|
Author Topic:   Billboards
ostra
Member
posted September 15, 1999 12:16 PM            
Hi!
Does anyone know how to do billboards (polys facing to the camera?).
by,
Marco

IP:

CheshireCat
Member
posted September 15, 1999 01:54 PM            
I'll assume you mean using OpenGL =]

The way I'm doing it is by setting both the Modelview and Projection matrices to the identity matrix, and using glOrtho to multiply the projection matrix by an orthographic one (glOrtho takes six paremters; the left, right, bottom, top,near, and far clipping edges, respectively). Then to draw your billboards, you just use the normal gl poly starts (GL_QUADS, GL_TRIANGLES), and use the glVertex2 calls for the vertices, which will automatically set the unused Z part to zero. You might also want to set the Z buffer test to "ALWAYS" so you don't end up with funny clipping problems.

Ugh, I feel incoherent today - maybe Seamus will explain it better =]

CheshireCat

IP:

LDA Seumas
unregistered
posted September 15, 1999 04:33 PM           
That works fine, if you don't need to use the Z test to clip the billboards to pre-drawn geometry (such as a landscape, or solid objects). It must be possible to work out the mapping between glOrtho Z and glFrustum Z so as to get the depth values to match properly, but I haven't bothered trying that yet (though I probably should, as assuming glOrtho is properly accelerated on most drivers, doing a single Z divide myself for each billboard would probably end up a win).

Right now I leave the Projection matrix as normal, and set the ModelView matrix to Identity, then manually transform the point for the center of the billboard from world space into camera space and send camera space coordinates (with Z) to OpenGL, letting it handle the Z divides. One reason for this is that I often have to inter-mix sending transparent billboards and transparent meshes, and resetting the projection matrix in between objects like that might not be too friendly to all drivers.

------------------
-- Seumas McNally, Lead Programmer, Longbow Digital Arts

IP:

CheshireCat
Member
posted September 15, 1999 05:26 PM            
Oops, I was assuming he meant things like huds, characters on the screen, or gui objects - things that have no place in the 3d environment. I forgot about sprites that are actually in the world =\ I suppose just leaving the projection as is and setting the Modelview to 1 is the best way of doing those.

IP:

LDA Seumas
unregistered
posted September 15, 1999 05:46 PM           
Ah yes, and for completely 2D objects such as the HUD, the GUI, and other text, I do use a glOrtho projection matrix, no Z-buffer, and simple qsort() based draw order sorting of the 2D objects.

------------------
-- Seumas McNally, Lead Programmer, Longbow Digital Arts

IP:

JaZzBrE
New Member
posted October 04, 1999 06:30 PM            
Well, I (in D3D) just compute the inverse of the view matrix once each frame and use it for all billboards. I make a quad (with either just XZ or XY filled and the other left zero) and transform it with this matrix. Works like a charm, becouse I just send it down the pipeline like a normal polygon then.
For axis aligned billboards you can use a variation of a LookAt function and for example a laser billboard just keep the heading the same (the directorion of the laser is going) and make the up vector facing the camera (ViewPosition-LaserPosition Normalized).

-Ales Mlakar

IP: