Game Development Reference
In-Depth Information
Figure 4.15 Object drawn with Gouraud shading (a), and an object drawn with
Phong shading (b).
One interesting thing to note is that regardless of the shading method used, the sil-
houette is identical. So even if Phong shading is used, the outline can be a dead
giveaway if an object is a low-polygon model.
Visibility
Once you have meshes, coordinate space matrices, lights, a reflection model, and
shading, there is one last important aspect to consider for 3D rendering. Which ob-
jects are and are not visible? This problem ends up being far more complex for 3D
games than it is for 2D games.
Painter's Algorithm, Revisited
As discussed in Chapter 2 , 2D Graphics ,” the painter's algorithm (drawing the
scene back to front) works fairly well for 2D games. That's because there's typic-
ally a clear ordering of which 2D sprites are in front of each other, and often the
2D engine may seamlessly support the concept of layers. But for 3D games, this
ordering is not nearly as static, because the camera can and will change its per-
spective of the scene.
This means that to use the painter's algorithm in a 3D scene, all the triangles in the
scene have to be resorted, potentially every frame, as the camera moves around
Search WWH ::




Custom Search