@@ -393,15 +393,26 @@ def testLocalise( self ) :
393
393
group = GafferScene .Group ()
394
394
group ["in" ][0 ].setInput ( plane ["out" ] )
395
395
396
+ globalSurface = GafferSceneTest .TestShader ( "surface" )
397
+ globalSurface ["type" ].setValue ( "surface" )
398
+ globalSurface ["parameters" ]["c" ].setValue ( imath .Color3f ( 4 , 5 , 6 ) )
399
+ globalSurface ["parameters" ]["i" ].setValue ( 3 )
400
+
401
+ globalAttributes = GafferScene .CustomAttributes ()
402
+ globalAttributes ["in" ].setInput ( group ["out" ] )
403
+ globalAttributes ["global" ].setValue ( True )
404
+ globalAttributes ["extraAttributes" ].setValue ( IECore .CompoundObject ( { "surface" : globalSurface .attributes ()["surface" ] } ) )
405
+
396
406
shader = GafferSceneTest .TestShader ( "surface" )
397
407
shader ["type" ].setValue ( "surface" )
398
408
shader ["parameters" ]["c" ].setValue ( imath .Color3f ( 1 , 2 , 3 ) )
409
+ shader ["parameters" ]["i" ].setValue ( 2 )
399
410
400
411
groupFilter = GafferScene .PathFilter ()
401
412
groupFilter ["paths" ].setValue ( IECore .StringVectorData ( [ "/group" ] ) )
402
413
403
414
assignment = GafferScene .ShaderAssignment ()
404
- assignment ["in" ].setInput ( group ["out" ] )
415
+ assignment ["in" ].setInput ( globalAttributes ["out" ] )
405
416
assignment ["filter" ].setInput ( groupFilter ["out" ] )
406
417
assignment ["shader" ].setInput ( shader ["out" ] )
407
418
@@ -438,10 +449,21 @@ def testLocalise( self ) :
438
449
439
450
planeAttr = tweaks ["out" ].attributes ( "/group/plane" )
440
451
self .assertTrue ( "surface" in planeAttr )
441
- self .assertEqual (
442
- planeAttr ["surface" ].getShader ( "surface" ).parameters ["c" ].value ,
443
- imath .Color3f ( 3 , 2 , 1 )
444
- )
452
+ shaderParameters = planeAttr ["surface" ].getShader ( "surface" ).parameters
453
+ self .assertEqual ( shaderParameters ["c" ].value , imath .Color3f ( 3 , 2 , 1 ) )
454
+ self .assertEqual ( shaderParameters ["i" ].value , 2 )
455
+
456
+ # Disable the shader assignment on "/group", our tweak should now localise
457
+ # the global shader.
458
+ assignment ["enabled" ].setValue ( False )
459
+
460
+ self .assertFalse ( "surface" in tweaks ["out" ].attributes ( "/group" ) )
461
+
462
+ planeAttr = tweaks ["out" ].attributes ( "/group/plane" )
463
+ self .assertTrue ( "surface" in planeAttr )
464
+ shaderParameters = planeAttr ["surface" ].getShader ( "surface" ).parameters
465
+ self .assertEqual ( shaderParameters ["c" ].value , imath .Color3f ( 3 , 2 , 1 ) )
466
+ self .assertEqual ( shaderParameters ["i" ].value , 3 )
445
467
446
468
# Test disabling tweak results in no localisation
447
469
0 commit comments