Default mirror shader with bump map.

Hey, guys. I am sorry for my bad english, but i have a little problem. I need your help. :frowning:
http://wiki.unity3d.com/index.php/MirrorReflection4 There is a default fx mirror shader, is this possible to add bump map in this shader? Thx very much.

Shader "FX/MirrorReflection"
{
    Properties
    {
        _MainTex ("Base (RGB)", 2D) = "white" {}
        [HideInInspector] _ReflectionTex ("", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100
        Pass {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 refl : TEXCOORD1;
                float4 pos : SV_POSITION;
            };
            float4 _MainTex_ST;
            v2f vert(float4 pos : POSITION, float2 uv : TEXCOORD0)
            {
                v2f o;
                o.pos = mul (UNITY_MATRIX_MVP, pos);
                o.uv = TRANSFORM_TEX(uv, _MainTex);
                o.refl = ComputeScreenPos (o.pos);
                return o;
            }
            sampler2D _MainTex;
            sampler2D _ReflectionTex;
            fixed4 frag(v2f i) : SV_Target
            {
                fixed4 tex = tex2D(_MainTex, i.uv);
                fixed4 refl = tex2Dproj(_ReflectionTex, UNITY_PROJ_COORD(i.refl));
                return tex * refl;
            }
            ENDCG
        }
    }

Any solution?

A couple of weeks ago, I rewrote the standard shader to include planar relfections (as a fun test). All you need to do is offset the reflection texels by the normal.

This is an example of what I did, but it is a surface shader. Give me some time and I’ll incorporate it into this shader if you wish.

Here’s the shader:

    Shader "FX/MirrorReflection"
    {
        Properties
        {
            _MainTex ("Base (RGB)", 2D) = "white" {}
            _BumpMap ("Normal Map", 2D) = "bump" {}
            [HideInInspector] _ReflectionTex ("", 2D) = "white" {}
        }
        SubShader
        {
            Tags { "RenderType"="Opaque" }
            LOD 100
            Pass {
                CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                #include "UnityCG.cginc"
                struct v2f
                {
                    half3 tspace0 : TEXCOORD1;
                    half3 tspace1 : TEXCOORD2;
                    half3 tspace2 : TEXCOORD3;
                    float2 uv0 : TEXCOORD4;
                    float2 uv1 : TEXCOORD5;
                    float4 refl : TEXCOORD6;
                    float4 pos : SV_POSITION;
                };

                float4 _MainTex_ST;
                float4 _BumpMap_ST;

                v2f vert (appdata_tan v)
                {
                    v2f o;
                    o.pos = mul (UNITY_MATRIX_MVP, v.vertex);

                    half3 wNormal = UnityObjectToWorldNormal (v.normal);
                    half3 wTangent = UnityObjectToWorldDir (v.tangent.xyz);
                    half tangentSign = v.tangent.w * unity_WorldTransformParams.w;
                    half3 wBitangent = cross (wNormal, wTangent) * tangentSign;
                    o.tspace0 = half3 (wTangent.x, wBitangent.x, wNormal.x);
                    o.tspace1 = half3 (wTangent.y, wBitangent.y, wNormal.y);
                    o.tspace2 = half3 (wTangent.z, wBitangent.z, wNormal.z);

                    o.uv0 = TRANSFORM_TEX (v.texcoord, _MainTex);
                    o.uv1 = TRANSFORM_TEX (v.texcoord, _BumpMap);
                    o.refl = ComputeScreenPos (o.pos);
                    return o;
                }

                sampler2D _MainTex;
                sampler2D _BumpMap;
                sampler2D _ReflectionTex;
                float4 _ReflectionTex_TexelSize;

                fixed4 frag(v2f i) : SV_Target
                {
                    half3 tnormal = UnpackNormal (tex2D (_BumpMap, i.uv1));
                   
                    half3 worldNormal;
                    worldNormal.x = dot (i.tspace0, tnormal);
                    worldNormal.y = dot (i.tspace1, tnormal);
                    worldNormal.z = dot (i.tspace2, tnormal);

                    float2 offset = worldNormal * 100 * _ReflectionTex_TexelSize;
                    i.refl.xy = i.refl.z * offset + i.refl.xy;

                    fixed4 tex = tex2D (_MainTex, i.uv0);
                    fixed4 refl = tex2Dproj (_ReflectionTex, UNITY_PROJ_COORD (i.refl));
                    return tex * refl;
                }
                ENDCG
            }
        }
        Fallback "Diffuse"
   }