|
41 | 41 | #include "IECore/MessageHandler.h" |
42 | 42 | #include "IECore/SimpleTypedData.h" |
43 | 43 |
|
| 44 | +#if PXR_VERSION >= 2111 |
| 45 | +#include "pxr/usd/usdLux/cylinderLight.h" |
| 46 | +#include "pxr/usd/usdLux/sphereLight.h" |
| 47 | +#endif |
| 48 | + |
44 | 49 | #include "boost/algorithm/string/replace.hpp" |
45 | 50 | #include "boost/pointer_cast.hpp" |
46 | 51 |
|
@@ -70,6 +75,26 @@ pxr::TfToken shaderId( const pxr::UsdShadeConnectableAPI &connectable ) |
70 | 75 | return result; |
71 | 76 | } |
72 | 77 |
|
| 78 | +void readAdditionalLightParameters( const pxr::UsdPrim &prim, IECore::CompoundDataMap ¶meters ) |
| 79 | +{ |
| 80 | + // Just to keep us on our toes, not all light parameters are stored as UsdShade inputs, |
| 81 | + // so we have special-case code for loading those here. |
| 82 | +#if PXR_VERSION >= 2111 |
| 83 | + if( auto sphereLight = pxr::UsdLuxSphereLight( prim ) ) |
| 84 | + { |
| 85 | + bool treatAsPoint = false; |
| 86 | + sphereLight.GetTreatAsPointAttr().Get( &treatAsPoint ); |
| 87 | + parameters["treatAsPoint"] = new IECore::BoolData( treatAsPoint ); |
| 88 | + } |
| 89 | + else if( auto cylinderLight = pxr::UsdLuxCylinderLight( prim ) ) |
| 90 | + { |
| 91 | + bool treatAsLine = false; |
| 92 | + cylinderLight.GetTreatAsLineAttr().Get( &treatAsLine ); |
| 93 | + parameters["treatAsLine"] = new IECore::BoolData( treatAsLine ); |
| 94 | + } |
| 95 | +#endif |
| 96 | +} |
| 97 | + |
73 | 98 | IECoreScene::ShaderNetwork::Parameter readShaderNetworkWalk( const pxr::SdfPath &anchorPath, const pxr::UsdShadeOutput &output, IECoreScene::ShaderNetwork &shaderNetwork ); |
74 | 99 |
|
75 | 100 | IECore::InternedString readShaderNetworkWalk( const pxr::SdfPath &anchorPath, const pxr::UsdShadeConnectableAPI &usdShader, IECoreScene::ShaderNetwork &shaderNetwork ) |
@@ -137,6 +162,8 @@ IECore::InternedString readShaderNetworkWalk( const pxr::SdfPath &anchorPath, co |
137 | 162 | } |
138 | 163 | } |
139 | 164 |
|
| 165 | + readAdditionalLightParameters( usdShader.GetPrim(), parameters ); |
| 166 | + |
140 | 167 | parametersData = boost::const_pointer_cast< IECore::CompoundData >( IECoreScene::ShaderNetworkAlgo::collapseSplineParameters( parametersData ) ); |
141 | 168 |
|
142 | 169 | IECoreScene::ShaderPtr newShader = new IECoreScene::Shader( shaderName, shaderType, parametersData ); |
|
0 commit comments