Direct3D (DirectX 8.1) Code Samples - Page 5

Simple Vertex & Pixel Shader (Cg)
 

Demonstrates how to write both a simple vertex and pixel shader using Cg. The two shaders have matching connectors and can be used simultaneously on the same piece of geometry. The shaders in this sample don't really do anything useful or neat, it's meant to be used as a framework or starting place for experimenting with shaders. Check out the OpenGL source code page for the OpenGL equivalent of this sample.

 

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 OpenGL source code page for the OpenGL equivalent of this sample.

 

Anisotropic Lighting Shader (Cg)
 

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 OpenGL source code page for the OpenGL equivalent of this sample.

 

Vertex Displacement or Mesh Deformation Shader (Cg)
 

Demonstrates how to performs vertex displacement on a simple mesh to create a flag waving animation. Check out the OpenGL source code page for the OpenGL equivalent of this sample.

 

Shadow Volumes
 

This sample demonstrates how to create dynamic shadows with Direct3D using a shadow volume.