Skip to content

Commit

Permalink
fixup! 3Delight ShaderNetworkAlgo : Translate UsdPreviewSurface to 3D…
Browse files Browse the repository at this point in the history
…elight

Ensure dlPrimitiveAttribute outputs UVs in older 3Delight versions
  • Loading branch information
murraystevenson committed Apr 26, 2024
1 parent 535401f commit 39f0c2e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/IECoreDelightTest/ShaderNetworkAlgoTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def testConvertUSDPrimvarReader( self ) :

reader = network.getShader( "reader" )
self.assertEqual( reader.name, convertedShaderType )
self.assertEqual( len( reader.parameters ), 2 )
self.assertEqual( len( reader.parameters ), 3 if convertedShaderType == "dlPrimitiveAttribute" else 2 )
self.assertEqual( reader.parameters["attribute_name" if convertedShaderType == "dlPrimitiveAttribute" else "name"].value, "test" )
self.assertEqual( reader.parameters["fallback_value" if convertedShaderType == "dlPrimitiveAttribute" else "defaultValue"].value, convertedDefault )

Expand Down
2 changes: 2 additions & 0 deletions src/IECoreDelight/ShaderNetworkAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ Color3f blackbody( float kelvins )

const InternedString g_angleParameter( "angle" );
const InternedString g_attributeNameParameter( "attribute_name" );
const InternedString g_attributeTypeParameter( "attribute_type" );
const InternedString g_aParameter( "a" );
const InternedString g_bParameter( "b" );
const InternedString g_baseParameter( "base" );
Expand Down Expand Up @@ -903,6 +904,7 @@ void convertUSDShaders( ShaderNetwork *shaderNetwork )
else if( shader->getName() == "UsdPrimvarReader_float2" )
{
newShader = new Shader( "dlPrimitiveAttribute", "osl:surface" );
newShader->parameters()[g_attributeTypeParameter] = new IntData( 3 ); // UV
transferUSDParameter( shaderNetwork, handle, shader.get(), g_varnameParameter, newShader.get(), g_attributeNameParameter, std::string() );
transferUSDParameter( shaderNetwork, handle, shader.get(), g_fallbackParameter, newShader.get(), g_fallbackValueParameter, V2f( 0 ) );
convertVecToColor<V2f, Color3f>( newShader.get(), g_fallbackValueParameter );
Expand Down

0 comments on commit 39f0c2e

Please sign in to comment.