DirectX materials used by 3ds Max are described by shader effect files written in either High Level Shader Language (HLSL) or the NVIDIA Cg language. These are processes by a 3ds Max effect file parser. An effect parser implements the interface IEffectParser. The parameters of the effect file (i.e. the parameters of the hardware material) are extracted, and displayed to the user by 3ds Max. The effect manager provides access to the effect parameters and is exposed as an interface IEffectManager that is implemented in 3ds Max by the DirectX material.
An effect file can define what parser is required to fully support the syntax of the file. This is implemented in the effect file with the following:
string ParamID = "<parser_id>";
The following are the valid parser ids
A shader effect file contains variables. These variables can contain a user-defined hint, called a semantic, which helps applications provide the correct data to the shader without having to decipher the variable names. For example WORLDVIEW and PROJECTION are semantics:
// texture texture Tex0 < string name = "tiger.bmp"; string UIName = "BaseTexture"; string UIType = "bitmap"; >; // Transforms float4x3 WorldView : WORLDVIEW; float4x4 Projection : PROJECTION;
Additionally, each variable can have an optional annotation. The annotation is a structure that contains data that the effect author wants to communicate to a parser. In the following example the variables GlowColor, GlowAmbient, and GlowThickness all have annotation to describe the name and type for constructing the UI element. The GlowThickness has additional annotations which describe the minimum and maximum values to be selected in the interface:
float4 GlowColor < string UIName = "GlowColor"; string UIType = "MaxSwatch"; > = float4(0.5f, 0.2f, 0.2f, 1.0f); float4 GlowAmbient < string UIName = "GlowAmbient"; string UIType = "ColorSwatch"; > = float4(0.2f, 0.2f, 0.0f, 0.0f); float GlowThickness< string UIName = "GlowThickness"; string UIType = "FloatSpinner"; float UIMin = 0.0f; float UIMax = 10.0f; > = 0.015f;
3ds Max uses the annotations to create the UI elements. The effect file created by combining the above two snippets gives the following UI:
For more information on annotations see Supported Shader Annotations.