diff --git a/contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp b/contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp index c21b2d5035..ce6139134f 100644 --- a/contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp +++ b/contrib/IECoreUSD/src/IECoreUSD/USDScene.cpp @@ -1423,6 +1423,15 @@ void USDScene::attributesHash( double time, IECore::MurmurHash &h ) const // Kind can not be animated so no need to update `mightBeTimeVarying`. } +#if PXR_VERSION >= 2111 + if( m_location->prim.HasAPI() ) + { + /// \todo Consider time-varying lights - see comment below + /// for materials. + haveAttributes = true; + } +#endif + auto doubleSidedAttr = pxr::UsdGeomGprim( m_location->prim ).GetDoubleSidedAttr(); if( doubleSidedAttr && doubleSidedAttr.HasAuthoredValue() ) { diff --git a/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py b/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py index a604f2cd45..0d6e1b9462 100644 --- a/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py +++ b/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py @@ -3186,5 +3186,30 @@ def assertExpected( root ) : roundTripRoot = IECoreScene.SceneInterface.create( roundTripFileName, IECore.IndexedIO.OpenMode.Read ) assertExpected( roundTripRoot ) + def testMultipleLights( self ) : + + scene = IECoreScene.SceneInterface.create( + os.path.join( os.path.dirname( __file__ ), "data", "twoLights.usda" ), + IECore.IndexedIO.OpenMode.Read + ) + + self.assertIn( "__lights", scene.setNames() ) + self.assertEqual( scene.readSet( "__lights" ), IECore.PathMatcher( [ "/Light1", "/Light2" ] ) ) + + hashes = { + scene.child( n ).hash( scene.HashType.AttributesHash, 0 ) + for n in [ "NoLight", "Light1", "Light2" ] + } + self.assertEqual( len( hashes ), 3 ) + + for light, exposure in [ + ( "Light1", 1 ), + ( "Light2", 2 ), + ] : + self.assertEqual( scene.child( light ).attributeNames(), [ "light" ] ) + attribute = scene.child( light ).readAttribute( "light", 0 ) + self.assertIsInstance( attribute, IECoreScene.ShaderNetwork ) + self.assertEqual( attribute.outputShader().parameters["exposure"], IECore.FloatData( exposure ) ) + if __name__ == "__main__": unittest.main() diff --git a/contrib/IECoreUSD/test/IECoreUSD/data/twoLights.usda b/contrib/IECoreUSD/test/IECoreUSD/data/twoLights.usda new file mode 100644 index 0000000000..97b3d182da --- /dev/null +++ b/contrib/IECoreUSD/test/IECoreUSD/data/twoLights.usda @@ -0,0 +1,17 @@ +#usda 1.0 + +def Xform "NoLight" () +{ +} + +def SphereLight "Light1" ( +) +{ + float inputs:exposure = 1 +} + +def SphereLight "Light2" ( +) +{ + float inputs:exposure = 2 +}