Jump to content

  • Log In with Google      Sign In   
  • Create Account

Can I use the graphics card's GPU to create particles?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Muzzy A   Members   -  Reputation: 688

Like
0Likes
Like

Posted 22 June 2012 - 12:31 AM

Im wanting to draw as many particles as i possibly can, so can i somehow create the on the graphics card and update them there instead of doing any calculations on the cpu?

My gut tells me you can, but i dont know for sure lol.

And if you can how in D3D9?

Sponsor:

#2 Ashaman73   Crossbones+   -  Reputation: 7991

Like
0Likes
Like

Posted 22 June 2012 - 12:54 AM

Im wanting to draw as many particles as i possibly can, so can i somehow create the on the graphics card and update them there instead of doing any calculations on the cpu?

My gut tells me you can, but i dont know for sure lol.

And if you can how in D3D9?

For sure you can, but it depends somewhat on your requirements. Basicly you can move them along a precalcualted path (i.e. linear or bezier), the next step would be, to save all vertex data in video memory and update them on the GPU alone. What will be really hard is, if you want to add kind of collision detection with the world.

But with the limitation of D3D9 I would sugguest to stick to a pre-calculated path, the preculculated path could be a simple linear interpolation between two points by a vertex shader, or a 4 point bezier spline interpolation.

#3 Waaayoff   Members   -  Reputation: 783

Like
0Likes
Like

Posted 22 June 2012 - 12:55 AM

If you're using Direct3D 9, you should probably stick to the CPU. You can also look into Point Sprites.

If you're using Direct3D 10/11, you can use geometry shaders to create the particles on the GPU.
"Spending your life waiting for the messiah to come save the world is like waiting around for the straight piece to come in Tetris...even if it comes, by that time you've accumulated a mountain of shit so high that you're fucked no matter what you do. "

#4 Muzzy A   Members   -  Reputation: 688

Like
0Likes
Like

Posted 22 June 2012 - 01:11 AM

If you're using Direct3D 9, you should probably stick to the CPU. You can also look into Point Sprites.

If you're using Direct3D 10/11, you can use geometry shaders to create the particles on the GPU.


I guess im going to have to start digging in directX 11 *sad face*

#5 molehill mountaineer   Members   -  Reputation: 595

Like
0Likes
Like

Posted 22 June 2012 - 04:10 AM

I guess im going to have to start digging in directX 11 *sad face*


these tutorials may benefit you,
this one in particular.

EDIT: I'm not sure he does it through the GPU but finding example code on geometry shaders shouldn't be too difficult

Edited by molehill mountaineer, 22 June 2012 - 04:12 AM.


#6 MJP   Moderators   -  Reputation: 11737

Like
0Likes
Like

Posted 22 June 2012 - 11:37 AM

You can simulate particles on the GPU with D3D9, as long as the GPU supports either vertex texture fetch or render-to-vertex-buffer (a custom ATI extension). You just render to a grid of pixels/vertices representing particles, and in the pixel shader you update the state of each particle. Then in a separate step you can render them as point sprites. With D3D11 you can of course do this much more elegantly and efficiently with compute shaders.

#7 mhagain   Crossbones+   -  Reputation: 8276

Like
0Likes
Like

Posted 22 June 2012 - 01:38 PM

You could put them all into a single static vertex buffer per emitter type, containing their initial properties (such as position - relative to 0|0|0, velocity, etc). One entry in this per particle. Create a second vertex buffer containing 4 sets of texture coordinates (one for each vertex of a quad). Set up a vertex declaration for this. Call your SetStreamSource and SetStreamSourceFreq appropriately. Send the emitter's position and time elapsed to your vertex shader as constants. Draw using instancing. Your vertex shader will add the emitter position to the particle position, then run the result through a standard gravity/velocity/time equation to get the position to draw at, and finally expand to a quad (you can get clever and use the texture coord buffer to help with this part). Write the result to your vertex shader output and the pixel shader runs as normal.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS