diff --git a/python/GafferSceneTest/ShaderTweakProxyTest.py b/python/GafferSceneTest/ShaderTweakProxyTest.py index d4938b1cd1e..ff5622c413f 100644 --- a/python/GafferSceneTest/ShaderTweakProxyTest.py +++ b/python/GafferSceneTest/ShaderTweakProxyTest.py @@ -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()