Game Development Reference
In-Depth Information
when the color is combined with the luminance texture, it appears
shaded.
// File: toon.txt
// Desc: Vertex shader that lights geometry so it appears to be
//
drawn in a cartoon style.
//
// Globals
//
extern matrix WorldViewMatrix;
extern matrix WorldViewProjMatrix;
extern vector Color;
extern vector LightDirection;
static vector Black = {0.0f, 0.0f, 0.0f, 0.0f};
//
// Structures
//
struct VS_INPUT
{
vector position : POSITION;
vector normal
: NORMAL;
};
struct VS_OUTPUT
{
vector position : POSITION;
float2 uvCoords : TEXCOORD;
vector diffuse : COLOR;
};
//
// Main
//
VS_OUTPUT Main(VS_INPUT input)
{
// zero out each member in output
VS_OUTPUT output = (VS_OUTPUT)0;
// transform vertex position to homogenous clip space
output.position = mul(input.position, WorldViewProjMatrix);
//
// Transform lights and normals to view space. Set w
// components to zero since we're transforming vectors.
// Assume there are no scalings in the world
// matrix as well.
//
LightDirection.w = 0.0f;
Search WWH ::




Custom Search