Skip to content
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
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Improvements
- Parameters dragged from non-terminal shaders create tweaks that include the shader name to correctly identify the parameter.
- Added array parameter types to the tweak creation menu.
- PlugCreationWidget : User defaults are now applied to newly created `TweakPlug.mode` plugs.
- OSLShader : Added forward compatibility for spline parameters saved from Gaffer 1.7.

Fixes
-----
Expand Down
48 changes: 48 additions & 0 deletions startup/Gaffer/rampPlugCompatibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
##########################################################################
#
# Copyright (c) 2025, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with
# the distribution.
#
# * Neither the name of John Haddon nor the names of
# any other contributors to this software may be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################

import Gaffer
import IECore

IECore.RampInterpolation = Gaffer.SplineDefinitionInterpolation

IECore.Rampff = Gaffer.SplineDefinitionff
IECore.RampfColor3f = Gaffer.SplineDefinitionfColor3f
IECore.RampfColor4f = Gaffer.SplineDefinitionfColor4f

Gaffer.RampffPlug = Gaffer.SplineffPlug
Gaffer.RampfColor3fPlug = Gaffer.SplinefColor3fPlug
Gaffer.RampfColor4fPlug = Gaffer.SplinefColor4fPlug
18 changes: 17 additions & 1 deletion startup/GafferOSL/shaderNameCompatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#
##########################################################################

import Gaffer

import GafferOSL

__nameMapping = {
Expand All @@ -48,6 +50,8 @@
"Maths/FloatMultiply" : "Maths/MultiplyFloat",
"Maths/VectorAdd" : "Maths/AddVector",
"Maths/VectorMultiply" : "Maths/ScaleVector",
"Pattern/FloatRamp" : "Pattern/FloatSpline",
"Pattern/ColorRamp" : "Pattern/ColorSpline",
# A whole bunch of MaterialX shaders were renamed from `mx_<op>_<type>`
# to `mx_<op>_<type>_<type>` here :
#
Expand Down Expand Up @@ -149,8 +153,20 @@ def __loadShaderWrapper( originalLoadShader ) :

def loadRenamedShader( self, shaderName, **kwargs ) :
renamed = __nameMapping.get( shaderName, shaderName )
return originalLoadShader( self, renamed, **kwargs )
result = originalLoadShader( self, renamed, **kwargs )
if shaderName in [ "Pattern/FloatRamp", "Pattern/ColorRamp" ]:
self["parameters"]["direction"].setValue( "v" )
return result

return loadRenamedShader

GafferOSL.OSLShader.loadShader = __loadShaderWrapper( GafferOSL.OSLShader.loadShader )

def __rampAliasForSplines( plug ) :

if plug.node()["name"].getValue() in [ "Pattern/ColorSpline", "Pattern/FloatSpline" ]:
return "spline"

return None

Gaffer.Metadata.registerValue( GafferOSL.OSLShader, "parameters", "compatibility:childAlias:ramp", __rampAliasForSplines )