An adaptation of this article written for Visual Basic can be found at
Billboarding techniques are utilized in 3D applications to orient a polygon to always face the user. This allows the application of a 2D image, such as a lens flare or images of foliage, into a 3D scene. By applying an image in this way, the illusion of complex objects or effects can be applied with a minimum of overhead.
Viewing a Matrix as a Group of Vectors
To understand the method that we will use here, we need to take an alternate look at our 4x4 viewing matrix. Ignoring the fourth column, we can divide a matrix into four vectors:
With this knowledge in hand, we can calculate the location for each corner of a billboard so that it is perpendicular to the field of view, i.e. facing the viewer.
Extracting the Vectors
To begin with, we will need to retrieve the current viewing matrix and extract the Right and Up vectors from the matrix. The vectors will then be normalized, so that we can readily scale them to the desired size. The vectors will then be scaled to one half of the billboard size, so that they represent a distance from the center of the billboard:
Creating the Billboard
All that remains, once we have these vectors, is to create the vertices for the billboard. In this example, we will use a diamond shaped billboard, which can be rendered as a triangle strip:
That's it! This code will of course have to be repeated every time the view matrix changes, which normally means every frame. However, the math is pretty light, and the effects that can be added with just two alpha blended polygons is a considerable payoff.
Visitors Since 1/1/2000: