Skip to content

Commit

Permalink
ShaderUI, ArnoldShaderUI : Allow nodeGadget:color to be specified
Browse files Browse the repository at this point in the history
This allows the colour of the node in the GraphEditor to be customised on a per-shader basis.
  • Loading branch information
johnhaddon committed Jun 21, 2024
1 parent 0244724 commit 077129b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Fixes
API
---

- ShaderUI : Added support for `nodeGadget:color` metadata registered against `{shaderType}:{shaderName}`, to specify per-shader colouring of nodes in the GraphEditor.
- ArnoldShaderUI : Added support for `gaffer.nodeGadget.color` RGB metadata in `.mtd` files, to specify per-shader colouring of nodes in the GraphEditor.
- Loop : Added `nextIterationContext()` method.

API
Expand Down
9 changes: 9 additions & 0 deletions python/GafferArnoldUI/ArnoldShaderUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ def __translateNodeMetadata( nodeEntry ) :
if iconScale is not None :
__metadata[nodeName]["iconScale"] = iconScale

# Node color.

color = __aiMetadataGetRGB( nodeEntry, None, "gaffer.nodeGadget.color" )
if color is not None :
Gaffer.Metadata.registerValue( "ai:surface:{}".format( nodeName ), "nodeGadget:color", color )

# Parameters
# ----------

paramIt = arnold.AiNodeEntryGetParamIterator( nodeEntry )
while not arnold.AiParamIteratorFinished( paramIt ) :

Expand Down
7 changes: 7 additions & 0 deletions python/GafferSceneUI/ShaderUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@
# Metadata
##########################################################################

def __shaderMetadata( node, key ) :

return Gaffer.Metadata.value(
node["type"].getValue() + ":" + node["name"].getValue(), key
)

def __parameterUserDefault( plug ) :

shader = plug.node()
Expand All @@ -75,6 +81,7 @@ def __parameterUserDefault( plug ) :
""",

"nodeGadget:minWidth", 0.0,
"nodeGadget:color", functools.partial( __shaderMetadata, key = "nodeGadget:color" ),

plugs = {

Expand Down

0 comments on commit 077129b

Please sign in to comment.