DirectX SDK |
When creating 3-D scenes, applications can sometimes gain performance advantages by rendering 2-D objects in a way that makes them appear to be 3-D objects. This is the basic idea behind the technique of billboarding.
A billboard in the normal sense of the word is a sign along a roadway. Direct3D applications can easily create and render this type of billboard by defining a rectangular solid and applying a texture to it. Billboarding in the more specialized sense of 3-D graphics is an extension of this. The goal is to make 2-D objects appear to be 3-D. The technique is to apply a texture containing the object's image to a rectangular primitive. The primitive is rotated so that it always faces the viewer. It doesn't matter if the object's image is not rectangular. Portions of the billboard can be made transparent, so the parts of the billboard image that you don't want seen are not visible.
Many games employ billboarding for their animated sprites. For instance, when the player is moving through a 3-D maze, he or she may see weapons or rewards that can be picked up. These are typically 2-D images textured onto a rectangular primitive. Billboarding is often used in games to render images of trees and bushes.
When an image is applied to a billboard, the rectangular primitive must first be rotated so that the resulting image faces the viewer. Your application must then translate it into position. The program can then apply a texture to the primitive.
Billboarding works best for symmetrical objects, especially objects that are symmetrical around the vertical axis. It also requires that the altitude of the viewpoint doesn't increase too much. If the user is allowed to view the billboarded from above, it will become readily apparent that the object is 2-D rather than 3-D.