Skip to content

Commit 9afe1de

Browse files
committed
USDScene : Load treatAsPoint and treatAsLine for UsdLuxLights
1 parent cdfe4a3 commit 9afe1de

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

contrib/IECoreUSD/src/IECoreUSD/ShaderAlgo.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
#include "IECore/MessageHandler.h"
4242
#include "IECore/SimpleTypedData.h"
4343

44+
#if PXR_VERSION >= 2111
45+
#include "pxr/usd/usdLux/cylinderLight.h"
46+
#include "pxr/usd/usdLux/sphereLight.h"
47+
#endif
48+
4449
#include "boost/algorithm/string/replace.hpp"
4550
#include "boost/pointer_cast.hpp"
4651

@@ -70,6 +75,26 @@ pxr::TfToken shaderId( const pxr::UsdShadeConnectableAPI &connectable )
7075
return result;
7176
}
7277

78+
void readAdditionalLightParameters( const pxr::UsdPrim &prim, IECore::CompoundDataMap &parameters )
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+
7398
IECoreScene::ShaderNetwork::Parameter readShaderNetworkWalk( const pxr::SdfPath &anchorPath, const pxr::UsdShadeOutput &output, IECoreScene::ShaderNetwork &shaderNetwork );
7499

75100
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
137162
}
138163
}
139164

165+
readAdditionalLightParameters( usdShader.GetPrim(), parameters );
166+
140167
parametersData = boost::const_pointer_cast< IECore::CompoundData >( IECoreScene::ShaderNetworkAlgo::collapseSplineParameters( parametersData ) );
141168

142169
IECoreScene::ShaderPtr newShader = new IECoreScene::Shader( shaderName, shaderType, parametersData );

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3031,6 +3031,7 @@ def testLightAttribute( self ) :
30313031
"exposure" : 0.0,
30323032
"intensity" : 30000.0,
30333033
"radius" : 0.0,
3034+
"treatAsPoint" : True,
30343035
"shaping:cone:angle" : 66.0,
30353036
"shaping:cone:softness" : 1.0
30363037
} )

0 commit comments

Comments
 (0)