v1.0
shader
プリセットを元にシェーダを作成し、そのシェーダを指定のシェーダの接続ポイントに接続します。
oReturn = SIApplyShaderToCnxPoint( PresetObj, [InputObjs], [Name], [Value] ); |
シェーダをShaderオブジェクト(例:シェーダがシーンオブジェクトに接続する場合)またはCollectionItem(例:シェーダがパスに接続する場合)として戻します。
| パラメータ | タイプ | 詳細 |
|---|---|---|
| PresetObj | 文字列 またはプリセット オブジェクト(「SIGetPreset」を参照) | シェーダ プリセット |
| InputObjs | 文字列 | シェーダの接続ポイントのリスト。
デフォルト値: 現在選択されている値 |
| Name | 文字列 | シェーダ名
デフォルト値:指定しない場合は名前が自動的に生成されます。 |
| 値 | ブール | 前のシェーダとの接続を解除する場合は True、前のシェーダを保持する場合は False。
デフォルト値: 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"
|