Billboarding

Started by
15 comments, last by ATronic 22 years, 4 months ago
How does that work? Do you calculate your particle positions in camera space or something? I''d love to learn a faster technique.
Advertisement
Oh wait. I see, you''re the one asking the question. Lemme know if you get it to work. What matrix are you grabbing in your glGetFloat call if not the matrix at each particle?
Try the function I posted, just to see what I''m saying. Do this.

  glPushMatrix();teBillboard();   for(int p=0; p<particleCount; p++)   {      particle[p].Draw();   }glPopMatrix();  


And it will work. The position of the particle is done by the following

glVertex3f(particle[p].x, particle[p].y, particle[p].z);
.
.
.

Make sense? So my particle system and billboarding technically work, it just has one thing that is bothering me. Try it though.

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"
I take it your glTranslate calls happen in your draw routine...

I think I understand... This will only work with Translations and Scales, I think (which was your initial problem). I guess you only need to billboard at the point of the last rotation... I''ll see what speed improvements I get, as my particles for the most part are only translated.
miles,

>I take it your glTranslate calls happen in your draw routine

I don''t know if I''m totally OT here, but you don''t call something like glTranslate *per particle*, do you ? If that''s the case: this is the most performance killing thing you can actually do. glTranslate or any other matrix manipulations have to be done per particle system. The particle positions themselves have to be passed by glVertex() or VA''s. See your psystem as a ''solid'' object, that is going to be translated, rotated, etc. Then, the individual particles are positioned with the appropriate coordinates through glVertex()

Imagine a 50k particle system, with a matrix call at every particle...
- AH
I call glTranslate per particle, then draw a textured quad. Is there some means to accomplish this using some other method? I know I can certainly draw each particle as a gl primitive (like a point or something) using vertex calls, but I don't see how to do this with geometry at each particle...

or is it actually faster to have the processor create a few thousand quads based on the particle positions?


Edited by - miles vignol on November 23, 2001 7:46:36 PM
> or is it actually faster to have the processor create a few thousand quads based on the particle positions

Ofcourse it is, thousand times faster. For my particle systems I do the following:

- there are always the same number of particles in the system, eg. if a particle is destroyed, a new one is instantaneously created.
- All particles have the same mesh topology (eg. quads)

I now initally create one or more vertex arrays with all vertex coordinates set to 0, but with a valid index array, that creates tri-strips of always 4 vertices (one particle). Texture coordinates are also generated that way.

Now for each frame I calculate the new particle positions (the particle physics), then a create camera facing quads using the CPU and repopulate the vertex-array, but NOT the index array, nor the texcoord array. This opeartion is rather fast, esp. if done in ASM.

I now transfer the VA to the 3d card (using nvidia''s AGP vertex_array_range transfers) and render it.
Note that the 3D card will *never* see the actual 3D particle positions that way, it will only see the 4 camera facing quad vertices. So no matrix modifications are necessary (or even possible) while the psystem is rendered.

IMO this is the fastest way to render a particle system, I can think of. Using this method you can easily render hundreds of thousands of particles with good framerates.

- AH

This topic is closed to new replies.

Advertisement