Posts: 4
Threads: 2
Joined: Jul 2024
Reputation:
0
06-08-2024, 04:06 AM
(This post was last modified: 06-08-2024, 08:46 AM by yunayuna64.)
Hello.
Using Obi Softbody I could make the Obi Fluid particle to collide with a skinned mesh deformed by its bone transform.
I wonder if there is a way to implement fluid collision with such a deformed mesh without using Softbody.
Please tell me if there is a method.
Thanks.
Posts: 6,347
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(06-08-2024, 04:06 AM)yunayuna64 Wrote: Hello.
Using Obi Softbody I could make the Obi Fluid particle to collide with a skinned mesh deformed by its bone transform.
I wonder if there is a way to implement fluid collision with such a deformed mesh without using Softbody.
Please tell me if there is a method.
Thanks.
Hi,
The traditional way to implement collisions in games against a skinned mesh is by parenting regular colliders (usually capsules and spheres) to its bones. This is less accurate than using a particle-based representation, but also cheaper.
kind regards,
Posts: 4
Threads: 2
Joined: Jul 2024
Reputation:
0
(06-08-2024, 10:59 AM)josemendez Wrote: Hi,
The traditional way to implement collisions in games against a skinned mesh is by parenting regular colliders (usually capsules and spheres) to its bones. This is less accurate than using a particle-based representation, but also cheaper.
kind regards,
In my application, the fluid must follow the shape of the surface exactly, so the your suggestion is not likely to work directly.
Anyway, thanks very much for your reply.
Kind regards.
Posts: 6,347
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(07-08-2024, 02:38 AM)yunayuna64 Wrote: In my application, the fluid must follow the shape of the surface exactly, so the your suggestion is not likely to work directly.
You could use distance fields instead of capsule colliders to better approximate the shape of the mesh. I've done this in the past with good results.
Note that if your fluid can't abandon the surface of the mesh, using an eulerian texture-space simulation (instead of a lagrangian, world-space one like Obi) would be a cheaper and more robust alternative.
kind regards,
Posts: 7
Threads: 1
Joined: Aug 2021
Reputation:
0
27-08-2024, 09:13 PM
(This post was last modified: 27-08-2024, 09:18 PM by sam3dx.)
(07-08-2024, 07:43 AM)josemendez Wrote: You could use distance fields instead of capsule colliders to better approximate the shape of the mesh. I've done this in the past with good results.
Note that if your fluid can't abandon the surface of the mesh, using an eulerian texture-space simulation (instead of a lagrangian, world-space one like Obi) would be a cheaper and more robust alternative.
kind regards,
Isn't distance fields have limitations on creating it on runtime from the skinned mesh including currently enabled blendshapes? Or even follow the skeletal animation?
What about this approach:
- create a proxy "obi cloth" from the skinned mesh (cloth that 100% driven by bones and 0% by free simulation)
- use that cloth to collide with fluid
Could it work? is it possible?
Posts: 6,347
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
28-08-2024, 07:57 AM
(This post was last modified: 28-08-2024, 08:01 AM by josemendez.)
(27-08-2024, 09:13 PM)sam3dx Wrote: Isn't distance fields have limitations on creating it on runtime from the skinned mesh including currently enabled blendshapes? Or even follow the skeletal animation?
Hi!
I wasn't talking about creating a distance field in the CPU at runtime for a skinned mesh, which is indeed extremely costly. The alternative I was talking about is approximating the geometry around each bone with a collider (in this case a SDF), then parenting it to the bone. This is the typical approach used in most modern games, except that capsules/spheres are used instead of SDFs since it requires a lot less storage.
This doesn't require to create or modify any collision geometry at runtime, and for most humanoid characters the results are indistinguishable from colliding against the actual deformed mesh since only areas influenced by multiple bones show any significant deviation from the SDFs' implicit surface. Would not work with extreme blendshapes though (things like changing body proportions).
(27-08-2024, 09:13 PM)sam3dx Wrote: What about this approach:
- create a proxy "obi cloth" from the skinned mesh (cloth that 100% driven by bones and 0% by free simulation)
- use that cloth to collide with fluid
Could it work? is it possible?
This would perform much worse and collisions would be a lot less robust, since you'd be approximating the mesh with a bunch of spheres - the cloth particles.
kind regards,
Posts: 7
Threads: 1
Joined: Aug 2021
Reputation:
0
(28-08-2024, 07:57 AM)josemendez Wrote: I wasn't talking about creating a distance field in the CPU at runtime for a skinned mesh, which is indeed extremely costly. The alternative I was talking about is approximating the geometry around each bone with a collider (in this case a SDF), then parenting it to the bone.
Oh, thanks for the detailed explanation!
Let me sum up the task then. Let's say I have a character which is a SkinnedMesh generated on runtime and it could be a very fat person or a really thin one because of the blendshapes used for customization. My task is to pour a glass of water (really small amount of liquid in compare to the skinned mesh size) on this skinnedmesh and I want to have as much precision on this mesh vs water interaction as possible. Is it somehow possible using the current OBI stack of tools at all? And if it's not - what would be the most approximately close result I can achieve?
Posts: 6,347
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
30-08-2024, 07:40 AM
(This post was last modified: 30-08-2024, 07:47 AM by josemendez.)
(30-08-2024, 02:22 AM)sam3dx Wrote: Let me sum up the task then. Let's say I have a character which is a SkinnedMesh generated on runtime and it could be a very fat person or a really thin one because of the blendshapes used for customization. My task is to pour a glass of water (really small amount of liquid in compare to the skinned mesh size) on this skinnedmesh and I want to have as much precision on this mesh vs water interaction as possible. Is it somehow possible using the current OBI stack of tools at all? And if it's not - what would be the most approximately close result I can achieve?
Hi,
It's possible, as just explained above: add a collider to each bone, that covers the mesh area affected by the bone. This is standard practice in games. Distance fields will do the best job of approximating the actual mesh geometry, out of all collider types.
To illustrate this using an actual example, see how the characters in Elden Ring are approximated using capsule colliders for physics interaction and hit detection purposes:
Of course, capsules are *a lot worse* than SDFs at approximating each bone's local geometry (specially if you use only one capsule per bone, you could do it the brute force way and get a very close approximation using many capsules/spheres per bone) but you get the idea. Depending on how you're generating the skinned mesh, how extreme your blend shapes are, and how often you're changing the body type, you may be able to have pre-generated distance fields that are simply scaled to follow the blend shape deformation, or may need to write a script that generates the colliders entirely at runtime after the final body shape has been decided.
kind regards,
Posts: 7
Threads: 1
Joined: Aug 2021
Reputation:
0
(30-08-2024, 07:40 AM)josemendez Wrote: you may be able to have pre-generated distance fields that are simply scaled to follow the blend shape deformation, or may need to write a script that generates the colliders entirely at runtime after the final body shape has been decided.
kind regards,
Thanks a lot for your input! I'm using the runtime colliders creation currently and I'm not happy with the level of precision they provide. Because I'm using a lot of blendshapes that changing the shape drastically and multiple combination of those belndshapes didn't allow me to pre-generate anything. By any chance, can OBI generate SDF on runtime? Or maybe I can I use some third party tools to generate distance fields that can be used by OBI?
Posts: 6,347
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
02-09-2024, 10:01 AM
(This post was last modified: 02-09-2024, 10:04 AM by josemendez.)
(30-08-2024, 11:34 PM)sam3dx Wrote: By any chance, can OBI generate SDF on runtime?
It can, but not in realtime. Building an adaptive SDF is a very expensive operation.
(30-08-2024, 11:34 PM)sam3dx Wrote: Or maybe I can I use some third party tools to generate distance fields that can be used by OBI?
Unity's MeshToSDF tool: https://github.com/Unity-Technologies/co...esh-to-sdf
It will generate a SDF from a mesh in realtime. Note that MeshToSDF's output is not very high-res (64^3), while Obi's SDFs can be very high-resolution (512^3, or even 1024^3), so the resolution might not be enough for your use case. Also keep in mind that the SDFs generated by this tool are regular 3D textures, which means they have a constant amount of detail and pretty high memory consumption, while Obi's SDFs are adaptive: they use an octree-like structure with nodes of different sizes, that yield finer resolution in areas where greater detail is needed.
You should be able to write a component that creates a Obi SDF where all leaf nodes for a given subdivision level exist, then copy each node's distance data from a regular 3D texture. This will make Obi able to use a SDF generated in realtime in the GPU.
kind regards,
|