1. Load the CGFX Plug-In
This illustration shows how and where to set the CGFX Plug-in for Maya 2011.
- Make sure to select “Auto load” from the “Plug-In Manager.” This ensures that the CGFX plug-in will load even if Maya restarts (save your preferences before a crash, or close Maya normally, to remember this setting)
- Window → Settings/Preferences → Plug-In Manager
2. Create a CGFX Shader
Through the Hypershade window you create new CGFXShader materials. Now that the plug-in is loaded you will see a button to create CGFX in the Hypershade
3. Assign the shader program to the Maya CGFX Shader
When viewing the selected shader in the Attribute Editor
- click the yellow manilla envelope icon
- Select your desired *.CGFX shader file from the Open menu and accept
- The *.cgfx file is now loaded into the CGFXShader material in Maya
4. Assign the Material to an Object
- Select the object to which the new shader belongs.
- RMB+Hold on the object: do not let go of RMB+Hold until all steps below are complete
- Navigate to Assign Existing Material
- Drag mouse over desired material
- Let go of RMB+Hold over the desired material
5. Assign the appropriate UV sets and Color sets to the shader
This step is important because this section describes how to assign UV sets and Color sets to assigned CGFX shaders. If the wrong UV or Color sets are assigned you will see unexpected results or a solid color over the whole object
- In the Attribute editor for the desired shader
- RMB+Hold over the Color attribute in the Vertex Data section and select the appropriate Color Set (provided this object has a color set assigned)
- ::NOTE:: Not all CGFX shaders use color sets so this attribute may be missing in some shaders
- This is the same process for assigning UV sets
6. Assign desired textures & 7. Modify Attributes
Using the CGFX shader now is just like using a Maya material. Each shader has a different use and set of functions, just like the various Maya materials. Both shaders and materials have different render times based on shader complexity
When Passing Data Using Structs in your Shaders
This is an example of CGFX shaders that use structs to pass data between the internal vertex and fragment programs. The benefit of using structs in your shaders is attribute types are only listed once. In this example, as contrasted from the one below, you’ll notice that “UV” is mentioned only once
When Passing Data Using Individual, Local Semantics in your Shaders
Duplicate UV and Color set Names
What you see below is one of the most common errors with CGFX shader use in Maya. The below illustration shows what happens during the following conditions
- When a CGFX Shader is assigned and is looking for a UV set name that is not located on an object, even when the shader is assigned to the object
- When two objects are assigned to the one shader but have different UV Sets names
Troubleshooting CGFX Shaders
Q: My Textures Aren’t Showing Up!
- This is most often caused by the CGFX shader looking for a UV set name that is not found on the affected mesh.
- CGFX shaders are only viewable in Hardware Texture mode.
Q: My objects are Pink!
- Make sure you have a valid .cgfx file and path loaded into the material attribute editor.
- Make sure the CGFX plug-in is loaded.
- Make sure your project folder is set to the right directory, otherwise a newly opened file may look like it doesn’t have shaders attached. File > Set Project…
Q: My Objects are Green!
- Make sure you’re viewing in Hardware Texture Mode.
Q: Transparent objects have weird, blocky artifacts!
- This shows up on some Fermi level cards. Update your nVidia driver to the most recent version.