Particle Collision

Started by
13 comments, last by Krohm 10 years, 8 months ago

How would you go about determine if a particle collided with something? We finally got GPU particles working but for rain we want it to create a new particle on collision with the ground. How might one go about doing this?

Advertisement

How would you go about determine if a particle collided with something? We finally got GPU particles working but for rain we want it to create a new particle on collision with the ground. How might one go about doing this?

Kind of depends on the implementation and what you're trying to do. For instance with rain you could treat it different ways, if it simply is created and moves downward and you want it to create a "splash" effect on hitting the ground you could provide some sort of method to find the ground coordinates under the position of the rain particle and have it react when it reaches that point. If you wanted something more dynamic like smoke that brushes off of solid objects and funnels upward then you'd have to look into testing it against the world geometry. Particles are like any other object really, the only problem is they come in massive amounts so testing them again a wide variety of collisions is just asking for trouble.

The biggest killer would be if you tried to do something like test particles against each other.

Is this in 2D or 3D? How is your ground defined?

this is 3d and ground is defined by a dynamic world method.

[media]http:

[/media]

Can't find that presentation (I think it was Bungie, but not the Blowing S#!t Up one) where they used the depth buffer (world pos reconstruction, I think you got deferred rendering already) for collision detection and response, and put the particles to sleep when off-screen.

Maybe you can get away by faking it: Just emit (splashes?) near ground. Rain is pretty fast moving, so I wonder if one can tell the difference.

This one? I tried implementing that, but wasn't able to get it working since I can't actually debug our GPU particle system (the VS debugger crashes). But it only deals with on-screen collisions, which covers pretty much everything except rain/snow. I'm not too worried about having splashes, the bigger issue is preventing the rain from falling through the terrain.

Yep, that's the one I meant.

Ok, just throwing ideas around: How about a heightfield then. Meaning: From your terrain create a "stop layer" texture (one channel), one texel per cube encoding the highest layer. Then in the simulation destroy the rain when it falls below the height at the corresponding position. This height texture can then also be used to create the splash positions.

How would you create such a texture? Scanning all the blocks on the CPU would probably be rather slow. Rendering it out with the GPU might be quicker but I don't know how you'd map 1 block to 1 pixel.

E.g. rendering with an orthographic projection, birds eye view looking straight down, axis aligned, and scaled so that one block comes out as one pixel and outputting depth (== distance from near plane == height). Actually a depth buffer alone could suffice here (with D3D11 one can disable rasterization completely). Then use this depth buffer/depth map for collision detection.

I suppose I could try that out. It may end up being rather expensive though considering how many draw calls it would need to draw all the terrain.

This topic is closed to new replies.

Advertisement