Skip to content

Commit

Permalink
UsdLux: Add support for shaping:ies:normalize
Browse files Browse the repository at this point in the history
(Internal change: 1974219)
  • Loading branch information
blevin authored and pixar-oss committed May 29, 2019
1 parent 0bdbd7d commit 875b9d4
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pxr/usd/lib/usdLux/generatedSchema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,11 @@ class "ShapingAPI" (
doc = """An IES (Illumination Engineering Society) light
profile describing the angular distribution of light."""
)
bool shaping:ies:normalize (
displayGroup = "Shaping"
doc = """Normalizes the IES profile so that it affects the shaping
of the light while preserving the overall energy output."""
)
}

class "ShadowAPI" (
Expand Down
5 changes: 5 additions & 0 deletions pxr/usd/lib/usdLux/schema.usda
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,11 @@ class "ShapingAPI" (
doc = """Rescales the angular distribution of the IES profile.
TODO: clarify semantics"""
)
bool shaping:ies:normalize (
displayGroup = "Shaping"
doc = """Normalizes the IES profile so that it affects the shaping
of the light while preserving the overall energy output."""
)
}

class "ShadowAPI" (
Expand Down
18 changes: 18 additions & 0 deletions pxr/usd/lib/usdLux/shapingAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,23 @@ UsdLuxShapingAPI::CreateShapingIesAngleScaleAttr(VtValue const &defaultValue, bo
writeSparsely);
}

UsdAttribute
UsdLuxShapingAPI::GetShapingIesNormalizeAttr() const
{
return GetPrim().GetAttribute(UsdLuxTokens->shapingIesNormalize);
}

UsdAttribute
UsdLuxShapingAPI::CreateShapingIesNormalizeAttr(VtValue const &defaultValue, bool writeSparsely) const
{
return UsdSchemaBase::_CreateAttr(UsdLuxTokens->shapingIesNormalize,
SdfValueTypeNames->Bool,
/* custom = */ false,
SdfVariabilityVarying,
defaultValue,
writeSparsely);
}

namespace {
static inline TfTokenVector
_ConcatenateAttributeNames(const TfTokenVector& left,const TfTokenVector& right)
Expand All @@ -222,6 +239,7 @@ UsdLuxShapingAPI::GetSchemaAttributeNames(bool includeInherited)
UsdLuxTokens->shapingConeSoftness,
UsdLuxTokens->shapingIesFile,
UsdLuxTokens->shapingIesAngleScale,
UsdLuxTokens->shapingIesNormalize,
};
static TfTokenVector allNames =
_ConcatenateAttributeNames(
Expand Down
22 changes: 22 additions & 0 deletions pxr/usd/lib/usdLux/shapingAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,28 @@ class UsdLuxShapingAPI : public UsdAPISchemaBase
USDLUX_API
UsdAttribute CreateShapingIesAngleScaleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;

public:
// --------------------------------------------------------------------- //
// SHAPINGIESNORMALIZE
// --------------------------------------------------------------------- //
/// Normalizes the IES profile so that it affects the shaping
/// of the light while preserving the overall energy output.
///
/// \n C++ Type: bool
/// \n Usd Type: SdfValueTypeNames->Bool
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: No Fallback
USDLUX_API
UsdAttribute GetShapingIesNormalizeAttr() const;

/// See GetShapingIesNormalizeAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDLUX_API
UsdAttribute CreateShapingIesNormalizeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;

public:
// ===================================================================== //
// Feel free to add custom code below this line, it will be preserved by
Expand Down
2 changes: 2 additions & 0 deletions pxr/usd/lib/usdLux/tokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ UsdLuxTokensType::UsdLuxTokensType() :
shapingFocusTint("shaping:focusTint", TfToken::Immortal),
shapingIesAngleScale("shaping:ies:angleScale", TfToken::Immortal),
shapingIesFile("shaping:ies:file", TfToken::Immortal),
shapingIesNormalize("shaping:ies:normalize", TfToken::Immortal),
specular("specular", TfToken::Immortal),
textureFile("texture:file", TfToken::Immortal),
textureFormat("texture:format", TfToken::Immortal),
Expand Down Expand Up @@ -119,6 +120,7 @@ UsdLuxTokensType::UsdLuxTokensType() :
shapingFocusTint,
shapingIesAngleScale,
shapingIesFile,
shapingIesNormalize,
specular,
textureFile,
textureFormat,
Expand Down
4 changes: 4 additions & 0 deletions pxr/usd/lib/usdLux/tokens.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ struct UsdLuxTokensType {
///
/// UsdLuxShapingAPI
const TfToken shapingIesFile;
/// \brief "shaping:ies:normalize"
///
/// UsdLuxShapingAPI
const TfToken shapingIesNormalize;
/// \brief "specular"
///
/// UsdLuxLight
Expand Down
14 changes: 14 additions & 0 deletions pxr/usd/lib/usdLux/wrapShapingAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ _CreateShapingIesAngleScaleAttr(UsdLuxShapingAPI &self,
return self.CreateShapingIesAngleScaleAttr(
UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Float), writeSparsely);
}

static UsdAttribute
_CreateShapingIesNormalizeAttr(UsdLuxShapingAPI &self,
object defaultVal, bool writeSparsely) {
return self.CreateShapingIesNormalizeAttr(
UsdPythonToSdfType(defaultVal, SdfValueTypeNames->Bool), writeSparsely);
}

} // anonymous namespace

Expand Down Expand Up @@ -165,6 +172,13 @@ void wrapUsdLuxShapingAPI()
&_CreateShapingIesAngleScaleAttr,
(arg("defaultValue")=object(),
arg("writeSparsely")=false))

.def("GetShapingIesNormalizeAttr",
&This::GetShapingIesNormalizeAttr)
.def("CreateShapingIesNormalizeAttr",
&_CreateShapingIesNormalizeAttr,
(arg("defaultValue")=object(),
arg("writeSparsely")=false))

;

Expand Down
1 change: 1 addition & 0 deletions pxr/usd/lib/usdLux/wrapTokens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ void wrapUsdLuxTokens()
_AddToken(cls, "shapingFocusTint", UsdLuxTokens->shapingFocusTint);
_AddToken(cls, "shapingIesAngleScale", UsdLuxTokens->shapingIesAngleScale);
_AddToken(cls, "shapingIesFile", UsdLuxTokens->shapingIesFile);
_AddToken(cls, "shapingIesNormalize", UsdLuxTokens->shapingIesNormalize);
_AddToken(cls, "specular", UsdLuxTokens->specular);
_AddToken(cls, "textureFile", UsdLuxTokens->textureFile);
_AddToken(cls, "textureFormat", UsdLuxTokens->textureFormat);
Expand Down

0 comments on commit 875b9d4

Please sign in to comment.