Create and visualize a GLSL shader

To create and visualize a GLSL shader, you must run Viewport 2.0 in OpenGL Core Profile mode and load the glslShader plug-in. See Run Viewport 2.0 in Core Profile mode. After you follow those steps, a GLSL Shader appears in the Create tab in the Hypershade, in the Create Render Node window, and the Assign New Material window.

To create a custom GLSL shader

  1. Right-click your object and select Assign New Material.
  2. Select GLSL Shader from the Assign New Material window.
  3. In the GLSLShader Attribute Editor, navigate to your .ogsfx file.

    Example .ogsfx files can be found in the ..\presets\GLSL\examples folder of the Maya installation directory. The Developer Kit example brickShader (both C++ and Python versions) has also been updated to support GLSL and therefore to run in OpenGL Core Profile mode in the viewport.

    The Developer Kit is available from the Autodesk Developer Network.

    Note:
    • If you edit an effects file in an external text editor after you have already loaded it in your scene, you must reload the file by clicking the icon in order for the shader to recognize your latest changes.

    • When loading an .ogsfx file, if any of the parameters in your GLSL shader match in name and type with parameters in an .ogsfx file that you have previously loaded, then existing scene values are used for these parameters instead of default ones from the new file.

      For example, if you have two effect files, and effect1.ogsfx has a gAmbient parameter with a default value of green, and effect2.ogsfx has gAmbient parameter with default value of red, and you load first effect1, then effect2, the gAmbient parameter value remains green when effect2 is loaded. In addition, if you load effect1, then change the gAmbient color to blue, then load effect2, gAmbient remains blue, since the current value is preserved.

      This allows you to switch from a simple effect to a more complex effect without affecting the current scene values of ambient and other shared parameters.