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?
Particle Collision
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.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?
The biggest killer would be if you tried to do something like test particles against each other.
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.
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.
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.