» News | » My 3d Dev | » Papers | » Downloads | » Contact
2004

Billboards explained

Introduction

Billbords are a fast, easy and simple way used to orient a polygon always facing the camera. This technic is the basic used for decals, light flares, lens flares, particles, aso. By a given center position, the size of the billboard and the view matrix we can calculate the position of the decal's edge points.

Get the Orientation

As we know, the orientation of a billboard is the reversed orientation of the viewer/camera direction. So we have to get the current view matrix, extract the right- and up- vector and normalize them to get unit vectors (length is one). here is same pseude code:

vRight = normalize( viewMatrix._11, viewMatrix._21, viewMatrix._31 );
vUp    = normalize( viewMatrix._12, viewMatrix._22, viewMatrix._32 );

I asume we are dealing with matrices like directx does. If not you have to use the transpose (MT) of the view matrix.
If you have problems to understand the code, lets take a look at the DirectX view matrix:

Size the Billboard

Knowing the orientation of the billboard, we also need the dimension of each direction. We
can resize the two extracted vectors to the half size of the billboard:
vRight = vRight * size / 2.0f;   // where size is the size of the billboard
vUp    = vUp * size / 2.0f;

Calculate the edge vertices

Now, as we know the Position of the billboard we can create the four edge vertices by two differend ways:


Render the billboard

The billboard can now simply rendered as a triangle fan and have to be realigned everytime the view matrix (camera) change.

Some hints

If you understand this simple code you won't have any problems to calculate texture coordinates. In the case you need a normal vector for the vertices, simple use the reversed direction vector from the view matrix.

On todays GPU's, billboarding is supported directly on hardware via Point-Sprites.