Adding BumpMap to a shader?

I downloaded the package provided in this video:

…and I want to add support for BumpMap to the “Diffuse-XRay-Replaceable” shader, which looks like this:

Shader "XRay Shaders/Diffuse-XRay-Replaceable"
{
    Properties
    {
        _Color("Main Color", Color) = (1,1,1,1)
        _EdgeColor("Edge Color", Color) = (0,0,0,0)
        _MainTex("Base (RGB)", 2D) = "white" {}
    }

    SubShader
    {
        Tags
        {
            "Queue" = "Geometry-1"
            "RenderType" = "Opaque"
            "XRay" = "ColoredOutline"
        }
        LOD 200

        CGPROGRAM
        #pragma surface surf Lambert

        sampler2D _MainTex;
        fixed4 _Color;

        struct Input {
            float2 uv_MainTex;
        };

        void surf(Input IN, inout SurfaceOutput o)
        {
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Alpha = c.a;
        }
        ENDCG
    }
   
    Fallback "Legacy Shaders/VertexLit"
}

I have no knowledge in shaders whatsoever, but I really need to use this shader in my Top Down Shooter I’m creating and alot of my models of course uses normal maps. Can anyone help?

I hate asking for Copy and Paste-ready code, but I have tried for about 2 years now to learn shader-coding but frankly, I’ve learned absolutely nothing :')

Shader "XRay Shaders/Diffuse-XRay-Replaceable"
{
    Properties
    {
        _Color("Main Color", Color) = (1,1,1,1)
//        _EdgeColor("Edge Color", Color) = (0,0,0,0)
        _MainTex("Base (RGB)", 2D) = "white" {}
        _BumpTex ("Bump", 2D) = "bump" {}
    }
    SubShader
    {
        Tags
        {
            "Queue" = "Geometry-1"
            "RenderType" = "Opaque"
//            "XRay" = "ColoredOutline"
        }
        LOD 200
        CGPROGRAM
        #pragma surface surf Lambert
        sampler2D _MainTex;
        sampler2D _BumpTex;
        fixed4 _Color;
        struct Input {
            float2 uv_MainTex : TEXCOORD0;
            float2 uv_BumpTex : TEXCOORD1;
        };
        void surf(Input IN, inout SurfaceOutput o)
        {
            fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Alpha = c.a;
            o.Normal = UnpackNormal(tex2D(_BumpTex, IN.uv_BumpTex));
        }
        ENDCG
    }
  
    Fallback "Legacy Shaders/Bumped Diffuse"
}

It seems to me that the line with “_EdgeColor” and the one with “XRay” aren’t doing anything, so I disabled them.

1 Like

They’re there for the replacement shader pass. They don’t do anything in that shader, but they do in the xray shader.