From 5b195df14e3272110437728942aa814ca9041f6e Mon Sep 17 00:00:00 2001 From: John Haddon Date: Tue, 26 Mar 2024 15:15:35 +0000 Subject: [PATCH] InteractiveRenderTest : Fix ShaderAssignment connections We were always connecting from `shader["out"]`, but we should be connecting from `shader["out"][""]` for well-behaved nodes that represent outputs as we want them. --- Changes.md | 5 ++ .../InteractiveArnoldRenderTest.py | 18 +++---- .../InteractiveCyclesRenderTest.py | 4 +- .../InteractiveDelightRenderTest.py | 6 +-- .../GafferSceneTest/InteractiveRenderTest.py | 54 ++++++++++--------- 5 files changed, 47 insertions(+), 40 deletions(-) diff --git a/Changes.md b/Changes.md index b5cc40daba3..ec4310f39db 100644 --- a/Changes.md +++ b/Changes.md @@ -34,6 +34,11 @@ API - ProcessorWidget provides a base class for custom widgets, and a factory mechanism for registering them against processors. - SimpleProcessorWidget provides a base class for widgets with a simple summary label and optional action links. +Breaking Changes +---------------- + +- InteractiveRenderTest : Subclasses must now return the shader output plug from creation methods such as `_createConstantShader()`. + 1.4.0.0b5 (relative to 1.4.0.0b4) ========= diff --git a/python/GafferArnoldTest/InteractiveArnoldRenderTest.py b/python/GafferArnoldTest/InteractiveArnoldRenderTest.py index 66b977edcd8..ba1c9f26989 100644 --- a/python/GafferArnoldTest/InteractiveArnoldRenderTest.py +++ b/python/GafferArnoldTest/InteractiveArnoldRenderTest.py @@ -198,8 +198,8 @@ def testLightLinkingAfterParameterUpdates( self ) : s["ShaderAssignment"]["in"].setInput( s["s"]["out"] ) s["ShaderAssignment"]["filter"].setInput( s["PathFilter"]["out"] ) - s["lambert"], _ = self._createMatteShader() - s["ShaderAssignment"]["shader"].setInput( s["lambert"]["out"] ) + s["lambert"], _, lambertOut = self._createMatteShader() + s["ShaderAssignment"]["shader"].setInput( lambertOut ) s["StandardAttributes"] = GafferScene.StandardAttributes( "StandardAttributes" ) s["StandardAttributes"]["attributes"]["linkedLights"]["enabled"].setValue( True ) @@ -287,8 +287,8 @@ def testQuadLightTextureEdits( self ) : s["ShaderAssignment"]["in"].setInput( s["s"]["out"] ) s["ShaderAssignment"]["filter"].setInput( s["PathFilter"]["out"] ) - s["lambert"], _ = self._createMatteShader() - s["ShaderAssignment"]["shader"].setInput( s["lambert"]["out"] ) + s["lambert"], _, lambertOut = self._createMatteShader() + s["ShaderAssignment"]["shader"].setInput( lambertOut ) s["Tex"] = GafferArnold.ArnoldShader( "image" ) s["Tex"].loadShader( "image" ) @@ -385,9 +385,9 @@ def testFlushCache( self ) : s["Tex"]["parameters"]["filename"].setValue( tmpTextureFile ) # Create a constant shader - s["constant"], shaderColor = self._createConstantShader() + s["constant"], shaderColor, constantOut = self._createConstantShader() shaderColor.setInput( s["Tex"]["out"] ) - s["ShaderAssignment"]["shader"].setInput( s["constant"]["out"] ) + s["ShaderAssignment"]["shader"].setInput( constantOut ) s["c"] = GafferScene.Camera() s["c"]["transform"]["translate"]["z"].setValue( 2 ) @@ -919,14 +919,14 @@ def _createConstantShader( self ) : shader = GafferArnold.ArnoldShader() shader.loadShader( "flat" ) - return shader, shader["parameters"]["color"] + return shader, shader["parameters"]["color"], shader["out"] def _createMatteShader( self ) : shader = GafferArnold.ArnoldShader() shader.loadShader( "lambert" ) shader["parameters"]["Kd"].setValue( 1 ) - return shader, shader["parameters"]["Kd_color"] + return shader, shader["parameters"]["Kd_color"], shader["out"] def _createTraceSetShader( self ) : # It's currently pretty ugly how we need to disable the trace set when it is left empty, @@ -965,7 +965,7 @@ def _createTraceSetShader( self ) : Gaffer.PlugAlgo.promote( switchShader["out"] ) - return shaderBox, traceSetShader["parameters"]["trace_set"] + return shaderBox, traceSetShader["parameters"]["trace_set"], shaderBox["out"] def _cameraVisibilityAttribute( self ) : diff --git a/python/GafferCyclesTest/InteractiveCyclesRenderTest.py b/python/GafferCyclesTest/InteractiveCyclesRenderTest.py index f72f0f5d53e..329d0eb5a20 100644 --- a/python/GafferCyclesTest/InteractiveCyclesRenderTest.py +++ b/python/GafferCyclesTest/InteractiveCyclesRenderTest.py @@ -123,13 +123,13 @@ def _createConstantShader( self ) : shader = GafferCycles.CyclesShader() shader.loadShader( "emission" ) shader["parameters"]["strength"].setValue( 1 ) - return shader, shader["parameters"]["color"] + return shader, shader["parameters"]["color"], shader["out"]["emission"] def _createMatteShader( self ) : shader = GafferCycles.CyclesShader() shader.loadShader( "diffuse_bsdf" ) - return shader, shader["parameters"]["color"] + return shader, shader["parameters"]["color"], shader["out"]["BSDF"] def _createTraceSetShader( self ) : diff --git a/python/GafferDelightTest/InteractiveDelightRenderTest.py b/python/GafferDelightTest/InteractiveDelightRenderTest.py index 457243e2214..4736f524e12 100644 --- a/python/GafferDelightTest/InteractiveDelightRenderTest.py +++ b/python/GafferDelightTest/InteractiveDelightRenderTest.py @@ -96,11 +96,11 @@ def _createConstantShader( self ) : shader = GafferOSL.OSLShader() shader.loadShader( "Surface/Constant" ) - return shader, shader["parameters"]["Cs"] + return shader, shader["parameters"]["Cs"], shader["out"]["out"] def _createTraceSetShader( self ) : - return None, None + return None, None, None def _cameraVisibilityAttribute( self ) : @@ -110,7 +110,7 @@ def _createMatteShader( self ) : shader = GafferOSL.OSLShader() shader.loadShader( "lambert" ) - return shader, shader["parameters"]["i_color"] + return shader, shader["parameters"]["i_color"], shader["out"]["outColor"] def _createPointLight( self ) : diff --git a/python/GafferSceneTest/InteractiveRenderTest.py b/python/GafferSceneTest/InteractiveRenderTest.py index 72ab1ba9c7a..10aa483b08f 100644 --- a/python/GafferSceneTest/InteractiveRenderTest.py +++ b/python/GafferSceneTest/InteractiveRenderTest.py @@ -561,12 +561,12 @@ def testShaderEdits( self ) : s["catalogue"] = GafferImage.Catalogue() s["s"] = GafferScene.Sphere() - s["shader"], colorPlug = self._createConstantShader() + s["shader"], colorPlug, shaderOut = self._createConstantShader() colorPlug.setValue( imath.Color3f( 1, 0, 0 ) ) s["a"] = GafferScene.ShaderAssignment() s["a"]["in"].setInput( s["s"]["out"] ) - s["a"]["shader"].setInput( s["shader"]["out"] ) + s["a"]["shader"].setInput( shaderOut ) s["o"] = GafferScene.Outputs() s["o"].addOutput( @@ -942,10 +942,10 @@ def testLights( self ) : s["g"]["in"][1].setInput( s["p"]["out"] ) s["g"]["in"][2].setInput( s["c"]["out"] ) - s["s"], unused = self._createMatteShader() + s["s"], unused, shaderOut = self._createMatteShader() s["a"] = GafferScene.ShaderAssignment() s["a"]["in"].setInput( s["g"]["out"] ) - s["a"]["shader"].setInput( s["s"]["out"] ) + s["a"]["shader"].setInput( shaderOut ) s["d"] = GafferScene.Outputs() s["d"].addOutput( @@ -1039,10 +1039,10 @@ def testAddLight( self ) : s["g"]["in"][1].setInput( s["p"]["out"] ) s["g"]["in"][2].setInput( s["c"]["out"] ) - s["s"], unused = self._createMatteShader() + s["s"], unused, shaderOut = self._createMatteShader() s["a"] = GafferScene.ShaderAssignment() s["a"]["in"].setInput( s["g"]["out"] ) - s["a"]["shader"].setInput( s["s"]["out"] ) + s["a"]["shader"].setInput( shaderOut ) s["d"] = GafferScene.Outputs() s["d"].addOutput( @@ -1119,10 +1119,10 @@ def testRemoveLight( self ) : s["g"]["in"][1].setInput( s["p"]["out"] ) s["g"]["in"][2].setInput( s["c"]["out"] ) - s["s"], unused = self._createMatteShader() + s["s"], unused, shaderOut = self._createMatteShader() s["a"] = GafferScene.ShaderAssignment() s["a"]["in"].setInput( s["g"]["out"] ) - s["a"]["shader"].setInput( s["s"]["out"] ) + s["a"]["shader"].setInput( shaderOut ) s["d"] = GafferScene.Outputs() s["d"].addOutput( @@ -1199,10 +1199,10 @@ def testHideLight( self ) : s["g"]["in"][1].setInput( s["p"]["out"] ) s["g"]["in"][2].setInput( s["c"]["out"] ) - s["s"], unused = self._createMatteShader() + s["s"], unused, shaderOut = self._createMatteShader() s["a"] = GafferScene.ShaderAssignment() s["a"]["in"].setInput( s["g"]["out"] ) - s["a"]["shader"].setInput( s["s"]["out"] ) + s["a"]["shader"].setInput( shaderOut ) s["d"] = GafferScene.Outputs() s["d"].addOutput( @@ -1473,12 +1473,12 @@ def testTraceSets( self ) : s["group"]["in"][0].setInput( s["reflector"]["out"] ) s["group"]["in"][1].setInput( s["reflected"]["out"] ) - s["constant"], constantParameter = self._createConstantShader() + s["constant"], constantParameter, constantOut = self._createConstantShader() s["constantAssignment"] = GafferScene.ShaderAssignment() s["constantAssignment"]["in"].setInput( s["group"]["out"] ) - s["constantAssignment"]["shader"].setInput( s["constant"]["out"] ) + s["constantAssignment"]["shader"].setInput( constantOut ) - traceShader, traceSetParameter = self._createTraceSetShader() + traceShader, traceSetParameter, traceShaderOut = self._createTraceSetShader() if traceShader is None : self.skipTest( "Trace set shader not available" ) @@ -1489,7 +1489,7 @@ def testTraceSets( self ) : s["traceAssignment"] = GafferScene.ShaderAssignment() s["traceAssignment"]["in"].setInput( s["constantAssignment"]["out"] ) - s["traceAssignment"]["shader"].setInput( s["traceShader"]["out"] ) + s["traceAssignment"]["shader"].setInput( traceShaderOut ) s["traceAssignment"]["filter"].setInput( s["traceAssignmentFilter"]["out"] ) s["set"] = GafferScene.Set() @@ -1644,10 +1644,10 @@ def testLightFilters( self ) : script["group"]["in"][2].setInput( script["cam"]["out"] ) script["group"]["in"][3].setInput( script["attributes"]["out"] ) - script["shader"], unused = self._createMatteShader() + script["shader"], unused, shaderOut = self._createMatteShader() script["assignment"] = GafferScene.ShaderAssignment() script["assignment"]["in"].setInput( script["group"]["out"] ) - script["assignment"]["shader"].setInput( script["shader"]["out"] ) + script["assignment"]["shader"].setInput( shaderOut ) script["outputs"] = GafferScene.Outputs() script["outputs"].addOutput( @@ -1791,10 +1791,10 @@ def testLightFiltersAndSetEdits( self ) : script["plane"] = GafferScene.Plane() - script["shader"], unused = self._createMatteShader() + script["shader"], unused, shaderOut = self._createMatteShader() script["assignment"] = GafferScene.ShaderAssignment() script["assignment"]["in"].setInput( script["plane"]["out"] ) - script["assignment"]["shader"].setInput( script["shader"]["out"] ) + script["assignment"]["shader"].setInput( shaderOut ) script["camera"] = GafferScene.Camera() script["camera"]["transform"]["translate"]["z"].setValue( 1 ) @@ -1875,12 +1875,12 @@ def a() : result = GafferScene.SceneProcessor() - result["__shader"], colorPlug = self._createConstantShader() + result["__shader"], colorPlug, shaderOut = self._createConstantShader() colorPlug.setValue( imath.Color3f( 1, 0, 0 ) ) result["__assignment"] = GafferScene.ShaderAssignment() result["__assignment"]["in"].setInput( result["in"] ) - result["__assignment"]["shader"].setInput( result["__shader"]["out"] ) + result["__assignment"]["shader"].setInput( shaderOut ) result["out"].setInput( result["__assignment"]["out"] ) @@ -1936,10 +1936,10 @@ def testLightLinking( self ) : s["g"]["in"][1].setInput( s["p"]["out"] ) s["g"]["in"][2].setInput( s["c"]["out"] ) - s["s"], unused = self._createMatteShader() + s["s"], unused, shaderOut = self._createMatteShader() s["a"] = GafferScene.ShaderAssignment() s["a"]["in"].setInput( s["g"]["out"] ) - s["a"]["shader"].setInput( s["s"]["out"] ) + s["a"]["shader"].setInput( shaderOut ) s["d"] = GafferScene.Outputs() s["d"].addOutput( @@ -2023,10 +2023,10 @@ def testHideLinkedLight( self ) : s["group"]["in"][2].setInput( s["plane"]["out"] ) s["group"]["in"][3].setInput( s["camera"]["out"] ) - s["shader"], unused = self._createMatteShader() + s["shader"], unused, shaderOut = self._createMatteShader() s["shaderAssignment"] = GafferScene.ShaderAssignment() s["shaderAssignment"]["in"].setInput( s["group"]["out"] ) - s["shaderAssignment"]["shader"].setInput( s["shader"]["out"] ) + s["shaderAssignment"]["shader"].setInput( shaderOut ) s["outputs"] = GafferScene.Outputs() s["outputs"].addOutput( @@ -2286,14 +2286,16 @@ def fail( plug, source, message ) : ## Should be implemented by derived classes to return an # appropriate Shader node with a constant shader loaded, - # along with the plug for the colour parameter. + # along with the plug for the colour parameter and the output + # plug to be connected to a ShaderAssignment. def _createConstantShader( self ) : raise NotImplementedError ## Should be implemented by derived classes to return # an appropriate Shader node with a matte shader loaded, - # along with the plug for the colour parameter. + # along with the plug for the colour parameter and the output + # plug to be connected to a ShaderAssignment. def _createMatteShader( self ) : raise NotImplementedError