If you are writing your own custom shader for use with the dx11Shader or glslShader plug-in in Viewport 2.0, the following are the supported semantics and annotations.
The dx11ShaderNode and GLSLShaderNode classes look for the following annotations on parameters and uniforms (GLSL) and forward relevant information to the MUniformParameter class at creation time:
Note: Although the OpenGL Shading Language (GLSL) does not support annotations, OGSFX does and they can be used for uniform, technique, and pass definitions.
Name | Type | Description |
UIOrder | int |
Allows reordering of parameters in the Attribute Editor, especially useful since the parameter order returned by the compiler does not always follow the order of declaration in the FX file. The parameter with the smallest UIOrder is laid out at the top of the AE, and the other parameters are added following increasing UIOrder. If not set, the parameter is placed in the same order as it appears in the shader file, but after the parameters with a specified UIOrder. |
UVEditorOrder | int | Allows reordering of textures in the UV Texture Editor. The texture parameter with the lowest UVEditorOrder appears first under the Textures menu. |
UIGroup | string |
All parameters with the same UIGroup attribute are laid out in a separate collapsible panel, the label of which is the UIGroup value. The panels are inserted at the position of the group parameter with the lowest UIOrder. If not set (or empty), the parameter is not placed in any named group. |
Object | string |
Group different shader parameters as part of the same Maya object. This is commonly used to define all parameters for a light. At the Attribute Editor parameter layout level, this acts exactly as a UIGroup annotation, except that the panel is collapsed by default. This is also used to determine the type of the light object when the object name contains "Light" (or "Lamp") and "Point", "Spot", "Ambient" or "Directional". A drop-down menu is created for each distinct Object, allowing easy connections to existing Maya scene lights. Example:
lightColor and lightPosition will be bound to the attributes of the same light node, which will likely be a Spot Light. |
UIName | string | Allows renaming of a parameter in the UI (Attribute Editor). By default, the variable name is shown. |
SasUiVisible UIType UIWidget |
bool string string |
Controls the visibility of the variable in the UI. For the two string annotations, a value of None hides the variable. Set UIType or UIWidget to ColorPicker to use the Color Chooser widget. |
SasUiMin UIMin uimin |
float/int (same as Parameter) |
Minimum range value. Corresponds to MUniformParameter::setRangeMin(). |
SasUiMax UIMax uimax |
float/int (same as Parameter) |
Maximum range value. Corresponds to MUniformParameter::setRangeMax(). |
UISoftMin uisoftmin |
float/int (same as Parameter) |
Minimum slider value for a range. Values smaller than UISoftMin (but larger than UIMin if specified) can be entered in the numeric input of the parameter. Corresponds to MUniformParameter::setSoftRangeMin(). |
UISoftMax uisoftmax |
float/int (same as Parameter) |
Maximum slider value for a range. Values greater than UISoftMax (but smaller than UIMax if specified) can be entered in the numeric input of the parameter. Corresponds to MUniformParameter::setSoftRangeMax(). |
UIFieldNames | string |
Creates a drop-down menu for the int parameter using the strings found in the attribute value. The format is the same as the MEL command attributeQuery -listEnum, which is a string of colon ":" delimited field names which can specify an index value separated by an equal sign "=". The indexing starts at zero, and the index value of an item, when it is not explicitly specified, is the index of the previous item (if any) incremented by one. Example: "Shaded:Wireframe=8:Bounding Box" defines 3 items with values 0, 8, and 9. |
ResourceName SasResourceAddress |
string |
Default texture file name. The plug-in automatically loads and connects the texture when setting the effect. The path can be absolute or relative. If a relative path is defined, the plug-in first tries to search for the file in the same folder hierarchy as the current ogsfx file. If the file is not found, then the plug-in searches for the file in the paths defined in MHWRender::MTextureManager::imagePaths(). |
TextureType ResourceType |
string |
If the variable is described as an under-specified texture instead of a texture[1D|2D|3D|Cube], then this annotation allows you to specify the texture type. Valid values are “1D”, “2D”, “3D”, and “Cube”. |
Space | string |
Allows specifying of the default space for position and direction semantics. Valid values are “Object”, “World”, “View”, and “Camera”. Any other value is ignored and the semantic remains undefined. "Object" corresponds to: semantic MUniformParameter::kSemanticObjectPos or MUniformParameter::kSemanticObjectDir "World" corresponds to: MUniformParameter::kSemanticWorldPos or MUniformParameter::kSemanticWorldDir "View" or "Camera" corresponds to: MUniformParameter::kSemanticViewPos or MUniformParameter::kSemanticViewDir |
Name | Type | Description |
mipmaplevels | int |
The dx11Shader allows for you to control the number of mip-map levels that should be loaded or generated, either at the technique or texture description level. Use this annotation with your texture description. The following values are valid.
To reduce texture memory, the default value for the dx11Shader plug-in is set to 1, so that only the first mip map level (<val>=1) is loaded / computed. It is also possible to enforce this on a per texture basis to explicitly reduce memory usage. Sample implementation as follows:
This value takes precedence over the value set for the technique annotation (texture_mipmaplevels). See Supported technique annotations. See AutodeskUberShader.fx in the presets\HLSL11\examples folder of your Maya installation for example use of this annotation. |
In addition to all the semantics currently supported by the MUniformParameter class, the dx11ShaderNode and GLSLShaderNode add extra light specific semantics to bind the properties of a scene light to shader parameters. When a light is driven by Maya, the values of all supported parameters are written using light information from the draw context. Unsupported parameters are left at the value found in the shader. This means that connecting a point light drives the position parameter, but not the direction.