
Advertisement
Sign in to follow this
Followers
0
Particle quick question
By
NiGoea
, in Graphics and GPU Programming
This topic is 2845 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
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 vectormatrix mul.
What do you suggest ?
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 vectormatrix mul.
What do you suggest ?
thanks ;)
0
rubicondev 296
3) Neither.
Use a dynamic VB with worldspace coordinates in it, then do the rest of the math on the vertex shader.
Use a dynamic VB with worldspace coordinates in it, then do the rest of the math on the vertex shader.
0
KulSeran 3267
I'd agree with Rubicon, but I've never done shader particles.
so
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.
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 vectormatrix 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.
0
NiGoea 104
I'm currently doing this:
* for each particle:
 compute quad 4 vertexes. Each computation implies a matrixvec 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 matrixvec mul. This is the only think I don't like too much, but it is not so bad actually.
What do you think ?
* for each particle:
 compute quad 4 vertexes. Each computation implies a matrixvec 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 matrixvec mul. This is the only think I don't like too much, but it is not so bad actually.
What do you think ?
0
szecs 2990
I think you should read the last two posts.
Or aren't you in the shader thing yet?
Or aren't you in the shader thing yet?
0
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 ?
0
DensitY 192
Quote:
Original post by Rubicon
3) Neither.
Use a dynamic VB with worldspace 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
0
Sign in to follow this
Followers
0

Advertisement
True, but with geometry shaders you can get around that.
Share this post
Link to post
Share on other sites