Game Development Reference
In-Depth Information
19.9 Sample Application: Cartoon Effect
The two effect file samples that we have shown so far did not use
shaders. Because shaders are typically an important part of special
effects, we want to show at least one example of them together. The
sample CartoonEffect implements the cartoon shader as discussed in
Chapter 17, but this time using the effects framework. Following is an
abridged version of the effect file:
//
// File: tooneffect.txt
//
// Desc: Cartoon shader in an effect file.
//
extern matrix WorldMatrix;
extern matrix ViewMatrix;
extern matrix ProjMatrix;
extern vector Color;
extern vector LightDirection;
static vector Black = {0.0f, 0.0f, 0.0f, 0.0f};
extern texture ShadeTex;
struct VS_INPUT
{
vector position : POSITION;
vector normal
: NORMAL;
};
struct VS_OUTPUT
{
vector position : POSITION;
float2 uvCoords : TEXCOORD;
vector diffuse : COLOR;
};
// Cartoon Shader Function:
VS_OUTPUT Main(VS_INPUT input)
{
...[Implementation omitted for brevity.]
}
sampler ShadeSampler = sampler_state
{
Texture = (ShadeTex);
MinFilter = POINT; // no filtering for cartoon shading
MagFilter = POINT;
MipFilter = NONE;
};
technique Toon
{
pass P0
{
// Set P0's vertex shader.
vertexShader = compile vs_1_1 Main();
Search WWH ::




Custom Search