Trying to get changeable clothes to work

I am creating a survival game in unity and have struggled getting 3d clothing to move perfectly with the player model. With certain movements the player’s body can phase through the clothes.


As you can see near the player’s armpits, the body can phase through it. Also note that the player cannot use one set of clothes as this survival game will allow players to change them so that they can wear different types of armor.

Here are some websites I viewed to get some ideas:
https://blender.stackexchange.com/questions/1124/how-should-clothes-be-modified-to-fit-a-character-model

Edit:
I set the solidifier modification’s offset to -1 and now the cloths tend to flicker from visible to invisible while moving the camera in unity.

If you can get away with hiding parts of the skin (like the armpits), then do so.

You can also load mask textures onto your body to clip fragments/pixels in the shader, depending on the state of the clothing, so that your armpits are only invisible when wearing a hoodie, not when wearing a tank top.

Otherwise, the best technique I’ve found to eliminate body/clothing clipping, on a body with autoweights, is to use a vertex weight proximity to blend between data transfer weights (from body, for tight sections) and autoweights (for loose sections).

how do I do the body/clothing clipping part?

First, learn how to code shaders for Unity, using HLSL. Then, learn how to change the texture used by a particular shader in Unity. Finally, learn HLSL’s clip() instruction.

The clothes have to be 3d not just textures/shaders. The player will also have to be able to equip not just shirt and pants, but jackets, vests, backpacks and other things.

It doesn’t matter. You can still clip 3D pixels using clip(). In fact, 3D is the entire reason to use clip(): it doesn’t even write to the depth buffer, so you don’t have to worry about draw order.

Unless you have thousands of characters that need it, you can afford a few mask lookups; you can even pack 4 different mask lookups into a single texture lookup.

For unity3d, I think you can make some vertices invisible. You would need some way to tell unity which vertices to turn off. Then you can turn off the vertices under the cloths. Or you could delete those vertices. Maybe defining a vertice group, vertex group then saving the model. I don’t know if the file format keeps this information. I don’t know if unity3d and godot will read vertex groups either. I know they read them for bones. You might try making fake bones to tag those vertices for deletion everytime you put cloths on.

I am so close to the solution.


All I did was copy the body to the player model, then I cut out the parts of the duplicated body that I don’t need to create the shirt (by selecting the faces I want to form the shirt with then press “P”), then extruding all the faces of the shirt by 0.001. IT ALMOST WORKED!. The problem is it still has parts of the body clipping through the clothes. As you can see in the image above, part of the stomach still clips through the clothing.

I finally found out where I went wrong. It turns out my model was so low poly that of course there is going to poke through. I created a new player model and this time it actually works much better. I also edited the topology of the weight paints to be slightly smoother.

Unless the bones are bent to an extreme angle, there is no poke through so far. Above is a picture of the player model equipped with a shirt, jeans, boots, bullet resistant vest, and a helmet. Note that these clothing articles are separate meshes and overlap each other.