- Home /
Use material with specific UV
Hi, I have a solid human mesh with two materials: HEAD and BODY. I'm adding a third material to its mesh renderer to draw some decals on body (tattoos, wounds), but it uses HEAD UV, thereby I see body tattoos on face. I tried offsets but with no avail. Only secondary map works, but I want many materials, for face and body separately.
How do I switch UV?
Answer by AndrewIanBurrow · Jan 10, 2019 at 11:22 AM
Hi GridManiac,
I have been puzzling over this for some time too. I was wanting to have a base texture mapped over a ground tile (grass for example) and then have a separate uv (created in Blender) to render another texture over the top (leaves, stones etc...). I wanted this so I could keep the base ground texture and change the "decal" overlay without having to create whole new textures.
Although Blender can export multiple uvs I found the standard shader in Unity didn't do what I wanted even though it can handle a secondary uv map, that is, I believe, designed to handle decals. Some examples can be found online of a wall texture with bullet holes using the secondary uv.
In the end I created multiple overlay textures and materials in Blender and then got Blender to combine them all into a single uv and texture atlas. Not ideal, and not simple, but the effect was what I wanted. This might not be what you are after though as I can image you will want to change the tattoos dynamically at run time, which would require a whole head and body texture.
I have reason to believe that you might be able to achieve what you want with a custom shader as well but I didn't look into that.
Answer by GridManiac · Jan 10, 2019 at 08:17 PM
@AndrewIanBurrow I think I found a suitable solution (at least for me). In my case I need to add decals at runtime, so the first alternative was to mix textures through Texture.SetPixels method, but performance was bad. Then I decided to try RenderTexture thing. I setup camera with orthogonal mode and created a plane with UI material and BODY texture, then I added another plane and moved it up slightly, the final texture I dragged to my human model BODY material. Now I can add as many decals as I want at runtime.
P.S. I use Substance Painter to adjust decals position to fit my model UV.