How can I hide poly behind clothes?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Nafis
:warning: Old Version Published before Godot 3 was released.

I have low poly 3D character with dress. But as it animates, some faces of body comes out through the dress. Is there a way I can hide the poly behind the dress mesh whenever the character is wearing a dress?

:bust_in_silhouette: Reply From: GlaDOSik

You’ve entered an exciting world of multilayered meshes. This topic is kinda complex but there are several solutions.

  1. Fix the animation of clothes in Blender (or Maya/Max/whatever). This involves a lot of fiddling with weight painting and it can take a lot of time. The idea is that you have the body mesh under the clothes but the animation is clean without clipping.

  2. Select in Blender every face which is under the clothes and put them to one vertex group. At the export time, select the group and delete the faces. It’s not the best solution because you can accidentally save file with deleted faces. And some faces still will be partially under clothes so some clipping can occure.

  3. Create a custom shader for clothes. Multiply a vertex in vertex shader by value between 0 and 1 (VERTEX = VERTEX * 0.05). Play with lower values first. This will push vertices closer to the camera which means less clipping. Or try the opposite. Multiply the vertex by value higher than one in shader for body.

  4. Simulate clothes in Blender and bake the simulation. It will be hard to get results you want but I think it should be possible. Godot right now doesn’t have cloth simulation but you could bake the animation elsewhere. This should prevent clipping too.

  5. Create the occlusion map and use it to hide body faces. I can’t provide you with concrete implementation because I didn’t try this solution yet so I will leave you with this blog post: http://zaumstudio.com/2016/06/20/new-tech-day-occluding-clothes/