v1.0
shader
Creates a shader from a preset and connects it to the specified shader connection points.
oReturn = SIApplyShaderToCnxPoint( PresetObj, [InputObjs], [Name], [Value] ); |
Returns the shader as either a Shader object (eg., when the shader is connected to a scene object) or a CollectionItem (eg., when the shader is connected to a pass).
Parameter | Type | Description |
---|---|---|
PresetObj | String or a preset object (see SIGetPreset) | Shader Presets |
InputObjs | String | List of shader connection
points.
Default Value: Current selection |
Name | String | Name of the shader
Default Value: If not specified, the name is automatically generated. |
Value | Boolean | True to disconnect the previous shader, False to keep the
previous shader
Default Value: True |
' ' This example creates a sphere, applies a lambert shader to it, prints out ' the list of connection points to that shader, connects the rounded ' connection point to the toon shader and then prints the updated list. ' ' Create the sphere to which the shader will be connected set oSphere = CreatePrim( "Sphere", "NurbsSurface" ) ' Apply a lambert shader to instantiate the material set oShader = SIApplyShader( InstallationPath( siFactoryPath ) _ & "\Data\DSPresets\Shaders\Material\Lambert.Preset", _ oSphere, "Christopher" ) ' Convert the shader to a Shader object set oShader = oShader(0) ' Print lambert shader info printShaderInfo oShader ' For convenience, create a collection to hold the parameters ' to be disconnected (Surface and Shadow connection points). set oCnxPoints = CreateObject( "XSI.Collection" ) oCnxPoints.Add oSphere & ".material.Surface" oCnxPoints.Add oSphere & ".material.Shadow" ' Use that collection to disconnect the shader from the material set oToony = SIApplyShaderToCnxPoint( "Material\Toon_Paint_Rounded", oCnxPoints, "Loonies" ) ' Convert the shader to a Shader object set oToony = oToony(0) ' Print toon shader info printShaderInfo oToony ' This is a convenience routine that prints information about the shader sub printShaderInfo( in_shader ) ' From the shader object you can get the material it belongs to set oMaterial = in_shader.Owners(0) ' Use the material to return the parameters that are connected and ' print out their names for each p in oMaterial.Parameters if TypeName( p.Source ) <> "Nothing" then LogMessage p.ScriptName & " is connected to " & p.Source.Name end if next end sub ' Output of the above script: ' ...before adding the toon shader 'INFO : "surface is connected to Christopher" 'INFO : "shadow is connected to Christopher" 'INFO : "Photon is connected to Christopher" ' ' ...after adding the toon shader 'INFO : "surface is connected to Loonies" 'INFO : "shadow is connected to Loonies" 'INFO : "Photon is connected to Christopher" |