Game Development Reference
In-Depth Information
shares that edge. The other face that shares the edge can be found
using the mesh's adjacency info.
17.5.4 The Silhouette Outlining Vertex Shader Code
We now present the vertex shader for rendering the silhouette edges.
The primary task of the shader is to determine if the vertex passed in
is on a silhouette edge. If it is, the vertex shader offsets the vertex by
some defined scalar in the direction of the vertex normal.
// File: outline.txt
// Desc: Vertex shader renders silhouette edges.
//
// Globals
//
extern matrix WorldViewMatrix;
extern matrix ProjMatrix;
static vector Black = {0.0f, 0.0f, 0.0f, 0.0f};
//
// Structures
//
struct VS_INPUT
{
vector position : POSITION;
vector normal : NORMAL0;
vector faceNormal1 : NORMAL1;
vector faceNormal2 : NORMAL2;
};
struct VS_OUTPUT
{
vector position : POSITION;
vector diffuse : COLOR;
};
//
// Main
//
VS_OUTPUT Main(VS_INPUT input)
{
// zero out each member in output
VS_OUTPUT output = (VS_OUTPUT)0;
// transform position to view space
input.position = mul(input.position, WorldViewMatrix);
// Compute a vector in the direction of the vertex
// from the eye. Recall the eye is at the origin
// in view space - eye is just camera position.
Search WWH ::




Custom Search