@@ -3055,6 +3055,13 @@ def testShaders( self ) :
30553055 ) )
30563056 manualComponentNetwork .setOutput ( IECoreScene .ShaderNetwork .Parameter ( "dest" , "" ) )
30573057
3058+
3059+ rmanSurface = IECoreScene .Shader ( "PxrFoo" , "osl:surface" , surface .parameters )
3060+ rmanNetwork = IECoreScene .ShaderNetwork ()
3061+ rmanNetwork .addShader ( "out" , rmanSurface )
3062+ rmanNetwork .setOutput ( IECoreScene .ShaderNetwork .Parameter ( "out" , "" ) )
3063+
3064+
30583065 writerRoot = IECoreScene .SceneInterface .create ( fileName , IECore .IndexedIO .OpenMode .Write )
30593066 shaderLocation = writerRoot .createChild ( "shaderLocation" )
30603067 shaderLocation .writeAttribute ( "ai:surface" , oneShaderNetwork , 0 )
@@ -3063,6 +3070,7 @@ def testShaders( self ) :
30633070 shaderLocation .writeAttribute ( "complex:surface" , complexNetwork , 0 )
30643071 shaderLocation .writeAttribute ( "componentConnection:surface" , componentConnectionNetwork , 0 )
30653072 shaderLocation .writeAttribute ( "manualComponent:surface" , manualComponentNetwork , 0 )
3073+ shaderLocation .writeAttribute ( "ri:surface" , rmanNetwork , 0 )
30663074
30673075 shaderLocation .writeAttribute ( "volume" , oneShaderNetwork , 0 ) # USD supports shaders without a prefix
30683076
@@ -3121,11 +3129,26 @@ def testShaders( self ) :
31213129 self .assertEqual ( textureUsd .GetInput ( "filename" ).Get (), "sometexture.tx" )
31223130
31233131
3132+
3133+
3134+ riShaderSource = mat .GetOutput ( "ri:surface" ).GetConnectedSource ()
3135+ self .assertEqual ( riShaderSource [1 ], "DEFAULT_OUTPUT" )
3136+ riShaderUsd = pxr .UsdShade .Shader ( riShaderSource [0 ].GetPrim () )
3137+ self .assertEqual ( riShaderUsd .GetShaderId (), "PxrFoo" )
3138+ self .assertEqual ( riShaderUsd .GetInput ( "c" ).Get (), "42" )
3139+ self .assertEqual ( riShaderUsd .GetInput ( "a" ).Get (), 42.0 )
3140+ self .assertEqual ( riShaderUsd .GetInput ( "g" ).Get (), 5 )
3141+ self .assertEqual ( riShaderUsd .GetInput ( "g_Knots" ).Get (), pxr .Vt .FloatArray ( [0 , 0 , 10 , 20 , 20 ] ) )
3142+ self .assertEqual ( riShaderUsd .GetInput ( "g_Colors" ).Get (), pxr .Vt .Vec3fArray (
3143+ [pxr .Gf .Vec3f ( 1 ), pxr .Gf .Vec3f ( 1 ), pxr .Gf .Vec3f ( 2 ), pxr .Gf .Vec3f ( 0 ), pxr .Gf .Vec3f ( 0 )]
3144+ ) )
3145+ self .assertEqual ( riShaderUsd .GetInput ( "g_Interpolation" ).Get (), 'linear' )
3146+
31243147 # Read via SceneInterface, and check that we've round-tripped successfully.
31253148
31263149 root = IECoreScene .SceneInterface .create ( fileName , IECore .IndexedIO .OpenMode .Read )
31273150
3128- self .assertEqual ( set ( root .child ( "shaderLocation" ).attributeNames () ), set ( ['ai:disp_map' , 'ai:surface' , 'complex:surface' , 'volume' , 'componentConnection:surface' , 'manualComponent:surface' ] ) )
3151+ self .assertEqual ( set ( root .child ( "shaderLocation" ).attributeNames () ), set ( ['ai:disp_map' , 'ai:surface' , 'complex:surface' , 'volume' , 'componentConnection:surface' , 'manualComponent:surface' , "ri:surface" ] ) )
31293152
31303153 self .assertEqual ( root .child ( "shaderLocation" ).readAttribute ( "ai:surface" , 0 ).outputShader ().parameters , oneShaderNetwork .outputShader ().parameters )
31313154 self .assertEqual ( root .child ( "shaderLocation" ).readAttribute ( "ai:surface" , 0 ).outputShader (), oneShaderNetwork .outputShader () )
@@ -3150,6 +3173,13 @@ def testShaders( self ) :
31503173 self .assertEqual ( root .child ( "shaderLocation" ).readAttribute ( "componentConnection:surface" , 0 ), componentConnectionNetwork )
31513174 self .assertEqual ( root .child ( "shaderLocation" ).readAttribute ( "manualComponent:surface" , 0 ), manualComponentNetwork )
31523175
3176+ rmanSurfaceWithoutTypePrefix = IECoreScene .Shader ( "PxrFoo" , "surface" , surface .parameters )
3177+ rmanNetworkWithoutTypePrefix = IECoreScene .ShaderNetwork ()
3178+ rmanNetworkWithoutTypePrefix .addShader ( "out" , rmanSurfaceWithoutTypePrefix )
3179+ rmanNetworkWithoutTypePrefix .setOutput ( IECoreScene .ShaderNetwork .Parameter ( "out" , "" ) )
3180+
3181+ self .assertEqual ( root .child ( "shaderLocation" ).readAttribute ( "ri:surface" , 0 ), rmanNetworkWithoutTypePrefix )
3182+
31533183 def testManyShaders ( self ) :
31543184
31553185 # Write shaders
0 commit comments