v4.0
shader
1 つまたは複数のコンテナにテクスチャ レイヤを追加します(コンテナは、シェーダまたはマテリアルのいずれかです)。
コマンドは、さまざまなコンテナの間でサイクルが引き起こされるような方法でレイヤが追加されないようにしたり、別のレンダ
ツリーに含まれているコンテナにレイヤを追加しないようにしたりするためのエラー チェックを行います。
テクスチャ レイヤは、シェーダやマテリアルの上に、レイヤとしてシェーダ
エフェクトを配置するための簡便な方法を提供するオブジェクトです。 各レイヤにはその特性 (色、ミキシング
モード、スケール係数など)について記述したプロパティのセットがあり、これによってそのレイヤが処理するシェーダ
ポートにどのように影響を与えるかが指定されます。 コンテナの下にレイヤが表示される順序はレイヤ化が適用された順序であり、「N
色をミックス」したシェーダ ノードが動作する場合と似ています。 テクスチャ レイヤ ポートのオブジェクト(AddTextureLayerPorts
コマンドを参照)はレイヤに所有され、そのレイヤが影響を与えるシェーダ ポートを指定するために使用されます。
oReturn = AddTextureLayer( [Object], [InputObjs], [Name], [After], [Reference] ); |
作成された場合は、新しい TextureLayer オブジェクトを戻します。
| パラメータ | タイプ | 詳細 |
|---|---|---|
| オブジェクト | 文字列またはオブジェクト | コンテナに追加するテクスチャ レイヤ。 指定しない場合には、新しいレイヤが作成されて追加されます。 |
| InputObjs | 文字列 | テクスチャ レイヤの追加先のコンテナ(シェーダまたはマテリアル)のリスト。 すべてのコンテナが単一のレンダ ツリーに含まれている必要があります。
デフォルト値: 現在選択されている値 |
| Name | 文字列 | 新しいレイヤに使用する名前。 既存のレイヤが渡された場合には、この引数は無視されます。 |
| After | ブール | True の場合は、新しいテクスチャ レイヤはリファレンス レイヤの後に挿入されます。 False の場合は、リファレンス
レイヤの前に挿入されます。 リファレンス レイヤがないときは、True の場合はコンテナのリストの最後に、False
の場合はリストの最初に追加されます。
デフォルト値: True |
| リファレンス | 文字列またはオブジェクト | 新しく追加されたレイヤが配置されるスタック内の位置を示す、リファレンス テクスチャ レイヤ。 レイヤはリファレンス レイヤの前後に挿入されます。 指定しない場合には、新しいレイヤは "After" 引数の値に応じて先頭または末尾に追加されます。 |
'
' This example creates two shaders in a simple render tree, and applies
' texture layers to them, illustrating inserting before/after, sharing layers
' between containers, and other fun things.
' In particular, it builds the following stacks of layers (in a slightly
' convoluted way, to show various features of the AddTextureLayer command)...
'
' Phong Fractal
' A A
' B D
' C E
' D
'
option explicit
dim oSph, oPhong, oFractal, oLyr(4)
' Build our shaders (a Phong and a Fractal), which will be the "texture
' layer containers" that will each be able to hold a stack of layers.
NewScene , False
set oSph = CreatePrim( "Sphere", "MeshSurface" )
set oPhong = SIApplyShader( "Phong", oSph )
set oFractal = BlendInPresetsInsp( "Fractal", , , True, siReplaceNoBlend, False, False, True )
' Now create and add all the layers, as indicated above.
' Add 'D' to (the end of) the first container.
set oLyr(3) = AddTextureLayer( , oPhong, "D", True )
' Add 'A' to both containers at the start.
set oLyr(0) = AddTextureLayer( , oPhong & "," & oFractal, "A", False )
' Insert 'B' after 'A'.
set oLyr(1) = AddTextureLayer( , oPhong, "B", True, oLyr(0) )
' Insert 'C' before 'D'.
set oLyr(2) = AddTextureLayer( , oPhong, "C", False, oLyr(3) )
' Add 'E' to the end of the second container.
set oLyr(4) = AddTextureLayer( , oFractal, "E", True )
' Add existing layer 'D' to the second container, before 'E'.
AddTextureLayer oLyr(3), oFractal, , False, oLyr(4)
PrintTextureLayersInContainer oPhong
PrintTextureLayersInContainer oFractal
sub PrintTextureLayersInContainer( in_cont )
dim oStack, oItem, oStr
oStr = "Texture Layers in Container: " & in_cont & vbCrLf
set oStack = EnumElements( in_cont & ".TextureLayers" )
for each oItem in oStack
oStr = oStr & " " & oItem.name & vbCrLf
next
logmessage oStr
end sub
'
' The output from the example should look something like this:
'
'INFO : "Texture Layers in Container: sphere.Material.Phong
' A
' B
' C
' D
'
'INFO : "Texture Layers in Container: sphere.Material.Phong.Fractal
' A
' D
' E
'
|