OpenGL (1.2 - 2.0) Code Samples - Page 11

Lighting Shader (Cg)
 

Demonstrates how to write a vertex shader using Cg, which calculates simple diffuse lighting for a single light source. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

 

Anisotropic Lighting Shader
 

Demonstrates how to write a vertex shader using Cg, which calculates Anisotropic Lighting for a single light source. The shader uses a texture as a look-up table for the correct Anisotropic Lighting values by storing the pre-calculated diffuse values in the texture's RGB components and specular values in its alpha component. This style of lighting is very useful for rendering surfaces like brushed steel where the surface is composed of micro facets or microscopic scratches that tend to lay parallel or run in the same direction. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

 

Vertex Displacement or Mesh Deformation Shader
 

Demonstrates how to performs vertex displacement on a simple mesh to create a waving flag animation. The sample can be downloaded using either Cg or GLslang. Check out the DirectX9 source code page for the Direct3D equivalent of this sample.

 

Recreating OpenGL's Fixed Function Pipeline using Cg
 

This sample demonstrates how to make use of nVIDIA's "fixed_function.cg" file to recreate certain portions of OpenGL's fixed-function-pipeline. If you're not familiar with this file, then you've probably been recreating bits-and-pieces of OpenGL's T&L pipe the hard way and I suggest you check it out. The sample doesn't really do anything graphically thrilling, it simply makes the file's shader functions easily accessible for testing purposes. The original "fixed_function.cg" shader code came from nVIDIA's develper site.

 

Matrix Palette Skinning on the Hardware
 

This sample demonstrates how to skin a mesh on the hardware using using either a Cg or GLslang shader. To keep things simple, the skeletal system used in this sample only consists of two bones or bone matrices.