Semantics and annotations supported by the dx11Shader and glslShader plug-ins in Viewport 2.0, Continued

Continues from Semantics and annotations supported by the dx11Shader and glslShader plug-ins in Viewport 2.0.

Hardware fog specific semantics

Note: Currently not supported for the glslShader plug-in.

NameTypeDescription
HardwareFogEnabledboolSpecifies whether hardware fog is enabled.
HardwareFogModeintSpecifies whether the fog type is Linear, Exponential or Exponential squared.
HardwareFogStartfloatSpecifies the near distance used in the linear fog.
HardwareFogEndfloatSpecifies the far distance used in the linear fog.
HardwareFogDensityfloatSpecifies the density of the exponential fog.
HardwareFogColorfloat4 (dx11Shader)

vec4 (glslShader)

Specifies the fog color in RGBA values.

Selection semantics

NameTypeDescription

HWS_PrimitiveBase

int

Integer used to generate the color of the object, or the first component, or the first geometry instance. (GPU Instancing must be enabled in the Viewport 2.0 options window.)

Corresponds to: MUniformParameter::kSemanticHWSPrimitiveBase.

HWS_PrimitiveCountPerInstance

intSpecifies the amount that HWS_PrimitiveBase needs to be incremented for each geometry instance.

Corresponds to: MUniformParameter::kSemanticHWSPrimitiveCountPerInstance.

HWS_ObjectLevel

boolSpecifies whether selection is to be done at the object level.

Corresponds to: MUniformParameter::kSemanticHWSObjectLevel.

HWS_FaceLevel

boolSpecifies whether selection is to be done at the face level.

Corresponds to: MUniformParameter::kSemanticHWSFaceLevel.

HWS_EdgeLevel

boolSpecifies whether selection is to be done at the edge level.

Corresponds to: MUniformParameter::kSemanticHWSEdgeLevel.

HWS_VertexLevel

boolSpecifies whether selection is to be done at the vertex level.

Corresponds to: MUniformParameter::kSemanticHWSVertexLevel.

HWS_FrontCCW

boolSpecifies whether a counter clockwise triangle is front facing. Useful when generating fat points or lines.

Corresponds to: MUniformParameter::kSemanticHWSFrontCCW.

HWS_InstancedDraw

boolSpecifies whether geometry instances are being drawn.

Corresponds to: MUniformParameter::kSemanticHWSInstancedDraw.

Supported technique annotations

NameTypeDescription
index_buffer_typestring

Allows specifying of custom primitive types via index buffer generator and mutator plug-ins. Usually used for tessellation, in order to provide the shader with an index buffer that contains extra data.

The dx11Shader/glslShader project contains a mutator that can generate Point-Normal Triangles using Adjacent Edge Normals (PN-AEN) index buffers. See Customizing Geometric Data for Shaders in the Maya Developer Help.

For dx11Shader / glslShader, use these values:

no-value : default index buffer (default)

"PNAEN9” / "GLSL_PNAEN9" : triangle and adjacent edges

“PNAEN18” / "GLSL_PNAEN18": triangle, adjacent edges, dominant edges, and dominant vertices

Any other value is acceptable as long as it matches the registered name of an index mutator.

Corresponds to MHWRender::MPxPrimitiveGenerator.

texture_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 technique definition to specify the mip map levels that should be generated when loading textures while using this technique. The following values are valid.

  • <val> = 0: generates all mip map levels for affected textures. If there are any existing mip maps in the textures, then they will be loaded. This allows, for example, the loading of pre-calculated mip maps for DDS textures.

  • <val> = 1-10 : only generates mipmaps up to the specified level.

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.

Note: For the glslShader and shaderFX plug-ins, the default value is set to 0.

It is also possible to enforce this on a per texture basis to explicitly reduce memory usage.

Sample implementation as follows:

technique11 T0
< 
    bool overridesDrawState = false;
    int isTransparent = 0;
    int texture_mipmaplevels = <val>;
>

Can be combined with the parameter annotation mipmaplevels, in which case the latter takes precedence. See Texture specific parameter annotations.

isTransparent

(dx11Shader)

intSpecifies 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 the float parameter that uses the "Opacity" semantic, and is transparent if the opacity value is lower than 1.0.

Transparency

(glslShader)

string

Specifies if this technique should be rendered in semi-transparency mode.

"Opaque" : no transparency (default)

"Transparent" : transparency is enabled.

Corresponds to MPxShaderOverride::isTransparent().

SupportsAdvancedTransparencystring (bool)

Specifies if this technique supports advanced transparency algorithms (such as depth peeling).

If true, the technique must define passes for draw context "transparentPeel", "transparentPeelAndAvg" and "transparentWeightedAvg".

"false" : no advanced transparency support (default value)

"true" : supports advanced transparency

Corresponds to: MPxShaderOverride::supportsAdvancedTransparency() .

OverridesDrawStatestring (bool)

Specifies if this technique should follow Maya's transparent object rendering or is self-managed (multi-passes).

"false" : does not override state (default value)

"true" : self-managed

Corresponds to: MPxShaderOverride::overridesDrawState().

OverridesNonMaterialItems

string (bool)

Specifies if this technique should be used to render non-material items such as the wireframe and the selected edges/vertices components.

This is particularly useful for shading effects that compute displacement for which the object geometry will not match the rendered material, making selection difficult.

"false" : does not override non-material items (default)

"true" : used to render non-material items, so that the shader can display UI primitives

See DrawContext in Supported pass annotations.

Corresponds to: MPxShaderOverride::overridesNonMaterialItems() .

ExtraScalefloat

Specifies if this technique requires an extra scale factor to be applied to the object space bounding box.

This allows the technique to indicate that the bounding box should be bigger than the base geometry; normally due to effects such as displacement, and to prevent the geometry from being discarded when moved to the edge of the viewport or during selection.

Default value is 1.0.

Corresponds to: MPxShaderOverride::boundingBoxExtraScale().

VariableNameAsAttributeNamestring (bool)

Tells Maya to use the uniform variable name as the Maya attribute name (instead of the UIName, when present).

"false" : use UIName as attribute name (default)

"true" : use variable name as attribute name

Can be used to maintain backward compatibility with a saved Maya scene, when the UI names defined in the shader file have been modified.

handlesConsolidatedGeometry

string (bool)

When set to False, specifies that the Consolidate World feature should be disabled on the geometry to which the glslShader is applied.

This annotation is useful when your technique draws displacement, the calculations of which involve the object-space co-ordinates of an object, such as use of the World transformation matrix. Consolidate World moves vertices of multiple objects into a new shared object-space, and maybe therefore cause your plug-in shader to render incorrectly. In this case, you may want to disable Consolidate World.

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.

NameTypeDescription
DrawContextstring

Specifies that this pass should be enabled only for this draw context.

Multiple passes can have the same DrawContext value.

This can be any string value that matches a pass semantic in MHWRender::MPassContext. For example, the following contexts are supported: "colorPass", "shadowPass", "depthPass", and "normalDepthPass".

An empty value (or if DrawContext is not set) is equivalent to setting this annotation to "colorPass".

Set to "nonMaterialItemsPass" for passes used to render non-material items. Set to “selectionPass” for passes used to select non-material items See OverridesNonMaterialItems in Supported technique annotations above.

PrimitiveFilter

string

Specifies that this pass can handle the rendering of the following components:

  • line as fat line (line size > 1)

  • point as fat point (point size > 1)

Can be used to handle edge or vertex components during the rendering pass or the selection pass.

Vertex components are rendered as quads instead of single pixels, and edge components, mostly during pre-selection highlighting, are rendered larger, for better visibility.

This is usually achieved by using a geometry shader to convert lines and points to quads.

"fatLine" : this pass can render lines as quads

"fatPoint" : this pass can render points as quads

If there is no pass defined that handles this special case, the default pass that handles the draw context "nonMaterialItemsPass" or "selectionPass" is used.

Global semantic

NameTypeDescription
MayaSwatchRenderbool

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

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