Skip to content

Billboarding is great

by Adam on March 8th, 2005

I was bored the other day and decided to experiment with textures above and beyond the norm or even point sprites that I have used previously. I decided to see what could be done with The Gimp and some billboarded squares. Here is the result …

Figure 1. Text Balloon over 3D scene.

Put simply the triangle is what would be considered the 3D scene of the program/game. The text balloon is drawn on top of it using the billboarding technique. Billboarding just means drawing 3D squares aligned to the camera so that they look 2D on the final rasterization (frame, screen, image). The technique is used in games to produce the Heads Up Display (HUD) see Figure 2 and in modeling software for menus (like in Blender).

Figure 2. Screenshot from Sid Meier’s Pirates!

Figure 2 shows an example HUD, note the transparency. Ooooo! Ahhhhh! Surgeon General’s Warning: This game contains addictive properties, use caution and moderation when consuming.

One of the easiest ways to billboard is to use OpenGL transformation operations. You draw your scene as normal and then at the end run the commands in Listing 1. All this does is redefine your scene to be a 3D cube aligned to the camera (which is at the origin). All the 3D stuff from before this is already rasterized into the buffer so this doesn’t affect it. Now you draw squares using glVertex2f() and texture them with your HUD images. Simple.

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, width, 0.0, height, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
Listing 1. Billboarding code.

From → Uncategorized

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS