Basic SDF implementation for skinned cloth - Printable Version +- Obi Official Forum (https://obi.virtualmethodstudio.com/forum) +-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html) +--- Forum: Obi Cloth (https://obi.virtualmethodstudio.com/forum/forum-2.html) +--- Thread: Basic SDF implementation for skinned cloth (/thread-4405.html) |
Basic SDF implementation for skinned cloth - AdamZ101 - 11-11-2024 Hey, so I have a simple character rigged along with a shirt that's also rigged. Each are separate, and both have an animator component with the same animator controller, using the character's avatar for both the character and shirt. When I play the scene the looping walk cycle plays on both skinned meshes correctly. Great. Both of those are added to a parent game object called NPC. On the NPC game object I have the Obi Solver. on the Skinned Mesh Renderer for the shirt I have Obi SkinnedCloth and Obi Skinned Cloth Renderer. When I play the scene the cloth behaves as expected, with clipping of course since I haven't played around with the settings. I've installed the Unity Git Hub link for SDF: https://github.com/Unity-Technologies/com.unity.demoteam.mesh-to-sdf I created a Game Object called SDF Texture, and assigned the SDF Texture script. I duplicated the SDFTexture-SkinnedMesh texture from the Git Hub example scene, and assigned that to the SDF Texture game object. Next, on my characters Skinned Mesh Renderer, I added a Mesh to SDF script, and assigned that duplicated texture. After all of that I'm at a loss as to what the next steps would be. Is there a video on how to do this? If not, could you advise me on what I need to do next please? Thanks! RE: Basic SDF implementation for skinned cloth - josemendez - 11-11-2024 (11-11-2024, 04:52 PM)AdamZ101 Wrote: I've installed the Unity Git Hub link for SDF: Hi, You're using Unity's GPU SDF textures. These are 3D textures and designed to be sampled from shaders, VFX graph and the like. When using Obi, you should be using Obi's own SDFs. See the manual: http://obi.virtualmethodstudio.com/manual/7.0/distancefields.html kind regards, RE: Basic SDF implementation for skinned cloth - AdamZ101 - 11-11-2024 (11-11-2024, 06:07 PM)josemendez Wrote: Hi,That makes it easier. Where do I plug in the distance field into my skinned cloth? I tried using the Obi Collider script and added my SDF, but I'd like the SDF to update in realtime based on the animation. RE: Basic SDF implementation for skinned cloth - josemendez - 12-11-2024 (11-11-2024, 10:17 PM)AdamZ101 Wrote: That makes it easier. Where do I plug in the distance field into my skinned cloth? I tried using the Obi Collider script and added my SDF, but I'd like the SDF to update in realtime based on the animation. Adding the SDF to the ObiCollider component is the correct thing to do. Quote:but I'd like the SDF to update in realtime based on the animation. Updating an SDF is an extremely expensive operation. This is not what you'd typically do unless you're baking it in the GPU and the SDF is quite low-resolution. For instance, Unity's MeshToSDF is fast enough for realtime use with resolutions of 32^3 to 128^3, which are not nearly enough for accurate cloth collision detection against a human body (you'd need at least 512^3). VFX Graph's SDF baker also warns you about this: Quote:Note that baking an SDF is a resource-intensive operation. If you need to bake an SDF every frame, it is best practice to use a low resolution. Instead, use multiple convex (or nearly convex) SDFs and parent them to the character's bones, similarly to what you'd usually do for regular character hitboxes in most games. This requires no updates whatsoever so it's completely free in terms of performance and for most use cases results will be indistinguishable from updating a whole-body SDF. I wrote a quite detailed description of this approach's strengths and weaknesses in this thread. kind regards, RE: Basic SDF implementation for skinned cloth - AdamZ101 - 12-11-2024 (12-11-2024, 08:44 AM)josemendez Wrote: Adding the SDF to the ObiCollider component is the correct thing to do. Thanks for the help and suggestions! |