Skip to content

Commit

Permalink
FIX : Add test to document corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldresser-ie committed May 22, 2024
1 parent 0d9dbd1 commit 036b159
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions python/GafferSceneTest/ShaderTweakProxyTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,47 @@ def test( self ) :
with self.assertRaisesRegex( Gaffer.ProcessException, 'Cannot use "texture1" in ShaderTweakProxy when tweaking "texture2", this would create cycle in shader network' ):
tweaks["out"].attributes( "/plane" )

def testAutoProxyValueTransferToComponent( self ) :

plane = GafferScene.Plane()
shader = GafferSceneTest.TestShader( "surface" )
shader["type"].setValue( "surface" )
shader["parameters"]["i"].setValue( 42 )

planeFilter = GafferScene.PathFilter()
planeFilter["paths"].setValue( IECore.StringVectorData( [ "/plane" ] ) )

assignment = GafferScene.ShaderAssignment()
assignment["in"].setInput( plane["out"] )
assignment["filter"].setInput( planeFilter["out"] )
assignment["shader"].setInput( shader["out"] )

tweakShader = GafferSceneTest.TestShader( "tweakShader" )

tweaks = GafferScene.ShaderTweaks()
tweaks["in"].setInput( assignment["out"] )
tweaks["filter"].setInput( planeFilter["out"] )
tweaks["shader"].setValue( "surface" )

tweaks["tweaks"].addChild( Gaffer.TweakPlug( "i", Gaffer.IntPlug() ) )
tweaks["tweaks"][0]["value"].setInput( tweakShader["out"]["r"] )

autoProxy = GafferScene.ShaderTweakProxy()
autoProxy.setupAutoProxy( Gaffer.IntPlug() )

tweakShader["parameters"]["c"]["g"].setInput( autoProxy["out"]["auto"] )

# This is quite a special case - there is no input to the parameter we are tweaking, so there is no
# connection to transfer, so we would expect the auto proxy to transfer the value - however the auto
# proxy output is connected to a subcomponent.
#
# The correct result is that the green component of tweakShader.c should be set to 42, transferring the value
# that was set. However, we have not yet added support for this fairly obscure case, so instead this test
# documents the current behaviour, which is to throw a semi-helpful exception.

with self.assertRaisesRegex( Gaffer.ProcessException, 'CompoundData has no child named "c.g"' ):
tweaks["out"].attributes( "/plane" )["surface"]

def testInvalidInShaderAssignment( self ) :

plane = GafferScene.Plane()
Expand Down

0 comments on commit 036b159

Please sign in to comment.