Skip to content

Commit

Permalink
FIX : Last round of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldresser-ie committed May 17, 2024
1 parent d8953de commit 42b2002
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
1.4.x.x (relative to 1.4.3.0)
=======

Features
--------

- ShaderTweaks : Added support for creating ShaderTweakProxy nodes that allow making input connections to the original network.

Improvements
------------

Expand Down
1 change: 0 additions & 1 deletion python/GafferArnoldUI/ArnoldShaderUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import imath

import Gaffer
import GafferScene
import GafferUI
import GafferImageUI
import GafferSceneUI
Expand Down
1 change: 0 additions & 1 deletion python/GafferOSLUI/OSLShaderUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

import Gaffer
import GafferUI
import GafferScene

import GafferOSL

Expand Down
7 changes: 7 additions & 0 deletions python/GafferSceneTest/ShaderTweakProxyTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ def test( self ) :
self.assertEqual( tweakedNetwork.input( ( "texture2", "c" ) ), ( "tweakShader", "out" ) )
self.assertEqual( tweakedNetwork.input( ( "tweakShader", "c" ) ), ( "", "" ) )

# Test using an auto-proxy on a parameter with no input ( it should apply the value to what the
# auto-proxy is connected to )
textureShader2["parameters"]["c"].setValue( imath.Color3f( 5, 6, 7 ) )
tweaks["tweaks"][0]["name"].setValue( "texture2.c" )
tweakedNetwork = tweaks["out"].attributes( "/plane" )["surface"]
self.assertEqual( tweakedNetwork.getShader( "tweakShader" ).parameters["c"].value, imath.Color3f( 5, 6, 7 ) )

# Test proxying a specific node using a named handle
tweaks["tweaks"][0]["name"].setValue( "c" )
Expand All @@ -129,6 +135,7 @@ def test( self ) :
self.assertEqual( tweakedNetwork.input( ( "surface", "c" ) ), ( "tweakShader", "out" ) )
self.assertEqual( tweakedNetwork.input( ( "tweakShader", "c" ) ), ( "texture2", "out" ) )

# Test error if we try to make a cycle
tweaks["tweaks"][0]["name"].setValue( "texture2.c" )
specificProxy["parameters"]["targetShader"].setValue( "texture1" )

Expand Down
3 changes: 2 additions & 1 deletion python/GafferSceneUI/ShaderTweakProxyUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
The handle of the upstream shader being fetched by this proxy - or Auto, indicating that
the original input of the parameter being ShaderTweaked will be used.
""",
"label", "Source Node",
"readOnly", True,
"nodule:type", "",
"stringPlugValueWidget:placeholderText", "Auto",
Expand Down Expand Up @@ -164,6 +163,8 @@ def __createShaderTweakProxy( plug, sourceHandle, sourceType, sourceName ):
result["parameters"]["targetShader"].setValue( sourceHandle )

plug.node().parent().addChild( result )
plug.node().scriptNode().selection().clear()
plug.node().scriptNode().selection().add( result )

# See if there are any output plugs on the new proxy which can be connected to this plug
for p in result["out"].children():
Expand Down
2 changes: 0 additions & 2 deletions src/GafferScene/ShaderAssignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

#include "GafferScene/ShaderAssignment.h"

#include "GafferScene/ShaderTweakProxy.h"

#include "Gaffer/Metadata.h"

#include "IECoreScene/ShaderNetwork.h"
Expand Down
7 changes: 2 additions & 5 deletions src/GafferScene/ShaderTweaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ bool ShaderTweaks::applyTweaks( IECoreScene::ShaderNetwork *shaderNetwork, Tweak
// are nodes in the two networks with the same name, which get uniquified during addShaders.
// This could be solved with an optional output unordered_map<oldHandle, newHandle>
// from addShaders(). For the moment, however, Doing this after merging simplifies all that.
std::vector<IECore::InternedString> shadersToDelete;

// If we need to check for cycles, we will need to populate a set of dependent shaders.
// We cache it in case there are multiple proxies connected to the same tweak.
Expand All @@ -462,8 +461,6 @@ bool ShaderTweaks::applyTweaks( IECoreScene::ShaderNetwork *shaderNetwork, Tweak
continue;
}

shadersToDelete.push_back( i.first );

ShaderNetwork::ConnectionRange range = shaderNetwork->outputConnections( i.first );
const std::vector<ShaderNetwork::Connection> outputConnections( range.begin(), range.end() );

Expand Down Expand Up @@ -501,8 +498,8 @@ bool ShaderTweaks::applyTweaks( IECoreScene::ShaderNetwork *shaderNetwork, Tweak
modifiedShader.first->second = proxyConnectedShader->copy();
}

const IECore::Data *origDestParameter = modifiedShader.first->second->parameters().at(c.destination.name).get();
modifiedShader.first->second->parameters()[c.destination.name] = castDataToType( shader->parameters().at(parameter.name).get(), origDestParameter );
const IECore::Data *origDestParameter = modifiedShader.first->second->parametersData()->member(c.destination.name, /* throwExceptions = */ true );
modifiedShader.first->second->parameters()[c.destination.name] = castDataToType( shader->parametersData()->member( parameter.name, /* throwExceptions = */ true ), origDestParameter );
}
}
else
Expand Down

0 comments on commit 42b2002

Please sign in to comment.