Troubleshoot working with CgFX shaders

CgFX shaders appear different in Viewport 2.0 versus hardware renderer

There is a difference in behavior between the Default renderer, the Hardware renderer and the Viewport 2.0 renderer in terms of CgFX state assignments. The default value of the DepthMask state is different. The default is the value used when it is left unspecified by the CgFX shader and is as follows for the different renderers:

Therefore, a CgFX shader might appear to work correctly when using the Hardware renderer and yet give an incorrect result with the Default and Viewport 2.0 renderer. In this case, adding a DepthMask = false state assignment to some of the shader passes may workaround the issue.

CgFX plug-ins that depend on local vertex position does not behave as expected

When using Viewport 2.0, if you enable the Consolidate world option in the Viewport 2.0 options, CgFx plug-ins that depend on local vertex position may not behave as expected.

In the example below, the check3d.cgfx shader applies the 3D checkerboard pattern to the object relative to the position of the surface in the local space of the object, and therefore may produce unexpected results in Viewport 2.0. The same shader is applied to both spheres but the checkerboard pattern moves when you tumble the scene or select the spheres when Consolidate world is turned on.

You can enable or disable Consolidate world by selecting Renderer > Viewport 2.0 > to open the Hardware Renderer 2.0 Settings window; or, open the Render Settings window and click on the Maya Hardware 2.0 tab. For more information, see Viewport 2.0 options.