## AddPresetTextureLayer

### Introduced

v4.0

### Description

Adds a new texture layer on the input objects provided, connecting the specified shader to the layer. See AddTextureLayer for more details about layers.

### Scripting Syntax

    oReturn = AddPresetTextureLayer( PresetObj, [InputObjs], [Name], [After], [Reference] );

### Return Value

Returns the new TextureLayer object, if one was created.

### Parameters

Parameter | Type | Description
--- | --- | ---
PresetObj | String | One of the Shader Presets representing the shader to attach
InputObjs | String | List of containers (shaders or materials) to which to add the texture layer. Note that all containers must currently be contained in a single render tree. Default Value: Current selection.
Name | String | Name to use for the new layer. If an existing layer is being passed in, then this argument is ignored.
After | Boolean | True to insert the new texture layer after the reference layer. False to insert it before. If no reference layer, then True will add at the end of the container's list, False will add it at the start. Default Value: True
Reference | String or object | Reference texture layer, to indicate where the newly-added layer should be located in the stack. The layer will be inserted adjacent to (before or after) the reference layer. If not specified, then the new layer will be added at the beginning or the end, depending on the value of the "After" argument.

### Examples

#### VBScript Example

    ' Create a sphere, add a default material and texture projection

    NewScene , false

    set oSphere =  CreatePrim("Sphere", "MeshSurface")

    ApplyShader , , , , siLetLocalMaterialsOverlap

    CreateProjection oSphere, siTxtPlanarXY, siTxtDefaultSpherical, "Texture_Support", "Texture_Projection"

    ' Add a new layer with an image shader

    Dim oLayer

    set oLayer = AddPresetTextureLayer("Image", oSphere.material & ".Phong")

    logmessage "Created Layer " & oLayer

    ' Add the diffuse port to the layer

    AddTextureLayerPorts oLayer, oSphere.material & ".Phong.diffuse"

    ' Add a layer with a cell shader

    set oLayer = AddPresetTextureLayer("Cell", oSphere.material & ".Phong")

    logmessage "Created Layer " & oLayer

    ' Make the cell shader's effect more pronounced

    SetValue oLayer & ".weight", 1

    ' Add the ambient port to the layer

    AddTextureLayerPorts oLayer, oSphere.material & ".Phong.ambient"

    '-------------------------

    ' Output of script:

    '

    'INFO : "Created Layer Sources.DefaultLib.Material.Phong.Image_Layer"

    'INFO : "Created Layer Sources.DefaultLib.Material.Phong.Cell_Layer"

    '

    ' If you open the texture layer editor, you will find there are two layers, an Image layer

    ' affecting the diffuse component and a Cell shader affecting the ambient component.

    ' Rendering the sphere will give the sphere with an image, with a cell pattern on top.

    '-------------------------

### See Also

AddTextureLayer RemoveTextureLayers MoveTextureLayers AddTextureLayerPorts AddImageTextureLayer AddClipTextureLayer BlendInTextureLayers Shader.CreateTextureLayer Shader.AddSharedTextureLayer Material.CreateTextureLayer Material.AddSharedTextureLayer