From 9c852708731f3e7e18e882af6d9e3c37efc1564e Mon Sep 17 00:00:00 2001 From: John Haddon Date: Mon, 1 Apr 2013 17:37:34 -0700 Subject: [PATCH 1/3] Adding support for coshader parameters in RenderManShader. --- SConstruct | 4 +- include/GafferRenderMan/RenderManShader.h | 2 + .../RenderManShaderTest.py | 49 +++++++++++- .../GafferRenderManTest/RenderManTestCase.py | 66 ++++++++++++++++ python/GafferRenderManTest/__init__.py | 1 + .../GafferRenderManTest/shaders/coshader.sl | 50 +++++++++++++ .../shaders/coshaderParameter.sl | 45 +++++++++++ src/GafferRenderMan/RenderManShader.cpp | 75 ++++++++++++++++--- 8 files changed, 280 insertions(+), 12 deletions(-) create mode 100644 python/GafferRenderManTest/RenderManTestCase.py create mode 100644 python/GafferRenderManTest/shaders/coshader.sl create mode 100644 python/GafferRenderManTest/shaders/coshaderParameter.sl diff --git a/SConstruct b/SConstruct index 2e33d28ca0b..74f2ecd87fc 100644 --- a/SConstruct +++ b/SConstruct @@ -857,7 +857,9 @@ libraries = { "GafferRenderManUI" : {}, - "GafferRenderManTest" : {}, + "GafferRenderManTest" : { + "additionalFiles" : glob.glob( "python/GafferRenderManTest/*/*" ), + }, "apps" : { "additionalFiles" : glob.glob( "apps/*/*-1.py" ), diff --git a/include/GafferRenderMan/RenderManShader.h b/include/GafferRenderMan/RenderManShader.h index 29e8a220a42..74677beabaf 100644 --- a/include/GafferRenderMan/RenderManShader.h +++ b/include/GafferRenderMan/RenderManShader.h @@ -66,6 +66,8 @@ class RenderManShader : public GafferScene::Shader protected : + virtual bool acceptsInput( const Gaffer::Plug *plug, const Gaffer::Plug *inputPlug ) const; + virtual void shaderHash( IECore::MurmurHash &h ) const; virtual IECore::ShaderPtr shader( NetworkBuilder &network ) const; diff --git a/python/GafferRenderManTest/RenderManShaderTest.py b/python/GafferRenderManTest/RenderManShaderTest.py index 045e06ecbd4..1a3580b4a5a 100644 --- a/python/GafferRenderManTest/RenderManShaderTest.py +++ b/python/GafferRenderManTest/RenderManShaderTest.py @@ -34,14 +34,16 @@ # ########################################################################## +import os import unittest import IECore import Gaffer import GafferRenderMan +import GafferRenderManTest -class RenderManShaderTest( unittest.TestCase ) : +class RenderManShaderTest( GafferRenderManTest.RenderManTestCase ) : def test( self ) : @@ -127,6 +129,51 @@ def testParameterOrdering( self ) : self.assertEqual( n["parameters"][0].getName(), "Ka" ) self.assertEqual( n["parameters"][1].getName(), "Kd" ) + + def testCoshader( self ) : + + shader = self.compileShader( os.path.dirname( __file__ ) + "/shaders/coshaderParameter.sl" ) + + shaderNode = GafferRenderMan.RenderManShader() + shaderNode.loadShader( shader ) + + self.assertTrue( "coshaderParameter" in shaderNode["parameters"] ) + self.assertEqual( shaderNode["parameters"]["coshaderParameter"].typeId(), Gaffer.Plug.staticTypeId() ) + + coshader = self.compileShader( os.path.dirname( __file__ ) + "/shaders/coshader.sl" ) + + coshaderNode = GafferRenderMan.RenderManShader() + coshaderNode.loadShader( coshader ) + + shaderNode["parameters"]["coshaderParameter"].setInput( coshaderNode["out"] ) + + s = shaderNode.state() + self.assertEqual( len( s ), 2 ) + + self.assertEqual( s[0].name, coshader ) + self.assertEqual( s[1].name, shader ) + self.assertEqual( s[0].parameters["__handle"], s[1].parameters["coshaderParameter"] ) + + def testInputAcceptance( self ) : + + shader = self.compileShader( os.path.dirname( __file__ ) + "/shaders/coshaderParameter.sl" ) + shaderNode = GafferRenderMan.RenderManShader() + shaderNode.loadShader( shader ) + + coshader = self.compileShader( os.path.dirname( __file__ ) + "/shaders/coshader.sl" ) + coshaderNode = GafferRenderMan.RenderManShader() + coshaderNode.loadShader( coshader ) + + random = Gaffer.Random() + + self.assertTrue( shaderNode["parameters"]["coshaderParameter"].acceptsInput( coshaderNode["out"] ) ) + self.assertFalse( shaderNode["parameters"]["coshaderParameter"].acceptsInput( random["outFloat"] ) ) + + self.assertTrue( shaderNode["parameters"]["floatParameter"].acceptsInput( random["outFloat"] ) ) + self.assertFalse( shaderNode["parameters"]["floatParameter"].acceptsInput( coshaderNode["out"] ) ) + + self.assertTrue( coshaderNode["parameters"]["colorParameter"].acceptsInput( random["outColor"] ) ) + self.assertFalse( coshaderNode["parameters"]["colorParameter"].acceptsInput( coshaderNode["out"] ) ) if __name__ == "__main__": unittest.main() diff --git a/python/GafferRenderManTest/RenderManTestCase.py b/python/GafferRenderManTest/RenderManTestCase.py new file mode 100644 index 00000000000..bd11223f763 --- /dev/null +++ b/python/GafferRenderManTest/RenderManTestCase.py @@ -0,0 +1,66 @@ +########################################################################## +# +# Copyright (c) 2013, 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 os + +import GafferSceneTest + +class RenderManTestCase( GafferSceneTest.SceneTestCase ) : + + def setUp( self ) : + + self.__compiledShaders = set() + + def compileShader( self, sourceFileName ) : + + # perhaps one day we'll need to implement this for other renderman + # renderers, in which case we'll be glad we put all the calls in one + # place. + + shaderName = os.path.splitext( os.path.basename( sourceFileName ) )[0] + outputFileName = "/tmp/" + shaderName + ".sdl" + + os.system( "shaderdl -o %s %s" % ( outputFileName, sourceFileName ) ) + + self.__compiledShaders.add( outputFileName ) + + return os.path.splitext( outputFileName )[0] + + def tearDown( self ) : + + for f in self.__compiledShaders : + if os.path.exists( f ) : + os.remove( f ) diff --git a/python/GafferRenderManTest/__init__.py b/python/GafferRenderManTest/__init__.py index 850dc23de81..849e63aedd0 100644 --- a/python/GafferRenderManTest/__init__.py +++ b/python/GafferRenderManTest/__init__.py @@ -34,6 +34,7 @@ # ########################################################################## +from RenderManTestCase import RenderManTestCase from RenderManShaderTest import RenderManShaderTest from RenderManAttributesTest import RenderManAttributesTest from RenderManOptionsTest import RenderManOptionsTest diff --git a/python/GafferRenderManTest/shaders/coshader.sl b/python/GafferRenderManTest/shaders/coshader.sl new file mode 100644 index 00000000000..2afd6cd04d6 --- /dev/null +++ b/python/GafferRenderManTest/shaders/coshader.sl @@ -0,0 +1,50 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2013, 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. +// +////////////////////////////////////////////////////////////////////////// + +class coshader( + + float floatParameter = 10; + color colorParameter = ( 1, 1, 1 ); + +) +{ + + public color aMethodYouWillPayDearlyToCall() + { + return floatParameter * colorParameter; + } + +} diff --git a/python/GafferRenderManTest/shaders/coshaderParameter.sl b/python/GafferRenderManTest/shaders/coshaderParameter.sl new file mode 100644 index 00000000000..d68cd4c626a --- /dev/null +++ b/python/GafferRenderManTest/shaders/coshaderParameter.sl @@ -0,0 +1,45 @@ +////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2013, 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. +// +////////////////////////////////////////////////////////////////////////// + +surface coshaderParameter( + float floatParameter = 1; + string stringParameter = ""; + shader coshaderParameter = null; +) +{ + Ci = 1; + Oi = 1; +} diff --git a/src/GafferRenderMan/RenderManShader.cpp b/src/GafferRenderMan/RenderManShader.cpp index 7a6fb1ac9cf..ef031728581 100644 --- a/src/GafferRenderMan/RenderManShader.cpp +++ b/src/GafferRenderMan/RenderManShader.cpp @@ -67,6 +67,34 @@ void RenderManShader::loadShader( const std::string &shaderName ) getChild( "__shaderName" )->setValue( shaderName ); } +bool RenderManShader::acceptsInput( const Plug *plug, const Plug *inputPlug ) const +{ + if( !Shader::acceptsInput( plug, inputPlug ) ) + { + return false; + } + + if( plug->parent() == parametersPlug() ) + { + if( plug->typeId() == Plug::staticTypeId() ) + { + // coshader parameter - input must be another + // renderman shader. + const RenderManShader *inputShader = inputPlug->parent(); + return inputShader && inputPlug->getName() == "out"; + } + else + { + // standard parameter - input must not be another + // shader. + const Shader *inputShader = inputPlug->parent(); + return !inputShader; + } + } + + return true; +} + void RenderManShader::shaderHash( IECore::MurmurHash &h ) const { Shader::shaderHash( h ); @@ -76,9 +104,26 @@ void RenderManShader::shaderHash( IECore::MurmurHash &h ) const IECore::ShaderPtr RenderManShader::shader( NetworkBuilder &network ) const { ShaderPtr result = new IECore::Shader( getChild( "__shaderName" )->getValue(), "ri:surface" ); - for( InputValuePlugIterator it( parametersPlug() ); it!=it.end(); it++ ) + for( InputPlugIterator it( parametersPlug() ); it!=it.end(); it++ ) { - result->parameters()[(*it)->getName()] = CompoundDataPlug::extractDataFromPlug( *it ); + if( (*it)->typeId() == Plug::staticTypeId() ) + { + // coshader parameter + const Plug *inputPlug = (*it)->source(); + if( inputPlug && inputPlug != *it ) + { + const RenderManShader *inputShader = inputPlug->parent(); + if( inputShader ) + { + result->parameters()[(*it)->getName()] = new StringData( network.shaderHandle( inputShader ) ); + } + } + } + else + { + // standard shader parameter + result->parameters()[(*it)->getName()] = CompoundDataPlug::extractDataFromPlug( static_cast( it->get() ) ); + } } return result; } @@ -99,18 +144,28 @@ void RenderManShader::loadShaderParameters( const std::string &shaderName, Gaffe { IECore::ConstShaderPtr shader = runTimeCast( shaderLoader()->read( shaderName + ".sdl" ) ); + const CompoundData *typeHints = shader->blindData()->member( "ri:parameterTypeHints", true ); + const StringVectorData *orderedParameterNamesData = shader->blindData()->member( "ri:orderedParameterNames", true ); const vector &orderedParameterNames = orderedParameterNamesData->readable(); for( vector::const_iterator it = orderedParameterNames.begin(), eIt = orderedParameterNames.end(); it != eIt; it++ ) { - CompoundDataMap::const_iterator vIt = shader->parameters().find( *it ); - ValuePlugPtr valuePlug = CompoundDataPlug::createPlugFromData( - *it, - Plug::In, - Plug::Default | Plug::Dynamic, - vIt->second - ); - parametersPlug->addChild( valuePlug ); + const StringData *typeHint = typeHints->member( *it, false ); + if( typeHint && typeHint->readable() == "shader" ) + { + parametersPlug->addChild( new Plug( *it, Plug::In, Plug::Default | Plug::Dynamic ) ); + } + else + { + CompoundDataMap::const_iterator vIt = shader->parameters().find( *it ); + ValuePlugPtr valuePlug = CompoundDataPlug::createPlugFromData( + *it, + Plug::In, + Plug::Default | Plug::Dynamic, + vIt->second + ); + parametersPlug->addChild( valuePlug ); + } } } From a60b2f28e667d48452dba301b2ecc60c0bd5b3b7 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Mon, 1 Apr 2013 17:40:22 -0700 Subject: [PATCH 2/3] Rationalising shader ui by moving as many registrations as possible onto the GafferScene::Shader base class. Registering an appropriate Nodule creator for RenderManShader so that only coshader parameters appear in the node graph. --- python/GafferArnoldUI/ArnoldShaderUI.py | 14 ---- python/GafferRenderManUI/RenderManShaderUI.py | 57 +++++++++++++++++ python/GafferRenderManUI/__init__.py | 1 + python/GafferSceneUI/OpenGLShaderUI.py | 2 - python/GafferSceneUI/SceneNodeUI.py | 5 -- python/GafferSceneUI/ShaderUI.py | 64 +++++++++++++++++++ python/GafferSceneUI/__init__.py | 2 +- 7 files changed, 123 insertions(+), 22 deletions(-) create mode 100644 python/GafferRenderManUI/RenderManShaderUI.py create mode 100644 python/GafferSceneUI/ShaderUI.py diff --git a/python/GafferArnoldUI/ArnoldShaderUI.py b/python/GafferArnoldUI/ArnoldShaderUI.py index 127032cd347..051127aa985 100644 --- a/python/GafferArnoldUI/ArnoldShaderUI.py +++ b/python/GafferArnoldUI/ArnoldShaderUI.py @@ -45,20 +45,6 @@ import GafferUI import GafferArnold -## \todo This will belong with a Shader base class node at some point, probably in -# GafferScene. -def __nodeGadgetCreator( node ) : - - return GafferUI.StandardNodeGadget( node, GafferUI.LinearContainer.Orientation.Y ) - -GafferUI.NodeGadget.registerNodeGadget( GafferArnold.ArnoldShader.staticTypeId(), __nodeGadgetCreator ) - -def __parametersNoduleCreator( plug ) : - - return GafferUI.CompoundNodule( plug, GafferUI.LinearContainer.Orientation.Y ) - -GafferUI.Nodule.registerNodule( GafferArnold.ArnoldShader.staticTypeId(), "parameters", __parametersNoduleCreator ) - def __parameterNoduleCreator( plug ) : if isinstance( plug, ( Gaffer.BoolPlug, Gaffer.IntPlug, Gaffer.StringPlug ) ) : diff --git a/python/GafferRenderManUI/RenderManShaderUI.py b/python/GafferRenderManUI/RenderManShaderUI.py new file mode 100644 index 00000000000..215da5ea8bf --- /dev/null +++ b/python/GafferRenderManUI/RenderManShaderUI.py @@ -0,0 +1,57 @@ +########################################################################## +# +# Copyright (c) 2013, 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 fnmatch + +import Gaffer +import GafferUI + +import GafferRenderMan + +########################################################################## +# Nodules +########################################################################## + +def __parameterNoduleCreator( plug ) : + + # only coshader parameters should be connectable in the node + # graph. + if plug.typeId() == Gaffer.Plug.staticTypeId() : + return GafferUI.StandardNodule( plug ) + + return None + +GafferUI.Nodule.registerNodule( GafferRenderMan.RenderManShader.staticTypeId(), fnmatch.translate( "parameters.*" ), __parameterNoduleCreator ) diff --git a/python/GafferRenderManUI/__init__.py b/python/GafferRenderManUI/__init__.py index 94f2dc207ec..5cb053de838 100644 --- a/python/GafferRenderManUI/__init__.py +++ b/python/GafferRenderManUI/__init__.py @@ -37,4 +37,5 @@ import RenderManRenderUI import RenderManAttributesUI import RenderManOptionsUI +import RenderManShaderUI import Menus diff --git a/python/GafferSceneUI/OpenGLShaderUI.py b/python/GafferSceneUI/OpenGLShaderUI.py index 9809b330093..8c01af84364 100644 --- a/python/GafferSceneUI/OpenGLShaderUI.py +++ b/python/GafferSceneUI/OpenGLShaderUI.py @@ -49,8 +49,6 @@ # Nodules ########################################################################## -GafferUI.Nodule.registerNodule( GafferScene.OpenGLShader.staticTypeId(), "parameters", GafferUI.CompoundNodule ) - def __parameterNoduleCreator( plug ) : if isinstance( plug, ( GafferImage.ImagePlug ) ) : diff --git a/python/GafferSceneUI/SceneNodeUI.py b/python/GafferSceneUI/SceneNodeUI.py index 3e4f80d3638..faed9da890f 100644 --- a/python/GafferSceneUI/SceneNodeUI.py +++ b/python/GafferSceneUI/SceneNodeUI.py @@ -139,11 +139,6 @@ def __noduleCreator( plug ) : ), ) -# Shader - -GafferUI.PlugValueWidget.registerCreator( GafferScene.Shader.staticTypeId(), "parameters", GafferUI.CompoundPlugValueWidget, collapsed=None ) -GafferUI.PlugValueWidget.registerCreator( GafferScene.Shader.staticTypeId(), "out", None ) - # SceneElementProcessor GafferUI.Nodule.registerNodule( GafferScene.SceneElementProcessor.staticTypeId(), "filter", GafferUI.StandardNodule ) diff --git a/python/GafferSceneUI/ShaderUI.py b/python/GafferSceneUI/ShaderUI.py new file mode 100644 index 00000000000..325875921c7 --- /dev/null +++ b/python/GafferSceneUI/ShaderUI.py @@ -0,0 +1,64 @@ +########################################################################## +# +# Copyright (c) 2013, 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 GafferUI +import GafferScene + +########################################################################## +# PlugValueWidgets +########################################################################## + +GafferUI.PlugValueWidget.registerCreator( GafferScene.Shader.staticTypeId(), "parameters", GafferUI.CompoundPlugValueWidget, collapsed=None ) +GafferUI.PlugValueWidget.registerCreator( GafferScene.Shader.staticTypeId(), "out", None ) + +########################################################################## +# NodeGadgets and Nodules +########################################################################## + +def __nodeGadgetCreator( node ) : + + return GafferUI.StandardNodeGadget( node, GafferUI.LinearContainer.Orientation.Y ) + +GafferUI.NodeGadget.registerNodeGadget( GafferScene.Shader.staticTypeId(), __nodeGadgetCreator ) + +def __parametersNoduleCreator( plug ) : + + return GafferUI.CompoundNodule( plug, GafferUI.LinearContainer.Orientation.Y ) + +GafferUI.Nodule.registerNodule( GafferScene.Shader.staticTypeId(), "parameters", __parametersNoduleCreator ) + +# we leave it to the derived class uis to register creators for the parameters.* plugs, because only the derived classes know whether +# or not networkability makes sense in each case. diff --git a/python/GafferSceneUI/__init__.py b/python/GafferSceneUI/__init__.py index 16b9507d941..91b7e14c354 100644 --- a/python/GafferSceneUI/__init__.py +++ b/python/GafferSceneUI/__init__.py @@ -50,5 +50,5 @@ import SceneWriterUI import StandardOptionsUI import StandardAttributesUI +import ShaderUI import OpenGLShaderUI - From 904522a1d526c6bcdc509805c50d7a83fa30142d Mon Sep 17 00:00:00 2001 From: John Haddon Date: Mon, 1 Apr 2013 18:54:04 -0700 Subject: [PATCH 3/3] Updating Changes file. --- Changes | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Changes b/Changes index def4d61e2dc..6059ff0f0c7 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,8 @@ +* Added support for shader parameters of type "shader" in the RenderManShader node - these are mapped to plugs which accept connections to other RenderManShaders, allowing the creation of networks of coshaders. + +0.54.0 +====== + * Added base classes Executable and Despatcher and two derived Node classes: ExecutableNode and ExecutableOpHolder. * Added an enabled/disabled plug to all SceneNodes. Nodes with no inputs output an empty scene when disabled, and SceneProcessors output the first input unchanged. The enabled/disabled state can be toggled using the node right click menu or the "d" hotkey in the Graph Editor.