Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Best method to render particles in gl?

This topic is 6312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I was just looking over some demo src for a simple particle engine in gl and was wondering if this is the most eff. method. Every time a particle is rendered, the code calls glPushMatrix(), then glPopMatrix() too restore the identity values. However, it would seem to me that you could simply reverse the calls, like this:
glRotate( .. pos vec ..);
glTranslate( .. pos vec .. );

// draw it here

glTranlaste ( .. neg vec .. );
glRotate ( .. neg vec .. );
Would this be faster or slower than the above method? or should I just test it and see... ? Thanks, Jason

Share this post

Link to post
Share on other sites
well, you''d have to send the data over the BUS again... with pushing and popping you don''t pass any parameters (popping) and i guess it''s pretty much optimised in the drivers so it shouldn''t be to slow :o)


Visit Rarebyte!
and no!, there are NO kangaroos in Austria (I got this questions a few times over in the states

Share this post

Link to post
Share on other sites
I found a much better method on http://nate.scuzzy.net/. Basically, you take the camera matrix, extract the "up" and "right" vectors from it, and then ue those to draw each particle, so say you have a particle at P, of size 2 * s. You draw it like this:

Vector a( P + (up * s) + (right * s) );
Vector b( P - (up * s) + (right * s) );
Vector c( P - (up * s) - (right * s) );
Vector d( P + (up * s) - (right * s) );

// now render the quad a,b,c,d with the normal modelview matrix and everything

You don''t need to change any matrices at all. It does require you to read the camera matrix, but you only do that once, and then you can render all 10,000 particles like that.

Technically, it''s not quite right, because all the particles will be on a plane, and not on a sphere around the camera, but I found that it''s really not noticable... unless you''ve got an unusually high field of view.

War Worlds - A 3D Real-Time Strategy game in development.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!