Maya supports Cg version 3.0.015.
CgFX examples are shipped with Maya Creative. You can find these examples at:
You can pack multiple mesh inputs into a single varying parameter register. For example, you can pack two sets of UV coordinates into a single float4 register.
The following is a sample workflow:
struct appdata { float3 Position: POSITION; float4 UVs: TEXCOORD0; };
In this example, this auxiliary structure informs Maya that the original float4 parameter should be assembled on the fly from two float2 inputs: one named UV1, and one named UV2. This structure is not used by the shader itself - it simply tells Maya how to assemble the data for this input.
struct UVs { float2 UV1; float2 UV2; };
For more information, see UVPacking.cgfx as an example.
Where the data assigned to a structure element is too large for the Cg data type specified (for example, a position with (x, y, z) coordinates is passed into a float2 value), the first n values will be used to populate the value, and any subsequent elements will be ignored (for example, x and y will be passed in, and z will be ignored).
Maya supports parameters that vary by time. See MrWiggle.cgfx for an example of a shader that moves with time.
You can specify matrices in your CgFX shader. Maya supports all matrix semantics keywords.
Maya supports rendering of transparent CgFX shaders. Maya detects whether the blending state is enabled in the first pass. If blending is enabled, Maya uses the Object Transparency Sorting or Polygon Transparency Sorting options in the scene view to correctly render the transparent shader.
Maya provides shader files that developers can incorporate into their own CgFX shader, in the following directory:
where <install_dir> is the directory where you installed Maya Creative.
Select a Maya_*.cgh code example; for example, maya_blends.cgh, the code that Maya uses for blending of the layered texture:
You can use the MAYA_CGFX macro to customize your CgFX shaders to include Maya specific attribute annotations without breaking the compatibility with other applications that might also use the same CgFX shader.
For example, you can use the following code to declare the directional light attribute in both Maya and another application without causing any compatibility issues:
#if defined(MAYA_CGFX) || defined(XSI) // Declares the « dirlight0 » with attribute annotations for Maya or XSI float4 dirlight0 : Direction < string UIName = "Distant Light 0 Direction"; string Object = "DirectionalLight"; string Space = "World"; > = {-1.0f, -1.0f, 0.3f, 0.0f}; #else // Declares the « dirlight0 » with attribute annotations for another application: .... #endif
The lines between #if defined(MAYA_CGFX) || defined(XSI) and #else are only parsed when loaded by Maya/XSI.