Game Development Reference
In-Depth Information
Note: Cartoon rendering is a particular kind of non-photorealistic
rendering, sometimes called stylistic rendering .
Although cartoon rendering isn't for all games, such as violent first-
person shooters, it can enhance the atmosphere of some types of
games when you want to impart a cartoonish feel. Furthermore, car-
toon rendering is pretty easy to implement and allows us to
demonstrate vertex shaders nicely.
We break cartoon rendering into two steps.
1. Cartoon drawings typically have few shading intensity levels with
an abrupt transition from one shade to the next; we refer to this as
cartoon shading . In Figure 17.2.a we see that the meshes are
shaded using exactly three shading intensities (bright, medium,
dark) and the transition between them is abrupt—unlike Figure
17.2.c, which has a smooth transition from light to dark.
2. Cartoon drawings also typically have their silhouette edges out-
lined, as Figure 17.2.b shows.
Both steps require their own vertex shader.
17.5.1 Cartoon Shading
To implement cartoon shading, we take the same approach as Lander
describes in his article “Shades of Disney: Opaquing a 3D World” fea-
tured in the March 2000 issue of Game Developer Magazine . It works
like this: We create a grayscale luminance texture that contains the dif-
ferent shade intensities we desire. Figure 17.3 shows the texture that
we use in the sample program.
Figure 17.3: Shade texture holds the shade intensi-
ties we use. Observe the abrupt transitions between
shades and that the texture shade intensity must
increase from left to right.
Then in the vertex shader we perform the standard diffuse calculation
dot product to determine the cosine of the angle between the vertex
normal
N and the light vector
L , which is used to determine how much
light the vertex receives:
s
LN
Search WWH ::




Custom Search