Archived

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

Kerion

Textured quad particles - best way?

Recommended Posts

Kerion    122
The current particle system for my engine uses textured quads, as it is hardware accelerated on nearly everything, rather then the few cards that support point sprites. Currently, to display my particles, I am using the inverse view matrix to make them camera facing. Per particle, I change the translation section of the matrix to the position of the particle, then do the world space calculation myself (setting the render state transform of the world to identity, so no world transformation is done for me). Is there a faster way to do this? I do not want to make a draw call per particle, so I pre-calculate an index buffers and fill my dynamic vertex buffer with my vertex data, doing the world transform per vertex. This allows me to push all the vertex data for the all the particles for the given emitter off to the card with a single draw call, but it requires me to do the world translation myself (as obviously, I can''t set the world matrix to be that of one of the particles, they would all get drawn in the same place). Does anyone have a better approach to this that I am just missing? Thanks.

Share this post


Link to post
Share on other sites
StangDriver    122
Correct me if I''m wrong, but it sounds like your particles are all at 0,0,0 and you are using your transformation matrices to put them in world space.

Couldn''t you just do the world transform for the particle *system* and make all your particles x,y,z relative to that?

Share this post


Link to post
Share on other sites
Kerion    122
StangDriver,

Indeed, you are correct. All particles are at 0,0,0, I then translate them to their x,y,z, which is calculated relative to their emitter.

The way my system works is that every particle system can have multiple emitters, which spew particles (obviously).

Your question is a valid one. I suppose I could, but 3D math is not my strongest point. I know enough to get me by. What would the math involved in this be? Are you saying I should set the world matrix to that of my emitter, and draw all my particles relative to that? So the world matrix never really changes, except per emitter.

Thanks

(oh, and yes, I could do it with a vertex shader, and I do have a geForce 3. That comes later

[edited by - Kerion on May 1, 2002 3:07:36 PM]

Share this post


Link to post
Share on other sites
StangDriver    122
I''m not familiar with the part of making the quads face the camera, but from what you said above, you just have to use an inverse view matrix? If that is the case, just set that "magic" matrix, as well as your world matrix for the particle emmiter''s location, and give each particle its own XYZ instead of its own world matrix. The hardware will handle the rest.

Depending on how you make the quads face the screen, you still might have to do that in software per particle. I''m not sure because I just use point sprites.

The other way to handle it would be to do it in a vertex shader, but it wouldn''t get accelerated on anything lower than a geforce3.

Share this post


Link to post
Share on other sites
Bad Monkey    145
I actually treat my particles as entities in their own right once they have been released from the emitter (ie they have their position in WORLD SPACE). When they are created, they inherit the world position of the emitter, and I start their simulation from there.

This makes it piss easy to have them interact with the environment (ie collide with other objects etc), and there is no translation involved at all to draw them (just the inverse rotation from the view matrix).

A good grasp of 3D math and basic physics will stand you in good stead for the future

Share this post


Link to post
Share on other sites
russian-bear    122
Id say you should go for the poinsprites thing ... because its more logical and it works on many newer cards (it worked on my old ATI card :-) )..

About that bilboard thing i dont know how you do it but look in the book Special FX programming with DX on page 693. There is a verry neat billboarding calculation there !

Share this post


Link to post
Share on other sites