Shader with 4 textures, 4 colors and diffuse output?

Hi.

I’m totally noob about shaders and trying to combine in a material 4 textures each one with it’s own color. The goal for this is making a customizable outfit for the players so they can choose their own cloth design pattern in any color. Achieved to combine the 4 textures ( 2 for upper body 2 for lower body: base coloured texture and coloured texture pattern) and it works well but looks so plain, unlit…

It’s the first time I’m messing around with shaders and I can´t make it react to light. The simplest diffuse would be enough, no need for complex output. Any clue in how to achieve this? Code below.

Thanks a lot in advance.

Have a nice day!

    Shader "Combined + Diffuse" {
        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" {}


            _Color ("M1", Color) = (1,1,1)
            _Color1 ("M2", Color) = (1,1,1)
            _Color2 ("C1", Color) = (1,1,1)
            _Color3 ("C2", Color) = (1,1,1)

        }
        SubShader {

        
            Pass {
            
                SetTexture [_MainTex] {
                    constantColor [_Color]
                        combine constant lerp(texture) previous
                   }

                SetTexture [_MainTex] {
                    combine previous * texture
                }
                 SetTexture [_BlendTex] {
                    constantColor [_Color1]
                        combine constant lerp(texture) previous
                   }
                SetTexture[_BlendTex]{
                    combine previous * texture
                }
                 SetTexture [_BlendTex2] {
                    constantColor [_Color2]
                        combine constant lerp(texture) previous
                   }
                    SetTexture[_BlendTex2]{
                    combine previous * texture
                }
                 SetTexture [_BlendTex3] {
                    constantColor [_Color3]
                        combine constant lerp(texture) previous
                   }
                    SetTexture[_BlendTex3]{
                    combine previous * texture
                }
            }
        }
        FallBack "Diffuse"

    }

Edited: A screenshot because I can feel I’m not explaining this correctly. Yellow is the main color of the upper outfit and blue is the pattern color. Orange is the main color of the lower outfit and green is the pattern color.

You’re using an old, and deprecated, fixed function shader syntax. This style of shader code was used to write shaders for devices made 20+ years ago, and which functionally no longer exist. The last desktop GPU made that used these stopped being made sometime in the early 00’s, the last consumer mobile devices outside of extreme budget ones by the end of the 00’s.

For backwards compatibility, Unity will automatically convert shaders written in this style to a more modern shader behind the scenes so they continue to work. But you’re limiting yourself significantly for any kind of customization you might be wanting to do.

You might try going through these tutorials:

And then you’ll likely want to use a Surface Shader, which lets you write more modern shader code while still letting Unity handle most of the complicated parts behind the scenes. Or perhaps look at getting Amplify Shader Editor or Unity’s Shader Graph to write your shaders using a node based shader system.

1 Like

Thanks for the reply

Didn´t realize my tiny knowledge about shaders was so out of date. Did a bit research starting from the tutorials you sent me and made a surface shader from scratch. The result is far better than the original one in terms of visual quality.
7967610--1021806--Shader2.PNG

Still not 100% convinced with the result, don’t know exactly why… It maybe receives more light than expected, is too bright. Will fool around a bit more, any new advice or link is very welcome.

Thanks a lot for your help, you saved my day.

Have a nice day.

1 Like

Thank you very much.
Will take a look at it.
Have a nice day!