Easy way to create clothes with simple color + different pattern
Hi everybody,
I'm working on a game where I'd like to generate random character who will have random outfits.
I'm quite new to Unity but so far, I've been able to change the color of the different parts of the outfits with a color picker. Now I'd like to add the possibility for the cloths to have images on them.
For example, there is a t-shirt with a white texture in my game which is then colored. I'd like to add a heart or a cross on it loaded from a second texture image similar to the first one.
I tried to apply the second texture to the details albedo but it messes the colors of the cloth.
Is what I'm asking possible and if yes, how to achieve ?
Thanks !
Answer by GawebStudio · Jan 20, 2018 at 01:45 PM
Ok, so to answer myself. It's not the perfect solution but it's quite simple to implement as long as you have the basic texture file.
Start by duplicating your texture file
Edit the first one and make it black & white only
Edit the second and create whatever pattern you want on it, grayscale only
In Unity, add you cloth to your character
In the SkinMesh Renderer, you should have one or more material in the "Materials" tab (not the material list)
Find the one which controls the color part you want. You may have several ones at once.
In your assets folder, duplicate this material
Assign the black/white texture to the first material and your pattern texture to the second material
In the skinmesh renderer materials tab, add a slot and put the pattern material in it
Set your pattern texture Alpha Source to Grayscale and enable Alpha is transparency
You should now be able to colorize the two parts independently while having different patterns for the same cloth. Just create more pattern textures and use a script to exchange them.
There are a few downsides this method so far : You lose the possible shadows you have in the original texture. I didn't bother too much with this but this could actually be easily solved in step 2 by making grayscale and adding the shadow in the main texture. Or you could use an height map too from what I understood. The second downside is that the color of the cloth will tend to be whiter than intended. Even full black will appear as grey due to the pattern material.
That's about it at the moment. Again, I'm quite new to Unity, been working with it for about a month only so if you have a better solution, let me know. But I guess my solution could help a few other creators if they don't mind the downsides listed.
Your answer
![](https://koobas.hobune.stream/wayback/20220612150910im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is it posible to access albedo imported image texture via script? 1 Answer
Standard Shader Emissive Warning? 2 Answers
Custom material upon a particle is too light 0 Answers
2D image shader, 3D object UV mapping , Using good lightings,,, somebody help me! 0 Answers
Create a prefab from an instantiated object in the editor 1 Answer