Semantics and annotations supported by the dx11Shader plug-in in Viewport 2.0

 
 
 

If you are writing your own custom shader for use with the dx11Shader plug-in in Viewport 2.0, the following are the supported semantics and annotations.

Supported parameter annotations

The dx11ShaderNode class looks for the following annotations on parameters and forwards relevant information to the MUniformParameter class at creation time:

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.
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.
Object string Allows defining of 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. A drop-down menu is created for each distinct Object allowing easy connections to existing Maya scene lights.
UIName string Allows renaming of a parameter for the UI. 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, and this is the only value currently recognized for the UIType annotation.

SasUiMin

UIMin

uimin

float/int

(same as Parameter)

Minimum range value.

SasUiMax

UIMax

uimax

float/int

(same as Parameter)

Maximum range value.

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.

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.

UIFieldNames int

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.

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”.

Light specific semantics

In addition to all the semantics currently supported by the MUniformParameter class, the dx11ShaderNode adds extra light specific annotations. 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.

Semantic Type Maya light parameter Description

LightColor, Color,

LightDiffuseColor, Diffuse,

LightAmbientColor, Ambient,

LightSpecularColor, Specular

float3 Color Values are not premultiplied by the light intensity.
LightIntensity float Intensity  
LightEnable bool Illuminate by default Follows the visibility of the light, including global light settings. When true, the Maya light is active and visible.
LightType int Type Allows writing of generic lighting code that can react correctly when connected to any light type. Valid values are:

2- Spot

3- Point

4- Directional

5- Ambient

6- Volume

7- Area

Position float3   Position for point, spot, area and volume lights. Reference space can be specified with an annotation.
Direction float3   Direction for directional and spot lights. Reference space can be specified with an annotation.
Hotspot float Cone Angle/ Penumbra Angle For spot lights, half angle, in radians. The Hotspot is computed as the minimum of ConeAngle and (ConeAngle+PenumbraAngle).

LightFalloff

Falloff

float Cone Angle/ Penumbra Angle For spot lights, half angle, in radians. The Falloff is computed as the maximum of ConeAngle and (ConeAngle+PenumbraAngle).
DecayRate float Decay Rate

For spot, point, area, and volume lights, expressed as an exponent. Maya provides the following values:

0.0 – No Decay

1.0 – Linear

2.0 – Quadratic

3.0 – Cubic

ShadowFlag bool Various When true, the light casts a shadow that the surface can receive. This value is true only when global Shadows are enabled, the light Use Depth Map Shadows is on, and the surface Receive Shadows is on.
ShadowColor float3 Shadow Color  
ShadowMap Texture2D   Contains the depth map shadow texture as computed by Maya.
ShadowMapBias float dmapBias  

ShadowMapMatrix

ShadowMapXForm

float4x4   View transformation matrix of the light

Supported technique annotations

Name Type Description
index_buffer_type string

Allows specifying of custom primitive types via index buffer generator and mutator plug-ins. The dx11Shader project contains a mutator that can generate Point-Normal Triangles using Adjacent Edge Normals (PN AEN) index buffers when the the following values are used: “PNAEN9”: triangle and adjacent edges, “PNAEN18”: triangle, adjacent edges, dominant edges, and dominant vertices.

texture_mipmaplevels

int

Specifies the mip map levels to generate/load the textures when using this technique.

A value of 0 means to load all possible levels.

isTransparent int Specifies the opacity of the effect, allowing Maya to use proper passes and culling. Supported values are:

0: Technique is always opaque

1: Technique is always transparent

2: Opacity of the technique is tied to a float parameter that has the "Opacity" semantics and is transparent if the opacity value is lower than 1.0.

Texture specific annotations

Name Type Description
mipmaplevels int

Specifies the mip map levels to generate/load a designed texture.

This value takes precedence over the value set for a technique.

Supported pass annotations

The effect can request that some of the passes in the technique be activated in a specialized context, such as when drawing depth maps for shadows. This is done by adding a string annotation named "drawContext" specifying the context in which the pass can be activated.

The following context are supported: "colorPass", "shadowPass", "depthPass", and "normalDepthPass".

Global semantic

Name Type Description
MayaSwatchRender bool

Identifies when the current rendering process is to draw the swatch.

Allows the user to handle a specific path when drawing the swatch.

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License