Additive Shader

Hey all,

I have a model that is unwrapped so that individual textures are to be set up like so:

So I have individual textures for the feet, pants, hands, ect. that I can combine in various ways to get different looking models. Since it would be impractical to make a different texture of each possible combination of feet, pants, hands, ect. I would like to be able to just make a material for each hand texture, head texture, ect. and drag that material onto the model.

So I would need a shader that combines these materials additively, correct? Or would it be better to create a shader that takes 5 textures and combines them? I’m horrible when it comes to textures, so I’m hoping I can get some input from you guys.

Thanks.

The simplest solution is to give your model five submeshes, so it can use five different materials. Each submesh should use the whole 0-1 UV space.

I do agree that would be the easiest. Unfortunately for me, I’m somewhat forced to do it this way because I bought this thinking that they would make this process a little easier for me. They just have the single mesh, but maybe I can break it into pieces. I just fear that will ruin the animations and UV maps. I’m no artist, haha.

In regards to combining the textures, I’ve come up with this:

Shader "Custom/Alpha Blended Textures" {
	Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
        _BlendTex ("Alpha Blended (RGBA)", 2D) = "white" {}
        _BlendTex2 ("Alpha Blended (RGBA) 2", 2D) = "white" {}
        _BlendTex3 ("Alpha Blended (RGBA) 3", 2D) = "white" {}
        _BlendTex4 ("Alpha Blended (RGBA) 4", 2D) = "white" {}
    }
    SubShader {
        Pass {
        	Lighting On
        
            // Apply base texture
            SetTexture [_MainTex] {
                combine texture
            }
            // Blend in the alpha texture using the lerp operator
            SetTexture [_BlendTex] {
                combine texture lerp (texture) previous
            }
            // Blend in the alpha texture using the lerp operator
            SetTexture [_BlendTex2] {
                combine texture lerp (texture) previous
            }
            // Blend in the alpha texture using the lerp operator
            SetTexture [_BlendTex3] {
                combine texture lerp (texture) previous
            }
            // Blend in the alpha texture using the lerp operator
            SetTexture [_BlendTex4] {
                combine texture lerp (texture) previous
            }
        }
    }
}

which stitches all the individual textures into one material, although I can’t get lighting to work correctly. And I have no idea what kind of performance issues I may run into with a shader like this.

Thats a really slow rendering method. You’re actually much better off using render to texture to generate your textures at run time.

You ought to be able to split up the mesh in a script using the existing UV coordinates to tell what part each vertex belongs to. Then you can normalize the UV coordinates for each submesh, and you should be good to go.

That really depends on how many combinations are going to exist at once, whether Discord has Unity Pro, and how it runs on the target hardware.

This sounds really promising, but I’m not sure where I would start. Would you mind expanding on the process behind that a little bit? I’m just not sure what kind of process is involved in splitting up a mesh via UV coordinates. I guess I’ll start by looking into the Mesh class.

There could easily be hundreds of combinations, since there are least 4 textures for each body part that can be mixed and matched. And there will be multiple players in an area at once, so I don’t think render textures will be my best option. And I am using pro if that matters.