Revisiting ShadowGun Shader for 4.6.x

I am experimenting with shaders for mobile and this used to give me good performance. I pulled it out today and dropped it in a new project and got this error…

“Shader error in ‘Mobile/BackgroundQueueAdditive2’: Did not find shader function ‘vert’ to compile”

Shader "Mobile/BackgroundQueueAdditive2"
{
Properties {
        _Color ("Main Color", Color) = (0.5, 0.5, 0.5, 0)
        _EnvTex ("EnvMap", 2D) = "black" {}                                                 
    }
    SubShader {
//      Tags { "Queue"="Background" "IgnoreProjector" = "True" "RenderType"="Background"}
        Tags { "Queue"="Transparent" "IgnoreProjector" = "True" "RenderType"="Transparent"}
      
        Pass{
//          Alphatest Greater 0
//          Cull Off
            ZWrite Off
//          Blend SrcAlpha OneMinusSrcAlpha     // Alpha blending
            Blend One One                       // Additive
//          Blend One OneMinusDstColor          // Soft Additive
//          Blend DstColor Zero                 // Multiplicative
//          Blend DstColor SrcColor             // 2x Multiplicative
          
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
          
            //Declare Properties
            sampler2D _EnvTex;
            fixed4 _Color;
            //------------------
          
            //Declare structures
            struct v2f{
                float4 pos : SV_POSITION;
                //half4 color : COLOR0;
                //half2 uv : TEXCOORD1;
                half2 uvSphere : TEXCOORD0;
            };
            struct appdata_custom {
                float4 vertex : POSITION;
                //float4 tangent : TANGENT;
                half3 normal : NORMAL;
                //half4 texcoord : TEXCOORD0;
                //half4 color : COLOR;
            };
            //--------------------
          
            half4 _EnvTex_ST;;
          
            //vertex shader
            v2f vert (appdata_custom v)
            {
                v2f o;
                o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
              
                //Sphere mapping ported from http://www.ozone3d.net/tutorials/glsl_texturing_p04.php
                half3 u = normalize( mul(UNITY_MATRIX_MV, v.vertex));
                half3 n = mul(UNITY_MATRIX_IT_MV, float4(v.normal.xyz,0));
                half3 r = reflect( u, n);
              
                half m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );
                o.uvSphere = half2(r.x/m+0.5, r.y/m+0.5);
                //---------------
                              
                //o.uv = TRANSFORM_TEX (v.texcoord, _EnvTex);;
                //o.color = v.color;
                return o;
            }
           //fragment shader
                fixed4 frag (v2f i) : COLOR {
                fixed4 tex = tex2D(_EnvTex, i.uvSphere) * _Color;
                tex.rgb *= 2; //double the color values, but leave alpha untouched
                return tex;
            }
            ENDCG
          
        }
    }
}

What would I change the vert function to in the latest and greatest Unity?

TIA

half4 _EnvTex_ST;;

remove one semicolon

Ummm…duh…thank you. Not sure when that snuck in there…

OK… In trying to use this shader which now compiles without errors, I get the hot pink color and the texture slot will not accept textures. What am I doing wrong here? I am trying to use it as a car shader.

It plays fine at Unity 5 Beta, perhaps restart computer ?

Here is a simple implementation of using the above shader brains for cheap speculars.

Shader "Mobile/SpecAdd"
{

Properties
{
        _EnvTex ("EnvMap", 2D) = "black" {}
        _Texture("_Texture", 2D) = "white" {}                                             
}
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 250
        ZWrite On
        Cull Back
        Lighting Off
        Fog { Mode Off }
  
        Pass
        {
      
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"

            sampler2D _EnvTex;
            sampler2D _Texture;
            half4 _Texture_ST;

            struct v2f
            {
                float4 pos : SV_POSITION;
                half2 uv : TEXCOORD0;
                half2 uvSphere : TEXCOORD1;
            };
            struct appdata_custom
            {
                float4 vertex : POSITION;
                half3 normal : NORMAL;
                half4 texcoord : TEXCOORD0;

            };

            v2f vert (appdata_custom v)
            {
                v2f o;
                o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                half3 u = normalize( mul(UNITY_MATRIX_MV, v.vertex));
                half3 n = mul(UNITY_MATRIX_IT_MV, float4(v.normal.xyz,0));
                half3 r = reflect( u, n);
                half m = 2.0 * sqrt( r.x*r.x + r.y*r.y + (r.z+1.0)*(r.z+1.0) );

                o.uvSphere = half2(r.x/m+0.5, r.y/m+0.5);
                o.uv = TRANSFORM_TEX (v.texcoord, _Texture);;
                return o;
            }

            fixed4 frag (v2f i) : COLOR
            {
                fixed4 tex = tex2D(_EnvTex, i.uvSphere);
                tex.rgb *= 2;
                fixed4 tex2 = tex2D(_Texture, i.uv);
                return tex + tex2;
            }
            ENDCG
        }
    }
}

Add the particles blob at EnvTex slot and your diffuse texture at Texture