Skip to content

Commit

Permalink
Create shader attributes if its not created when query
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelliu-adsk committed Jul 19, 2023
1 parent 93cadb1 commit dd5d37c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 10 additions & 3 deletions lib/mayaUsd/ufe/UsdLight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ bool getLightShadowEnable(const UsdPrim& prim)
const UsdLuxShadowAPI shadowAPI(prim);
const PXR_NS::UsdAttribute lightAttribute = shadowAPI.GetShadowEnableAttr();

if (!lightAttribute) {
// If the shadow enable attribute is not created yet, create one here
shadowAPI.CreateShadowEnableAttr(VtValue(true));
}

bool val = false;
lightAttribute.Get(&val);
return val;
Expand All @@ -187,9 +192,6 @@ void setLightShadowEnable(const UsdPrim& prim, bool attrVal)

if (lightAttribute) {
lightAttribute.Set(attrVal);
} else {
const PXR_NS::UsdAttribute shadowAttribute = shadowAPI.CreateShadowEnableAttr();
shadowAttribute.Set(attrVal);
}
}

Expand All @@ -210,6 +212,11 @@ Ufe::Color3f getLightShadowColor(const UsdPrim& prim)
const UsdLuxShadowAPI shadowAPI(prim);
const PXR_NS::UsdAttribute lightAttribute = shadowAPI.GetShadowColorAttr();

if (!lightAttribute) {
// If the shadow color attribute is not created yet, create one here
shadowAPI.CreateShadowColorAttr();
}

GfVec3f val(0.f, 0.f, 0.f);
lightAttribute.Get(&val);
return Ufe::Color3f(val[0], val[1], val[2]);
Expand Down
5 changes: 1 addition & 4 deletions lib/mayaUsd/ufe/UsdLightHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ Ufe::Light::Ptr UsdLightHandler::light(const Ufe::SceneItem::Ptr& item) const
if (!lightSchema)
return nullptr;

UsdLight::Ptr usdLight = UsdLight::create(usdItem);
usdLight->shadowEnable(true);

return usdLight;
return UsdLight::create(usdItem);
}

} // namespace ufe
Expand Down

0 comments on commit dd5d37c

Please sign in to comment.