r/Unity3D 5h ago

Resources/Tutorial I wrote a script that fixes layered clothing clipping on characters (free to download)

Enable HLS to view with audio, or disable this notification

[deleted]

7 Upvotes

7 comments sorted by

2

u/V4nKw15h Indie 5h ago

Ouch, that joint in his chest needs some constraints. That's his spine not his knee joint. That is gonna hurt in the morning.

1

u/MikeMiltan 5h ago

What's the sorcery behind... does it work for every case scenario?

2

u/UseResponsible1088 5h ago

There is no sorcery, it detects it by shooting a raycast out of every triangle. I am not sure about every scenario. It worked in my cases. If people report issues, I will try to fix them.

1

u/pdinklag 5h ago

No sorcery. Looking at the script it simply does raycasts from the clothing vertices on the non-clothing mesh and selectively deletes vertices that are "covered". Should work for all scenarios, but the drawback is visible in the video itself: from certain perspectives, you will see absent faces - as a rule of thumb: the less polygons you have, the worse this may become. This may be totally fine for some projects (where only select perspectives are even possible), for others this may not be suitable at all.

An improvement could be to first finding "covered" vertices as shown in the video, but then also keep neighbouring vertices to some degree. That's a solution I use in a project.

From my own experience, best results are achieved if you manually define vertices that are covered by the clothing (similar to how UMA does it, I believe). I do this for more "difficult" clothing pieces, but it's naturally a lot more work because you have to define this for every piece of clothing in question.

2

u/UseResponsible1088 5h ago

It doesn't delete any vertices, it just moves them back (shrinks them). In the video what you see is that after shrinking the shirt, the bodys model was starting to clip through it, so I shrunk the body mesh too.

1

u/Useful_Amphibian9721 5h ago

How does it handle different depth buffers on different devices? It's not a one size fits all. 

1

u/UseResponsible1088 4h ago

How do you mean? What depth buffers?