Sign in to follow this  
NiGoea

Particle quick question

Recommended Posts

NiGoea    104
Hi ! To make a particle system, do you prefer using pointsprite or normal quads (sprite) ? What do you suggest (for an FPS engine) ? thanks !!

Share this post


Link to post
Share on other sites
B_old    689
Quads tend to be more flexible I would say. In case you are using D3D 10 (and upwards) pointsprites aren't really supported by the API, but you could use a geometry shader instead.

Share this post


Link to post
Share on other sites
NiGoea    104
Thanks you guys !

I was just thinking about the fact that with quads you have to send 4 vertexes for each quad, instead of just one needed by a pointsprite.

Quote:
Original post by KulSeran
I prefer normal quads. It gives you more flexibility, like stretching a spark particle, or tumbling a leaf particle.


What do you mean with "tumbling a leaf particle" ?

thanks ;)

Share this post


Link to post
Share on other sites
KulSeran    3267
A "smoke" particle might be a screen-facing billboard quad.
A "spark" particle would be a screen-facing billboard that is stretched along the velocity of the particle.
A explosion might have a world oriented shockwave that is parallel to the ground.
A leaf or confetti might rotate or tumble on one or more axis in world space ( for instance a coworker made the effect in this using a particle that tumbled on the single long axis of the confetti )

Share this post


Link to post
Share on other sites
B_old    689
Quote:
Original post by NiGoea
I was just thinking about the fact that with quads you have to send 4 vertexes for each quad, instead of just one needed by a pointsprite.

True, but with geometry shaders you can get around that.

Share this post


Link to post
Share on other sites
NiGoea    104
Thanks !

So let's use quads.
I was looking for a way to have quads always facing the camera.
I found two solutions:

1. Billboards. But this forces to have a DrawPrimitive for each single quad, that is for each particle, because the worldView matrix is different for each particle. It sounds slow to me.

2. Compute world space vertexes for each quad, rotated accordingly to the (inverse) camera matrix. In this way you can pack many particles in a single draw call. But the CPU has to perform lots of vector-matrix mul.

What do you suggest ?

thanks ;)

Share this post


Link to post
Share on other sites
KulSeran    3267
I'd agree with Rubicon, but I've never done shader particles.
so
Quote:

2. Compute world space vertexes for each quad, rotated accordingly to the (inverse) camera matrix. In this way you can pack many particles in a single draw call. But the CPU has to perform lots of vector-matrix mul.

for billboards, you only need to do vector addition.
Take the world center of the particle, and just add/subtract the camera's up and left vectors to generate your 4 corners.

You could likely do that in a shader too.

Share this post


Link to post
Share on other sites
NiGoea    104
I'm currently doing this:

* for each particle:
- compute quad 4 vertexes. Each computation implies a matrix-vec mul.
- store it in a system memory VB.

- at the end of the cicle, fill the device VB, which IS a dynamic vertex buffer.
[there is no need to compute the index buffer, because it's the same every time]
- DrawIndexedPrimitive

It seems fast enough, I can draw 5000 particles without significan FPS drop.

So, finally, for each particle I have four matrix-vec mul. This is the only think I don't like too much, but it is not so bad actually.

What do you think ?

Share this post


Link to post
Share on other sites
NiGoea    104
Quote:
Original post by szecs
I think you should read the last two posts.
Or aren't you in the shader thing yet?


what's wrong with my method ?

Share this post


Link to post
Share on other sites
DensitY    192
Quote:
Original post by Rubicon
3) Neither.

Use a dynamic VB with world-space coordinates in it, then do the rest of the math on the vertex shader.


Rubicon is bang on.

I did something similar to this with my particle system and its lightning fast as a result.

I posted my shader code here a while ago: http://www.gamedev.net/community/forums/topic.asp?topic_id=562581&whichpage=1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this