Skip to content

Commit

Permalink
InteractiveRenderTest : Fix ShaderAssignment connections
Browse files Browse the repository at this point in the history
We were always connecting from `shader["out"]`, but we should be connecting from `shader["out"]["<name>"]` for well-behaved nodes that represent outputs as we want them.
  • Loading branch information
johnhaddon committed Apr 3, 2024
1 parent 0dad727 commit 5b195df
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 40 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
=========

Expand Down
18 changes: 9 additions & 9 deletions python/GafferArnoldTest/InteractiveArnoldRenderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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" )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 ) :

Expand Down
4 changes: 2 additions & 2 deletions python/GafferCyclesTest/InteractiveCyclesRenderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) :

Expand Down
6 changes: 3 additions & 3 deletions python/GafferDelightTest/InteractiveDelightRenderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) :

Expand All @@ -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 ) :

Expand Down
54 changes: 28 additions & 26 deletions python/GafferSceneTest/InteractiveRenderTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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" )

Expand All @@ -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()
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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"] )

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5b195df

Please sign in to comment.