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 !

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.

  1. Start by duplicating your texture file
  2. Edit the first one and make it black & white only
  3. Edit the second and create whatever pattern you want on it, grayscale only
  4. In Unity, add you cloth to your character
  5. In the SkinMesh Renderer, you should have one or more material in the “Materials” tab (not the material list)
  6. Find the one which controls the color part you want. You may have several ones at once.
  7. In your assets folder, duplicate this material
  8. Assign the black/white texture to the first material and your pattern texture to the second material
  9. In the skinmesh renderer materials tab, add a slot and put the pattern material in it
  10. 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.