Softimage SDK Programmer's Guide > Customizing Softimage using the SDK > Custom Shaders >

# Creating Shader Language Parser Definitions

Custom shader language parsers allow you to provide instructions to Softimage on how to build shader definitions for a specific file format. Typically, this can be used to import established file formats, such as .cgfx, .mi, .sl, etc., but you can also use it to develop a custom lightweight file format that can batch-create shader definitions for any renderer.

In the XSILoadPlugin callback, the parser ClassName is registered using the PluginRegistrar.RegisterShaderLanguageParser or PluginRegistrar::RegisterShaderLanguageParser method. The parser ClassName together with the shader definition's ClassName, Major and Minor information (set up in the ParseInfo callback) define the ProgID, which uniquely identifies the shader definition in Softimage. See Instantiating Shader Definitions and the ProgID for details.

When the shader parser plug-in is loaded in Softimage, the QueryParserSettings callback tells Softimage which folder locations to look in by setting the Folders attribute, and what file extensions to look for by setting the FileTypes attribute. Based on these settings, Softimage will begin parsing each file in the specified location(s) that have the specified file extension(s).

Each time a file is parsed, the ParseInfo callback is fired. The ParseInfo callback is responsible for defining the ClassName, Major and Minor version numbers used to build the ProgID. It is also responsible for adding the name of the shader definition to the preset manager. You indicate how and where the new shader definition will appear in the preset manager by specifying the ShaderDef.DisplayName or ShaderDef::PutDisplayName and the ShaderDef.Category or ShaderDef::PutCategory using context attributes. For more information, see Populating the Preset Manager.

Finally, when the shader is instantiated, the Parse callback is fired. The Parse callback allows access to the ShaderDef or ShaderDef object (returned from the Definition context attribute), which allows you to:

- Assign shader families.

- Define the input and output parameters.

- Associate the renderers.

- Set up any custom attributes.

- Customize the associated shaderball.

Note

If you want to skip right to look at some code, check out the example.