Skip to content

Commit 18eb233

Browse files
authored
Merge pull request #1276 from johnhaddon/usdLuxHashFix
USDScene : Fix `attributesHash()` to consider UsdLuxLights
2 parents 2504593 + 80297f9 commit 18eb233

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,15 @@ void USDScene::attributesHash( double time, IECore::MurmurHash &h ) const
14231423
// Kind can not be animated so no need to update `mightBeTimeVarying`.
14241424
}
14251425

1426+
#if PXR_VERSION >= 2111
1427+
if( m_location->prim.HasAPI<pxr::UsdLuxLightAPI>() )
1428+
{
1429+
/// \todo Consider time-varying lights - see comment below
1430+
/// for materials.
1431+
haveAttributes = true;
1432+
}
1433+
#endif
1434+
14261435
auto doubleSidedAttr = pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr();
14271436
if( doubleSidedAttr && doubleSidedAttr.HasAuthoredValue() )
14281437
{

contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,5 +3211,30 @@ def assertExpected( root ) :
32113211
roundTripRoot = IECoreScene.SceneInterface.create( roundTripFileName, IECore.IndexedIO.OpenMode.Read )
32123212
assertExpected( roundTripRoot )
32133213

3214+
def testMultipleLights( self ) :
3215+
3216+
scene = IECoreScene.SceneInterface.create(
3217+
os.path.join( os.path.dirname( __file__ ), "data", "twoLights.usda" ),
3218+
IECore.IndexedIO.OpenMode.Read
3219+
)
3220+
3221+
self.assertIn( "__lights", scene.setNames() )
3222+
self.assertEqual( scene.readSet( "__lights" ), IECore.PathMatcher( [ "/Light1", "/Light2" ] ) )
3223+
3224+
hashes = {
3225+
scene.child( n ).hash( scene.HashType.AttributesHash, 0 )
3226+
for n in [ "NoLight", "Light1", "Light2" ]
3227+
}
3228+
self.assertEqual( len( hashes ), 3 )
3229+
3230+
for light, exposure in [
3231+
( "Light1", 1 ),
3232+
( "Light2", 2 ),
3233+
] :
3234+
self.assertEqual( scene.child( light ).attributeNames(), [ "light" ] )
3235+
attribute = scene.child( light ).readAttribute( "light", 0 )
3236+
self.assertIsInstance( attribute, IECoreScene.ShaderNetwork )
3237+
self.assertEqual( attribute.outputShader().parameters["exposure"], IECore.FloatData( exposure ) )
3238+
32143239
if __name__ == "__main__":
32153240
unittest.main()
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#usda 1.0
2+
3+
def Xform "NoLight" ()
4+
{
5+
}
6+
7+
def SphereLight "Light1" (
8+
)
9+
{
10+
float inputs:exposure = 1
11+
}
12+
13+
def SphereLight "Light2" (
14+
)
15+
{
16+
float inputs:exposure = 2
17+
}

0 commit comments

Comments
 (0)