CreateShaderFromPr ogID

Introduced

7.0

Description

Adds a Shader to a render tree based on the specified Shader.ProgID.

Scripting Syntax

    CreateShaderFromProgID( ProgID, [Container], Name )

Parameters

Parameter | Type | Description
ProgID | String | Identify the shader to add by its Shader.ProgID. You can also create shader compounds if you supply a valid shader compound ProgID.
Container | Selection list | The shader compound or material to which we're adding the node. Default Value: If not specified, the user is prompted to select a shader container.
Name | String | Name for the new shader

Return Value

The new Shader object.

Examples

JScript Example

    /*
       This example demonstrates how to use the CreateShaderFromProgID command
    */
    NewScene(null, false);
    CreatePrim("Sphere", "MeshSurface", null, null);

    // Create an Image Shader using its ProgID and nest it under the material
    CreateShaderFromProgID( "Softimage.txt2d-image-explicit.1", "Sources.Materials.DefaultLib.Scene_Material", "Image");
    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.Image",
       "Sources.Materials.DefaultLib.Scene_Material.Phong.diffuse", false);
    CreateShaderCompound("Sources.Materials.DefaultLib.Scene_Material.Phong", null);

    // Create a Fractal Shader using its ProgID and nest it under the shader compound.
    CreateShaderFromProgID( "Softimage.txt3d-fractal_v3.1",
       "Sources.Materials.DefaultLib.Scene_Material.ShaderCompound", "Fractal");
    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.ShaderCompound.Fractal",
       "Sources.Materials.DefaultLib.Scene_Material.ShaderCompound.Phong.specular", false);

    // Application.LogMessage GetProgID on the shader compound before exporting it
    // You should get "XSIRTCOMPOUND" as the progid. It means the compound have not been exported
    // and the compound properties does not match the ones of an existing compound.
    var shaderCompound = GetValue("Sources.Materials.DefaultLib.Scene_Material.ShaderCompound");
    Application.LogMessage( shaderCompound.ProgID );

    //Export the shader compound
    var exportPath = XSIUtils.BuildPath( Application.InstallationPath(siUserPath), "Data",
       "RTCompounds", "XSIDOC_PhongSpecFractal.xsirtcompound" );
    SetShaderCompoundProperties("Sources.Materials.DefaultLib.Scene_Material.ShaderCompound",
       "XSIDOC_PhongSpecFractal", "", "Test for creation of compounds from progid", "XSIDOC",
       null, "", 1, null, 239);
    ExportShaderCompound("Sources.Materials.DefaultLib.Scene_Material.ShaderCompound",exportPath,
       , null, null);

    // Application.LogMessage GetProgID on the shader compound, you should get a valid ProgID.
    var shaderCompound = GetValue("Sources.Materials.DefaultLib.Scene_Material.ShaderCompound");
    Application.LogMessage( shaderCompound.ProgID );

    // Create a shader compound by ProgID and nest it under the material.
    CreateShaderFromProgID( "XSIRTCOMPOUND.XSIDOC_PhongSpecFractal.1.0",
       "Sources.Materials.DefaultLib.Scene_Material", "ReferencedShaderCompound");

See Also

CreateShaderFromPreset | CreateShaderFromCLSID | CreateShaderCompound | NestShaders
UnnestShaders | AddShaderCompoundPort | RemoveShaderCompoundPort | MoveShaderCompoundPort
RenameShaderCompoundPort | ExportShaderCompound | ImportShaderCompound | ExplodeShaderCompound
SetShaderCompoundProperties | GetShaderCompoundProperties |  |

Autodesk Softimage v7.5