ShaderDefinitions
 
 
 

Custom Shader Examples

These examples show how to create self-installing custom shader definitions using various implementation languages.


Color Sampler
These examples were ported from the SPDL-based Color Sampler Lightmap shader. They demonstrate how to create a custom lightmap output parameter, and how to create a property page widget that allows the user to specify a texture space id. This example is available in C++ and JScript.

Environment Blur
These examples were ported from the SPDL-based Environment Blur shader. It demonstrates how to create a property page widget that allows the user to select a shader. This example is available in C# and JScript.

Fast Volume Effects
These examples were ported from the SPDL-based Fast Volume Effects shader. It demonstrates how to define structure and array parameters and how to modify the property page layout. This example is available in VBScript and JScript.

Model Map
These examples were ported from the SPDL-based Model Map shader. It demonstrates how to create property page widgets that allow the user to specify a texture space id and a CAV. They also demonstrate how to define a drop-down list of values. This example is available in Python and JScript.

Example Files

Location
Files
JSShaderExample.js
PYSShaderExample.py
VBShaderExample.vbs
CSShaderExample.cs
CSShaderExample.csproj
CPPShaderExample.cpp
CPPShaderExample.vcproj
GNUmakefile

Running the Examples

To run the Color Sampler example

  • In the script editor, type the command and click Run:

    // [JScript]
    NewScene(null, false);
    CreatePrim("Cube", "MeshSurface");
    CreateShaderFromProgID("JSShaders.JSColorSampler.1.0", "Sources.Materials.DefaultLib.Scene_Material");
    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.JS_Color_Sampler.out",
    	"Sources.Materials.DefaultLib.Scene_Material.lightmap", false);
    
    // [C++]
    NewScene(null, false);
    CreatePrim("Cube", "MeshSurface");
    CreateShaderFromProgID("CPPShaders.CPPColorSampler.1.0", "Sources.Materials.DefaultLib.Scene_Material");
    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.CPP_Color_Sampler.out",
    	"Sources.Materials.DefaultLib.Scene_Material.lightmap", false);
    

To run the Environment Blur example

  • In the script editor, type the command and click Run:

    // [JScript]
    NewScene(null, false);
    CreatePrim("Cube", "MeshSurface");
    CreateShaderFromProgID("JSShaders.JSEnvBlur.1.0", "Sources.Materials.DefaultLib.Scene_Material");
    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.JS_Environment_Blur.out",
    	"Sources.Materials.DefaultLib.Scene_Material.photon", false);
    
    // [C#]
    NewScene(null, false);
    CreatePrim("Cube", "MeshSurface");
    CreateShaderFromProgID("CSShaderExample.CSEnvBlur.1.0", "Sources.Materials.DefaultLib.Scene_Material");
    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.CS_Environment_Blur.out",
    	"Sources.Materials.DefaultLib.Scene_Material.photon", false);
    

To run the Fast Volume Effects example

  • In the script editor, type the command and click Run:

    // [JScript]
    NewScene(null, false);
    CreatePrim("Cube", "MeshSurface");
    CreateShaderFromProgID("JSShaders.JSBionicVolume.1.0", "Sources.Materials.DefaultLib.Scene_Material");
    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.JS_Fast_Volume_Effects.out",
    	"Sources.Materials.DefaultLib.Scene_Material.volume", false);
    
    ' [VBScript]
    NewScene , false
    CreatePrim "Cube", "MeshSurface"
    CreateShaderFromProgID "VBShaders.VBBionicVolume.1.0", "Sources.Materials.DefaultLib.Scene_Material"
    SIConnectShaderToCnxPoint "Sources.Materials.DefaultLib.Scene_Material.VBS_Fast_Volume_Effects.out", _
    	"Sources.Materials.DefaultLib.Scene_Material.volume", false
    

To run the Model Map example

  • In the script editor, type the command and click Run:

    // [JScript]
    NewScene(null, false);
    CreatePrim("Cube", "MeshSurface");
    CreateShaderFromProgID("JSShaders.JSModelMap.1.0", "Sources.Materials.DefaultLib.Scene_Material");
    SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.JS_Model_Map.out",
    	"Sources.Materials.DefaultLib.Scene_Material.Phong.ambient", false);
    
    # [Python]
    app = Application
    app.NewScene("", False)
    app.CreatePrim("Cube", "MeshSurface")
    app.CreateShaderFromProgID("PYSShaders.PYSModelMap.1.0", "Sources.Materials.DefaultLib.Scene_Material")
    app.SIConnectShaderToCnxPoint("Sources.Materials.DefaultLib.Scene_Material.PYS_Model_Map.out",
    	"Sources.Materials.DefaultLib.Scene_Material.Phong.ambient", False)
    

Building the C++ Color Sampler Example

Follow the instructions below to build the examples.

To build the Color Sampler example on Windows

  1. Open a Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET from a Softimage command prompt ensures that environment variables such as XSISDK_ROOT are set (otherwise you'll get build and link errors).

    Tip To load the Simple Command project from the command line, type:

    devenv cppsrc_CPPColorSampler\CPPShaderExample.vcproj
  2. In Visual Studio .NET, open the project file .vcproj.
  3. Select a configuration (Win32/Win64 Release or Debug) and build the DLL.

To build the Color Sampler example on Linux

  1. In a shell (tcsh) window, type:

    source $XSI_HOME/.xsi_<xsi_version>
  2. Change directories to

    cppsrc_CPPColorSampler
  3. To remove all intermediate files before building the example, run this command:

    gmake clean
  4. To compile the example, run this command:

    gmake

Building the C# Environment Blur Example

Follow these instructions to build the C# plug-in.

Note: You can either use Visual Studio .NET 2005 or Visual C# 2005 Express Edition to build the example. Visual C# Express can be downloaded freely at http://msdn.microsoft.com/vstudio/express/visualcsharp/.

To build the example on Windows

  1. Open a Softimage command prompt, and type devenv to start Visual Studio .NET.

    Starting Visual Studio .NET or Visual C# Express from a Softimage command prompt ensures that environment variables such as XSI_USERHOME are set (otherwise you'll get build and link errors).

    Tip To load the CSShaderExample project from the command line, type:

    devenv cssrc_CSEnvBlur\CSShaderExample.csproj
  2. In Visual Studio .NET, open the project file .csproj.
  3. Select a configuration (Release or Debug) and build the DLL.

Keywords

This example uses the following keywords:

C++, JScript, Python, VBScript, C++ example, JScript example, Python example, VBScript example, C# example, RegisterShader, Define, DefineInfo, ShaderDef, Context, GetSource