diff --git a/Changes.md b/Changes.md index 81306905a85..7fb770373a1 100644 --- a/Changes.md +++ b/Changes.md @@ -8,6 +8,7 @@ Improvements - LightEditor : Added column for Arnold 7.4.4.0's new `sampling_mode` parameter. - ArnoldShader : Moved Arnold 7.4.4.0's new `standard_hair.scattering_mode` parameter to the "Specular" section of the UI. - ArnoldImager : Added activators for Arnold 7.4.4.0's new `lens_effects` imager parameters. +- OSLShader : Added forward compatibility for splines parameters saved from Gaffer 1.7. Fixes ----- diff --git a/startup/Gaffer/rampPlugCompatibility.py b/startup/Gaffer/rampPlugCompatibility.py new file mode 100644 index 00000000000..e6f0015a80d --- /dev/null +++ b/startup/Gaffer/rampPlugCompatibility.py @@ -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 diff --git a/startup/GafferOSL/shaderNameCompatibility.py b/startup/GafferOSL/shaderNameCompatibility.py index d28b2147c23..10b0eb820e2 100644 --- a/startup/GafferOSL/shaderNameCompatibility.py +++ b/startup/GafferOSL/shaderNameCompatibility.py @@ -34,6 +34,8 @@ # ########################################################################## +import Gaffer + import GafferOSL __nameMapping = { @@ -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__` # to `mx___` here : # @@ -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 )