ShaderArrayParameter
 
 
 

ShaderArrayParameter

Object Hierarchy | Related C++ Class: ShaderArrayParameter

Inheritance

SIObject

Parameter

ShaderParameter

ShaderArrayParameter

Introduced

v9.0 (2011)

Description

Represents an array parameter for a Shader. An array parameter is a special kind of ShaderParameter which contains a set of ShaderParameter objects. These types of parameters are useful for supporting a dynamic number of instances of parameters. For example, the Volume Effects shader includes an array parameter of light references labeled 'scatter_lights_input' that allows you to add any number of lights.

You get this object when you iterate over the ParameterCollection property (via Shader.Parameters) when the collection item is a shader array parameter.

These type of parameters can be defined using the ShaderArrayParamDef interface.

Methods

Add operator AddCustomOp AddExpression AddFCurve
AddFCurve2 AddScriptedOp AddScriptedOpFromFile AnimatedParameters
Clear operator Connect ConnectFromFile ConnectFromFile2
ConnectFromPreset ConnectFromPreset2 ConnectFromProgID ConnectFromProgID2
Disconnect Enable operator GetInstanceValue GetValue2 operator
IsAnimated IsClassOf operator IsEqualTo operator IsLocked operator
IsSupportedInstanceValue Move operator PutValue2 operator Remove operator
SetCapabilityFlag operator SetInstanceValue SetLock Show operator
UnSetLock      
       

Properties

Animatable operator Application Capabilities operator Categories
Count operator DataType operator Default operator Definition operator
Definition2 operator Description operator FullName operator HasInstanceValue
Help Item operator Item2 operator Keyable operator
LockLevel operator LockType operator Marked Max operator
Min operator Model Name operator NestedObjects
Origin OriginPath OriginalValue operator OverridenObject
OverridingObject Parameters operator Parent Parent3DObject
ReadOnly operator ScriptName operator Source Sources
SuggestedMax operator SuggestedMin operator Tags operator Targets operator
Type operator Value operator ValueType operator  
       

Examples

1. Python Example

# 
# This example demonstrates how to work with a ShaderArrayParameter by instantiating
# a shader that implements a shader array parameter, adding 2 elements to that array, 
# setting some values on the new elements, and then finding them again by iterating 
# over the shader parameters.
#
from win32com.client import constants as si
app = Application
app.NewScene("", False)
# Set up a cylinder with a Volume Effects shader 
app.GetPrimLight("Light_Box.Preset", "Light_Box")
app.GetPrimLight("LightFlat.Preset")
app.CreatePrim("Cylinder", "MeshSurface")
sh = app.CreateShaderFromProgID("Softimage.March_Fractal_vol.1.0", "Sources.Materials.DefaultLib.Scene_Material")
app.SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.Volume_Effects.out", 
        "Sources.Materials.DefaultLib.Scene_Material.volume", False)
# Add 2 instances of the input array parameters and set some values on them
ap = sh.Parameters("scatter_lights_input");
app.SIAddArrayElement("Sources.Materials.DefaultLib.Scene_Material.Volume_Effects.scatter_lights_input")
app.SetReference2("Sources.Materials.DefaultLib.Scene_Material.Volume_Effects.scatter_lights_input.scatter_lights_input", "Light_Box")
app.SIAddArrayElement("Sources.Materials.DefaultLib.Scene_Material.Volume_Effects.scatter_lights_input")
app.SetReference2("Sources.Materials.DefaultLib.Scene_Material.Volume_Effects.scatter_lights_input.scatter_lights_input[1]", "light1")
# Now we can iterate over the list of items
for param in sh.Parameters :
        if (param.IsClassOf(si.siShaderParameterID)) :
                if (app.ClassName(param) == "ShaderArrayParameter") :
                        app.LogMessage("'" + param.ScriptName + "' is an array with " + str(param.Count) + " members")
# Expected output:
# INFO : 'scatter_lights_input' is an array with 2 members
# INFO : 'shadow_lights_input' is an array with 0 members
# INFO : 'trans_model' is an array with 0 members

2. JScript Example

/* 
        This example demonstrates how to work with a ShaderArrayParameter by instantiating
        a shader that implements a shader array parameter, and then manipulating the array
        using the Add and Remove methods.
        NB: This example manipulates the ParameterCollection directly instead of getting a
        pointer to it (eg., var pArrayParam = sh.Parameters("inputs")) because the proxy
        object (pointer) is not dynamic.
*/
app = Application;
NewScene(null, false);
// Set up a cylinder with a Volume Effects shader 
CreatePrim("Cylinder", "MeshSurface");
var sh = CreateShaderFromProgID("Softimage.March_Fractal_vol.1.0", "Sources.Materials.DefaultLib.Scene_Material");
SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.Volume_Effects.out", 
        "Sources.Materials.DefaultLib.Scene_Material.volume", false);
// Add 3 instances of the inputs array parameters
sh.Parameters("shadow_lights_input").Add();
sh.Parameters("shadow_lights_input").Add();
sh.Parameters("shadow_lights_input").Add();
app.LogMessage("Found " + sh.Parameters("shadow_lights_input").Parameters.Count 
        + " element(s) on the inputs array parameter");
// Remove one of the elements
sh.Parameters("shadow_lights_input").Remove(1);
app.LogMessage("Now there are " + sh.Parameters("shadow_lights_input").Parameters.Count + " element(s)");
// Expected output:
// INFO : Found 3 element(s) on the inputs array parameter
// INFO : Now there are 2 element(s)

See Also

ArrayParameter ShaderParameter