Game Development Reference
In-Depth Information
in the scene. If there is a scene with 10,000 objects, this process of resorting the
scene by depth every single frame would be computationally expensive.
That already sounds very inefficient, but it can get much worse. Consider a split-
screen game where there are multiple views ofthe game world onthe same screen.
If player A and player B are facing each other, the back-to-front ordering is go-
ing to be different for each player. To solve this, we would either have to re-
sort the scene multiple times per frame or have two different sorted containers in
memory—neither of which are desirable solutions.
Another problem is that the painter's algorithm can result in a massive amount of
overdraw , which is writing to a particular pixel more than once per frame. If you
consider the space scene from Figure 2.3 in Chapter 2 , certain pixels may have
been drawn four times during the frame: once for the star field, once for the moon,
once for an asteroid, and once for the spaceship.
In modern 3D games, the process of calculating the final lighting and texturing for
a particular pixel is one of the most expensive parts of the rendering pipeline. If
a pixel gets overdrawn later, this means that any time spent drawing it was com-
pletely wasted. Due to the expense involved, most games try to eliminate as much
overdraw as possible. That's never going to happen with the painter's algorithm.
And, finally, there is the issue of overlapping triangles. Take a look at the three
triangles in Figure 4.16 . Which one is the furthest back?
Search WWH ::




Custom Search