Game Development Reference
In-Depth Information
This effect is achieved by using the previously mentioned normals. With a flat shad-
ing model, the face is colored based on the direction of the light and the normal of
the first vertex on the face, and it assumes that the normal value for the rest is the
same. Hence, the mathematics used to calculate the diffuse lighting color of each
pixel on the face will result in the exact same color. Smooth shading, on the other
hand, calculates a separate result for each vertex independently, and then blends
the computed color for each pixel between them. It is a very primitive lighting effect,
but gives our objects a more believable appearance.
The glDepthFunc function sets the depth testing function the renderer will use,
which could be one of the following options:
These options specify whether the pixel should be overwritten with new information
in one of four ways: always, never, if the z-value is greater than the current value
(further away), or less than the current value (closer). The most common approach is
to choose GL_LESS , but never let it to be said that OpenGL didn't give us the power
to create whatever weird and wacky graphical effects we want, since choosing the
Search WWH ::

Custom Search