TextureLayers (Shader)

Introduced

4.0

Description

Returns a TextureLayerCollection containing each TextureLayer object owned by the shader.

C# Syntax

    // get accessor
    TextureLayerCollection rtn = Shader.TextureLayers;

Examples

1. JScript Example

    /*
       This JScript example demonstrates creating texture layers on
       a shader, plus enumerating and removing them.
    */

    oRoot = ActiveProject.ActiveScene.Root;
    oSph = oRoot.AddGeometry( "Sphere", "MeshSurface" );
    oMat = oSph.AddMaterial( "Phong" );
    oPhong = oMat.Shaders(0);

    // Add a layer at the end (since there are no others the "After"
    // flag is irrelevant).
    oLayers = new Array(3);
    oLayers[0] = oPhong.CreateTextureLayer( "B", true );

    // Add another layer before the other one.
    oLayers[1] = oPhong.CreateTextureLayer( "A", false, oLayers[0] );

    // Create a third layer at the very start.
    oLayers[2] = oPhong.CreateTextureLayer( "base", false );

    Application.LogMessage( "Created " + oPhong.TextureLayers.Count + " layers." );
    for ( i = 0; i < oPhong.TextureLayers.count; i++ )
    {
       oLayer = oPhong.TextureLayers(i);
       Application.LogMessage( (i+1) + ": " + oLayer );
    }

    oPhong.RemoveTextureLayer( oLayers[1] );
    oPhong.RemoveTextureLayer( oPhong.FullName + "." + oLayers[2].Name );

    count = oPhong.TextureLayers.Count;
    Application.LogMessage( "Only " + count + " remains after removal." );
    for ( i = 0; i < count; i++ )
    {
       Application.LogMessage( (i+1) + ": " + oPhong.TextureLayers.Item(i) );
    }

    // This example should log something like:
    //INFO : "Created 3 layers."
    //INFO : "1: sphere.Material.Phong.base"
    //INFO : "2: sphere.Material.Phong.A"
    //INFO : "3: sphere.Material.Phong.B"
    //INFO : "Only 1 remains after removal."
    //INFO : "1: sphere.Material.Phong.B"

2. VBScript Example

    '
    ' This VBScript example demonstrates creating texture layers on
    ' a shader, plus enumerating and removing them.
    '

    set oRoot = ActiveProject.ActiveScene.Root
    set oSph = oRoot.AddGeometry( "Sphere", "MeshSurface" )
    set oMat = oSph.AddMaterial( "Phong" )
    set oPhong = oMat.Shaders(0)

    ' Add a layer at the end (since there are no others the "After"
    ' flag is irrelevant).
    dim oLayers(2)
    set oLayers(0) = oPhong.CreateTextureLayer( "B", True )

    ' Add another layer before the other one.
    set oLayers(1) = oPhong.CreateTextureLayer( "A", False, oLayers(0) )

    ' Create a third layer at the very start.
    set oLayers(2) = oPhong.CreateTextureLayer( "base", False )

    LogMessage "Created " & oPhong.TextureLayers.Count & " layers."
    i = 1
    for each oLayer in oPhong.TextureLayers
       LogMessage i & ": " & oLayer
       i = i + 1
    next

    oPhong.RemoveTextureLayer oLayers(1)
    oPhong.RemoveTextureLayer oPhong.FullName & "." & oLayers(2).Name

    count = oPhong.TextureLayers.Count
    LogMessage "Only " & count & " remains after removal."
    for i = 0 to count - 1
       LogMessage i + 1 & ": " & oPhong.TextureLayers.Item(i)
    next

    ' This example should log something like:
    'INFO : "Created 3 layers."
    'INFO : "1: sphere.Material.Phong.base"
    'INFO : "2: sphere.Material.Phong.A"
    'INFO : "3: sphere.Material.Phong.B"
    'INFO : "Only 1 remains after removal."
    'INFO : "1: sphere.Material.Phong.B"

See Also

Material.TextureLayers | Material.CreateTextureLayer | Material.AddSharedTextureLayer | Shader.CreateTextureLayer
Shader.AddSharedTextureLayer |  |  |

Autodesk Softimage v7.5