From 1d2bfd61801bd8f63b42d99f7a2ba890e176c6ac Mon Sep 17 00:00:00 2001 From: John Haddon Date: Tue, 4 Jun 2024 16:28:12 +0100 Subject: [PATCH] USD AttributeAlgo : Don't treat `arnold:*` light primvars as attributes Since 0590bbfdadaee2c26295e404abd951f98c79b570, they have been converted to light parameters instead. --- Changes | 4 +++- contrib/IECoreUSD/src/IECoreUSD/AttributeAlgo.cpp | 13 +++++++++++++ contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 058e276177..6fe439da10 100644 --- a/Changes +++ b/Changes @@ -11,7 +11,9 @@ Fixes - ShaderNetworkAlgo : Fixed crash caused by cyclic connections in `removeUnusedShaders()`. - ShaderStateComponent : Fixed GL rendering failures caused by unsupported values for texture parameters. -- USDScene : Fixed exceptions caused by attempt to write shader parameters with unsupported value types. +- USDScene : + - Fixed exceptions caused by attempt to write shader parameters with unsupported value types. + - Fixed duplicate loading of `arnold:*` primvars on lights as attributes. These are now only loaded as parameters on the light shader. - IECoreUSD::DataAlgo : Fixed exceptions thrown by `toUSD()` and `valueTypeName()` when passed datatypes not supported by `dispatch()`. An empty VtValue or SdfValueTypeName is now returned instead. Build diff --git a/contrib/IECoreUSD/src/IECoreUSD/AttributeAlgo.cpp b/contrib/IECoreUSD/src/IECoreUSD/AttributeAlgo.cpp index 1c368a198c..cb30723eef 100644 --- a/contrib/IECoreUSD/src/IECoreUSD/AttributeAlgo.cpp +++ b/contrib/IECoreUSD/src/IECoreUSD/AttributeAlgo.cpp @@ -40,6 +40,8 @@ IECORE_PUSH_DEFAULT_VISIBILITY #include "pxr/usd/usdGeom/primvar.h" #include "pxr/usd/usdGeom/primvarsAPI.h" + +#include "pxr/usd/usdLux/lightAPI.h" IECORE_POP_DEFAULT_VISIBILITY using namespace IECoreUSD; @@ -92,6 +94,17 @@ bool IECoreUSD::AttributeAlgo::isCortexAttribute( const pxr::UsdGeomPrimvar &pri } } + // Check for `arnold:*` primvars on lights. These will be loaded as + // parameters in `ShaderAlgo::readLight()`. + + if( + boost::starts_with( primVar.GetPrimvarName().GetString(), "arnold:" ) && + pxr::UsdLuxLightAPI( primVar.GetAttr().GetPrim() ) + ) + { + return false; + } + // Everything else should be loaded as a Cortex attribute. return true; diff --git a/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py b/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py index 964555089b..84bdcb76c5 100644 --- a/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py +++ b/contrib/IECoreUSD/test/IECoreUSD/USDSceneTest.py @@ -4165,6 +4165,7 @@ def testArnoldSpecificLightInputs( self ) : root = IECoreScene.SceneInterface.create( fileName, IECore.IndexedIO.OpenMode.Read ) self.assertEqual( root.child( "light" ).readAttribute( "light", 0 ), lightShader ) + self.assertEqual( root.child( "light" ).attributeNames(), [ "light" ] ) def testTreatLightAsPointOrLine( self ) :