(26-07-2017, 07:51 PM)baryy Wrote: Hi I'm really hoping someone can advise on this notion. I wish to drive the simple fluid sim with a kinect driven avatar. Could anyone knowledgeable point me in a direction which might work? I understand that the classic colliders will not interact but is it possible to incorporate the mesh normals to react with the particles and repel around the kinect silhouette or via any other router?
Hi baryy,
Regular (primitive) colliders like capsules attached to the limbs will work just fine, but of course they'll be much less precise. Mesh colliders cannot be deformed by a skeleton and are slower.
Using regular physics is just not going to work if you need accurate realtime collision detection with a deformable humanoid shape.
If I were in your situation (also based on the video/question you posted on the blog post) I'd take a completely different approach, using shaders. This will be both faster (like,
a lot faster) and probably also easier to get right.
- Each frame, render the silhouette of your mesh to a full-screen render texture. Whiite silhouette against a black background.
- Blur the silhouette (using separable linear gaussian blur, if possible). This essentially gives you a sort-of distance field of your humanoid.
- Now the fun part. Use a fullscreen grid-like mesh to create your particles (use a geometry shader to emit a quad per vertex) and read the previous blurred texture at each particles' location. The whiter your texture, the closer you are to the body silhouette. You can use a threshold to control how close your particles are allowed to get to the silhouette. To get a gradient direction (a "normal") to project the particles, just take the derivative of this black/white map.
The benefits of this approach: all done in the GPU, in parallel for each particle, and it is largely independent of the complexity of your character mesh. You could simulate hundreds of thousands of particles this way.
cheers,
Edit: Also based on your blog comment, fluid dynamics isn't really what you're looking for here. While the result you're after has a fluid-like quality to in, in fact your particles are completely independent of each other. They are simply pinned in world space to their original position via a spring. This is heaps faster to calculate than a fluid simulation.