Is it possible to add a normal map to a default unlit transparent shader?

I promise, I have done some research but I’m a little confused as there is not consistency between the answers I am getting.

I just want to be able to add a normal map to the default unity unlit transparent shader (code below)

its for a sky dome so I don’t want it to be effected by light or be reflective or emissive etc. i just want to be able to give it some depth.

Is it possible to add normal maps to a unlit transparent shader or am i wasting my time by looking into it?

Shader "Custom/SkyDomeNormalMap"
{
    Properties {
        _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
        _NormalMap ("Normal Map", 2D) = "bump" {}
    }

    SubShader {
        Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
        LOD 100

        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha

        Pass {
            CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                #pragma target 2.0
                #pragma multi_compile_fog

                #include "UnityCG.cginc"

                struct appdata_t {
                    float4 vertex : POSITION;
                    float2 texcoord : TEXCOORD0;
                    UNITY_VERTEX_INPUT_INSTANCE_ID
                };

                struct v2f {
                    float4 vertex : SV_POSITION;
                    float2 texcoord : TEXCOORD0;
                    UNITY_FOG_COORDS(1)
                    UNITY_VERTEX_OUTPUT_STEREO
                };

                sampler2D _MainTex;
                sampler2D _NormalMap;
                float4 _MainTex_ST;

                v2f vert (appdata_t v, float3 normal : NORMAL)
                {
                    v2f o;
                    UNITY_SETUP_INSTANCE_ID(v);
                    UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
                    o.vertex = UnityObjectToClipPos(v.vertex);
                    o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
                    UNITY_TRANSFER_FOG(o,o.vertex);
                    return o;
                }

                fixed4 frag (v2f i) : SV_Target
                {
                    fixed4 col = tex2D(_MainTex, i.texcoord);
                    UNITY_APPLY_FOG(i.fogCoord, col);
                    return col;
                }
            ENDCG
        }
    }
}

What do you mean by depth? Normal mapping is used specifically for lighting 99% of the time. The whole idea behind normal mapping is that you can get lighting w/o depth (ie: actual mesh detail).

I believe I have misunderstood the answers on this post - https://blender.stackexchange.com/questions/63053/bump-maps-vs-normal-maps/63058 - which imply that bump maps and normal maps are essentially the same but normal maps contain more data and are more accurate.

I just want to give the texture some more depth so it doesn’t look so flat.

so for example, I can take a quad and add a texture to it using the standard shader. I can then add a normal map and give it so much more depth and detail. I’m trying to figure out if I can do that with an unlit shader. However, from what you said, I’m guessing that’s not possible as it is “unlit”?

The problem with using a standard shader for the skydome is that it’s effected by the light in the scene and that has some undesired results. I hope this all makes sense.

Because it’s adding more detail to the lighting, yes.

It’s possible, though kind of pointless. You’d be faking some kind of lighting in the shader which you could do just as easily (if not more easily) on the texture itself. Take your normal map, copy off the green channel by itself as a greyscale value, and apply that as an overlay on your skybox texture in Photoshop / Gimp and you’ll get something pretty close to the same thing you’d get in the shader, only for free as it’s pre-baked into the texture.

1 Like

thanks for the info, i did it on photoshop and it looks great :slight_smile: