Drawing Objects with OpenGL Realtime Shaders

All realtime effects require at least one, and often multiple, drawing passes to render the final effect. The output of each pass is brought together using blending, alpha testing, stencil testing, and other such drawing operations.

In the render tree, these draw operations are implemented in different ways:

• If you are building OpenGL-based programmable Cg shaders, you need to first attach an OGL Draw shader to the material node of any object for which you want to create realtime shader effects. This node also handles blending, culling, depth testing, and other draw operations. This is discussed immediately below in Drawing with OGL Draw Nodes.

• If you are building effects with GLSL Program shaders, there is no need to connect an OGL Draw shader in the render tree to perform any of these draw functions. See Setting Up a Unified GLSL Program.

• The same is true for the CgFX shader which references a CgFX file that combines everything needed to render a shading effect in a single place. See Effects Shaders (.cgfx Files).

Drawing with OGL Draw Nodes

1. Select the object and open a render tree (press 7).

2. Connect an OGL13Draw shader to the realtime port of the object’s Material node.

 

3. The object now uses the OGL Draw shader to draw itself in any 3D views whose display mode is set to Realtime Shaders > OpenGL.

4. Open the OGL Draw shader’s property editor in which you can set its properties to control how the object is drawn.

 

You can set the following draw properties:

Enable Blending allows you to blend this draw pass with the background. You need to specify how you want the drawing pass to blend with the source and destination parameters. For more information about blending, see Blending with Realtime Shaders.

Culling indicates whether back facing or front facing triangles should be drawn or not.

Depth Testing and Depth Write control how the incoming depth is used against the existing depth in the frame buffer.

- Depth testing controls whether the GPU should test the incoming depth with the destination depth.

- Depth writing controls whether the GPU should update the depth in the test passes.

Reset OpenGL state allows any subsequent draw pass to start from a fresh OpenGL context.

Deactivating this option allows any subsequent OGL Draw nodes to use any OpenGL states (such as shading and texturing) that were previously set up.



Autodesk Softimage v.7.5