Archived

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

Rendering lots of particles...

This topic is 4961 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

Hello all! A while ago, I made a class called particle in my engine that allows me to make a particle, set its texture, and render it. Now that i have been working with many more particles and large scenes, i thought it would be a good idea to create a class that includes a lot of particles, so i can send them all to render at once, cutting my render time down conciderably. Unfortunatly, i cant just change my code around a little bit, because the way i render each particle is to chance a matrix so it is facing me, now that i want to render hundreds at once, this would not work, so i am seeking a different approach. I was wondering if anyone knew a good equasion to manually change the vertex locations of each corner of the particle so it faces the camera. if i have an array of verticies that includes locations for each particle, at render time could i just create 2 polygons for each particle and change the vertices manually by using some equation so that they are facing the camera? Any tips would be very helpful! Chris

Share this post


Link to post
Share on other sites
i dont know if direct x has a built in function for doing something like this. Im thinking of doing it completely mathmatically, but that may slow down the speed a lot if im doing this to 1000s of particles. How do other games do this kind of thing, and what would be some good techniques that would make this kind of thing easier?

Share this post


Link to post
Share on other sites
I usually just apply a billboard matrix to the entire particle effect if they''re not really spread out, it''s so much faster. If however, they''re going to be on different sides of the screen because of high velocity, then just use sin/cos to rotate the actual 4 vertices against the angle of the camera''s view matrix each frame. Don''t forget how you plot the coordinates to begin with, since an angle of zero (in default left hand cartesian) is looking down the positive z axis, straight ahead.

With dynamic vertex buffers, it''s a good idea to lock for 500 particles at a time max, update, render, and then do another 500 or however many depends on how much data is going to be sent, not doing all at once.. that could stall the program and wouldn''t be very efficient either.

Share this post


Link to post
Share on other sites
Are you working with D3D ?
If thats the case, D3D has point sprite primitives. It''s one
of simplest methods to render particles, altough it''s not
supported by some very old cards ! It''s simple, efficient and
there''s no need to make the particle face the camera !

Check the sdk for point sprites.

Share this post


Link to post
Share on other sites
Some modern day cards also don''t support point sprites, so be careful. For instance, laptops sometimes have "Special Editions" of video cards and leave a lot of the good stuff off. A lot of people like to play games on laptops though. Just make sure you have multiple ways to perform the render. Use D3DXEffectFile for that.

Chris

Share this post


Link to post
Share on other sites