ShaderParamDef

Object Hierarchy | Related C++ Class: ShaderParamDef

Inheritance

SIObject

ShaderParamDef

Introduced

v9.0 (2011)

Description

This object represents a definition for a ShaderParameter. Shader parameter definitions are stored on the ShaderDef object in a special ShaderParamDefContainer object, which allows you to access existing parameter definitions or add new ones. To access the ShaderParamDefContainer object, call ShaderDef.InputParamDefs or ShaderDef.OutputParamDefs. From the ShaderParamDefContainer you can add new parameter definitions by calling ShaderParamDefContainer.AddParamDef or ShaderParamDefContainer.AddArrayParamDef with a set of ShaderParamDefOptions.

To access a specific shader parameter definition from an instantiated shader definition, use the ShaderParamDefContainer.GetParamDefByName method. To iterate over the entire list of input or output parameter definitions for an instantiated shader definition, use the ShaderParamDefContainer.Definitions property.

To access existing shader parameter definitions from a ShaderParameter instance, use the ShaderParameter.Definition property.

To add an array parameter (ShaderArrayParamDef), use the ShaderParamDefContainer.AddArrayParamDef method. For all other parameter types, use the ShaderParamDefContainer.AddParamDef method.

Note: This object is a generic interface. There are special accessors on the specializations of this object for the array and struct parameter types. See the ShaderArrayParamDef and ShaderStructParamDef reference pages for more details on these specializations.

Methods

IsClassOf operator IsEqualTo operator    
       

Properties

Application Attributes operator Capabilities operator Categories
DataType operator DefaultValue operator DisplayName operator FullName operator
HasDefaultValue operator Help IsArray operator IsInput operator
IsOutput operator IsStructure operator MainPort operator MaxValue operator
MinValue operator Name operator NestedObjects Origin
OriginPath Parent SuggestedMaxValue operator SuggestedMinValue operator
Texturable operator Type operator    
       

Examples

Python Example

# 
# This example demonstrates how to create a dynamic shader definition 
# with 2 output and 1 input parameters. It also connects the new
# shader definition in to a cube and displays it in the render tree
#
from win32com.client import constants as cns
app = Application
app.NewScene("", False)
oShaderDef = XSIFactory.CreateShaderDef(None, "MySimpleParamDemo", 1, 3)
oShaderDef.AddShaderFamily("mrTexture")
oShaderDef.DisplayName = "Demo"
oShaderDef.Category = "Demo Items"
app.LogMessage("Shader definition name: " + oShaderDef.Name)
# OUT PARAMETER 1
# Set up shader parameter definition options to use with new parameters
oShaderParamDefOptions = XSIFactory.CreateShaderParamDefOptions()
oShaderParamDefOptions.SetAnimatable(True)
oShaderParamDefOptions.SetTexturable(True)
oShaderParamDefOptions.SetInspectable(True)
oShaderParamDefOptions.SetShortName("Output")
# Add output parameter to definition
oOutputParams = oShaderDef.OutputParamDefs
oOutputParams.AddParamDef("result", cns.siColorParameterType, oShaderParamDefOptions)
oOutputParams.GetParamDefByName("result").DisplayName = "Colour Output"
app.LogMessage(oOutputParams.GetParamDefByName("result").DisplayName)
# OUT PARAMETER 2
# Change existing shader parameter definition options to use with new output parameter
oShaderParamDefOptions.SetShortName("Valid?")
# Add 2nd output parameter to definition
oOutputParams.AddParamDef("valid", cns.siBooleanParameterType, oShaderParamDefOptions)
# IN PARAMETER
# More changes to param def options
oShaderParamDefOptions.SetSoftLimit(-50, 50)
oShaderParamDefOptions.SetHardLimit(-10, 10)
oShaderParamDefOptions.SetDefaultValue(5)
oShaderParamDefOptions.SetShortName("Vexatious")
# Add input parameter (direct access)
oShaderDef.InputParamDefs.AddParamDef("vex", cns.siScalarParameterType, oShaderParamDefOptions)
# RESULTS
# Now print info to see what we have
for oShaderOutParamDef in oShaderDef.OutputParamDefs.Definitions :
	app.LogMessage("Input parameter name: " + oShaderOutParamDef.DisplayName)
	app.LogMessage("\tClassName: " + app.ClassName(oShaderOutParamDef))
	app.LogMessage("\tType: " + str(oShaderOutParamDef.DataType))
# Connect this shader in the RenderTree and pop up the RenderTree view to see it
cube = app.ActiveSceneRoot.AddGeometry("Cube", "MeshSurface")
app.CreateShaderFromProgID("None.MySimpleParamDemo.1.3", "Sources.Materials.DefaultLib.Scene_Material", "")
app.SIConnectShaderToCnxPoint( "Sources.Materials.DefaultLib.Scene_Material.Demo.result", 
	"Sources.Materials.DefaultLib.Scene_Material.Photon", False)
app.SelectObj(cube)
app.OpenView("Render Tree", False)
# INFO : Shader definition name: None.MySimpleParamDemo.1.3
# INFO : Input parameter name: Output
# INFO : 	ClassName: ShaderParamDef
# INFO : 	Type: 4
# INFO : Input parameter name: Valid?
# INFO : 	ClassName: ShaderParamDef
# INFO : 	Type: 1

See Also

ShaderParamDefContainer.AddParamDef ShaderParamDefContainer.AddArrayParamDef ShaderParameter.Definition ShaderParamDefContainer Shader Parameter Definitions Shader Definition examples installed with Softimage Shader Parser examples installed with Softimage