Unity 4.6 - WP8 Transparency Shader for Fog

Hello,

Since Unity 4.6 doesn’t support fog on WP8 platforms, I have added fog support to all of my shaders thanks to this blog: Software7

However, when I try to add fog support to my transparency shader, I get an error. I am new to shaders. Any help to fix this error will be appraciated. (I use echologin shaders in my project, but he dropped support and I can’t reach him)

Thanks in advance…

Here is the shader (modified for fog support):

Shader "old-echoLogin/Transparent/Cutout/20-Color-WP8_v2"
{
    Properties
       {
        _TransparencyLM ("Transparency LM", 2D) = "gray" {}
        _echoRGBA ( "RGBA Multiply", Vector )            = ( 1, 1, 1, 1 )  
       }
    //=========================================================================
    SubShader
    {
        Tags {"Queue"="Transparent+1" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
        Fog {Mode  Off}

        Pass
        {  
            Name "BASE"
               ZWrite Off
               Blend SrcAlpha OneMinusSrcAlpha
              Cull Off
           
            CGPROGRAM
          
             #pragma vertex vert vertex:fogVertex finalcolor:fogColor
            #pragma fragment frag
            #pragma fragmentoption ARB_precision_hint_fastest
            #pragma multi_compile_fwdbase

            uniform half4 unity_FogColor;
            uniform half4 unity_FogStart;
            uniform half4 unity_FogEnd;
            uniform half4 unity_FogDensity;

            #include "UnityCG.cginc"

            sampler2D    _TransparencyLM;
            float4        _TransparencyLM_ST;
            float4        _TransparencyLM_TexelSize;

#ifndef LIGHTMAP_OFF
            sampler2D   unity_Lightmap;
            float4       unity_LightmapST;
#endif
            float4        _echoRGBA;

             struct VertInput
            {
                float4 vertex    : POSITION;
                float2 texcoord    : TEXCOORD0;
                float4 color    : COLOR;
#ifndef LIGHTMAP_OFF
                  float4 texcoord1: TEXCOORD1;
#endif
                half fogFactor;
            };

            void fogVertex(inout appdata_full v, out VertInput data)
            {
                UNITY_INITIALIZE_OUTPUT(VertInput, data);
                float cameraVertDist = length(mul(UNITY_MATRIX_MV, v.vertex).xyz);
                data.fogFactor = saturate((unity_FogEnd.x - cameraVertDist) / (unity_FogEnd.x - unity_FogStart.x));          
            }

            void fogColor(VertInput IN, SurfaceOutput o, inout fixed4 color)
            {
                color.rgb = lerp(unity_FogColor.rgb, color.rgb, IN.fogFactor);
            }

               struct Varys
            {
                half4 pos        : SV_POSITION;
                half2 tc1        : TEXCOORD0;
                fixed4 vcolor    : TEXCOORD1;
#ifndef LIGHTMAP_OFF
                half2 tc3        : TEXCOORD3;
#endif
            };

             //=============================================
            Varys vert ( VertInput ad )
            {
                Varys v;

                v.vcolor        = ad.color * _echoRGBA;
                v.pos    = mul ( UNITY_MATRIX_MVP, ad.vertex );
                  v.tc1     = ( _TransparencyLM_ST.xy * ad.texcoord.xy ) + _TransparencyLM_ST.zw;

#ifndef LIGHTMAP_OFF
                   v.tc3     = ( unity_LightmapST.xy * ad.texcoord1.xy ) + unity_LightmapST.zw;
#endif
                return v;
            }
   
             //=============================================
            fixed4 frag ( Varys v ):COLOR
            {
                fixed4 fcolor = tex2D ( _TransparencyLM, v.tc1 );
      
#ifndef LIGHTMAP_OFF
                fcolor.xyz *= DecodeLightmap ( tex2D ( unity_Lightmap, v.tc3 ) );
#endif
                return fcolor * v.vcolor;
            }

            ENDCG
        }
     }
}

And here is the error I am getting:
Shader error in ‘old-echoLogin/Transparent/Cutout/20-Color-WP8_v2’: syntax error, unexpected ‘,’ at token “,” type name expected at token “,” at line 78

Line 78 is this line:
void fogColor(VertInput IN, SurfaceOutput o, inout fixed4 color)

Yeah, that guide of yours works only with surface shaders. Maybe this will work. I didn’t test it, I don’t have 4.6.

Shader "old-echoLogin/Transparent/Cutout/20-Color-WP8_v2"
{
    Properties
       {
        _TransparencyLM ("Transparency LM", 2D) = "gray" {}
        _echoRGBA ( "RGBA Multiply", Vector )            = ( 1, 1, 1, 1 ) 
       }
    //=========================================================================
    SubShader
    {
        Tags {"Queue"="Transparent+1" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
        Fog {Mode  Off}
        Pass
        { 
            Name "BASE"
               ZWrite Off
               Blend SrcAlpha OneMinusSrcAlpha
              Cull Off
          
            CGPROGRAM
        
            #pragma vertex vert
            #pragma fragment frag
            #pragma fragmentoption ARB_precision_hint_fastest
            #pragma multi_compile_fwdbase
            uniform half4 unity_FogColor;
            uniform half4 unity_FogStart;
            uniform half4 unity_FogEnd;
            uniform half4 unity_FogDensity;
            #include "UnityCG.cginc"
            sampler2D    _TransparencyLM;
            float4        _TransparencyLM_ST;
            float4        _TransparencyLM_TexelSize;
#ifndef LIGHTMAP_OFF
            sampler2D   unity_Lightmap;
            float4       unity_LightmapST;
#endif
            float4        _echoRGBA;
             struct VertInput
            {
                float4 vertex    : POSITION;
                float2 texcoord    : TEXCOORD0;
                float4 color    : COLOR0;
            };
               struct Varys
            {
                half4 pos        : SV_POSITION;
                half2 tc1        : TEXCOORD0;
                fixed4 vcolor    : TEXCOORD1;
                half fogFactor : TEXCOORD2;
#ifndef LIGHTMAP_OFF
                half2 tc3        : TEXCOORD3;
#endif
            };
                       
            //=============================================
            Varys vert ( VertInput ad )
            {
                Varys v;
                v.vcolor        = ad.color * _echoRGBA;
                v.pos    = mul ( UNITY_MATRIX_MVP, ad.vertex );
                  v.tc1     = ( _TransparencyLM_ST.xy * ad.texcoord.xy ) + _TransparencyLM_ST.zw;
#ifndef LIGHTMAP_OFF
                   v.tc3     = ( unity_LightmapST.xy * ad.texcoord1.xy ) + unity_LightmapST.zw;
#endif

                float cameraVertDist = length(mul(UNITY_MATRIX_MV, ad.vertex).xyz);
                v.fogFactor = saturate((unity_FogEnd.x - cameraVertDist) / (unity_FogEnd.x - unity_FogStart.x));

                return v;
            }
  
             //=============================================
            fixed4 frag ( Varys v ):COLOR
            {
                fixed4 fcolor = tex2D ( _TransparencyLM, v.tc1 );
    
#ifndef LIGHTMAP_OFF
                fcolor.xyz *= DecodeLightmap ( tex2D ( unity_Lightmap, v.tc3 ) );
#endif
                fixed4 color =  fcolor * v.vcolor;

                color.rgb = lerp(unity_FogColor.rgb, color.rgb, v.fogFactor);
                return color;
            }
            ENDCG
        }
     }
}

Thanks a lot. That really worked!