Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArnoldShaderUI : Add presets menu for image.color_space parameter #5625

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
1.3.x.x (relative to 1.3.10.0)
=======

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

- ArnoldShader : Added a colour space presets menu for the `image` shader.
- CyclesShader : Added a colour space presets menu for the `image_texture` and `environment_texture` shaders (#5618).

API
---

- ArnoldShaderUI : Added support for `colorSpace` widget type metadata, allowing an OpenColorIO colour space to be chosen.

1.3.10.0 (relative to 1.3.9.0)
========

Expand Down
1 change: 1 addition & 0 deletions arnoldPlugins/gaffer.mtd
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,7 @@
gaffer.fileSystemPath.extensions STRING "tx"
[attr color_space]
gaffer.layout.index INT 1
widget STRING "colorSpace"
[attr uvset]
gaffer.layout.index INT 2

Expand Down
14 changes: 14 additions & 0 deletions python/GafferArnoldUI/ArnoldShaderUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

import Gaffer
import GafferUI
import GafferImageUI
import GafferSceneUI
import GafferArnold

Expand Down Expand Up @@ -289,13 +290,26 @@ def __translateNodeMetadata( nodeEntry ) :
"mapper" : "GafferUI.PresetsPlugValueWidget",
"filename" : "GafferUI.FileSystemPathPlugValueWidget",
"camera" : "GafferSceneUI.ScenePathPlugValueWidget",
"colorSpace" : "GafferUI.PresetsPlugValueWidget",
"null" : "",
}[widget]

if widget == "camera" :
__metadata[paramPath]["scenePathPlugValueWidget:setNames"] = IECore.StringVectorData( [ "__cameras" ] )
__metadata[paramPath]["scenePathPlugValueWidget:setsLabel"] = "Show only cameras"

if widget == "colorSpace" :
# Here we're assuming that Arnold is being used with an OCIO
# colour manager configured to match Gaffer.
__metadata[paramPath]["presetNames"] = GafferImageUI.OpenColorIOTransformUI.colorSpacePresetNames
__metadata[paramPath]["presetValues"] = GafferImageUI.OpenColorIOTransformUI.colorSpacePresetValues
__metadata[paramPath]["openColorIO:extraPresetNames"] = IECore.StringVectorData( [ "Auto" ] )
__metadata[paramPath]["openColorIO:extraPresetValues"] = IECore.StringVectorData( [ "auto" ] )
__metadata[paramPath]["openColorIO:includeRoles"] = True
# Allow custom values in case Arnold has been configured to use
# some other colour manager instead.
__metadata[paramPath]["presetsPlugValueWidget:allowCustom"] = True

# Layout section from OSL "page".

page = __aiMetadataGetStr( nodeEntry, paramName, "page" )
Expand Down
20 changes: 19 additions & 1 deletion python/GafferCyclesUI/CyclesShaderUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import GafferUI
import GafferCycles
import GafferImage
import GafferImageUI

##########################################################################
# Build a registry of information retrieved from GafferCycles metadata.
Expand Down Expand Up @@ -122,6 +123,19 @@ def __translateNodesMetadata( nodeTypes ) :
paramPath = nodeTypeName + ".parameters.type"
__metadata[paramPath]["noduleLayout:visible"] = False

# Add OCIO colorspace menus where appropriate. There doesn't seem to be anywhere
# we can query this from the Cycles API, so we just hardcode it to shaders know about.

for parameter in [ "image_texture.parameters.colorspace", "environment_texture.parameters.colorspace" ] :
# Here we're assuming that Cycles is being used with an OCIO config that matches Gaffer's.
__metadata[parameter]["plugValueWidget:type"] = "GafferUI.PresetsPlugValueWidget"
__metadata[parameter]["presetNames"] = GafferImageUI.OpenColorIOTransformUI.colorSpacePresetNames
__metadata[parameter]["presetValues"] = GafferImageUI.OpenColorIOTransformUI.colorSpacePresetValues
__metadata[parameter]["openColorIO:extraPresetNames"] = IECore.StringVectorData( [ "Auto" ] )
__metadata[parameter]["openColorIO:extraPresetValues"] = IECore.StringVectorData( [ "" ] )
__metadata[parameter]["openColorIO:includeRoles"] = True
# Allow custom values in case Cycles has been configured to use some other OCIO config.
__metadata[parameter]["presetsPlugValueWidget:allowCustom"] = True

##########################################################################
# Gaffer Metadata queries. These are implemented using the preconstructed
Expand Down Expand Up @@ -168,7 +182,11 @@ def __plugMetadata( plug, name ) :
# Node type is CyclesLight.
key = plug.node()["__shader"]["name"].getValue() + "." + plug.relativeName( node )

return __metadata[key].get( name )
result = __metadata[key].get( name )
if callable( result ) :
return result( plug )
else :
return result

for nodeType in ( GafferCycles.CyclesShader, GafferCycles.CyclesLight ) :

Expand Down
Loading