Shader help?
I want to achieve special effect - sprite must be hidden when light falls on it. I have tweaked some shaders that I have found and got pretty nice results - sprite hides when too close to a source of light. BUT. When I move sprite too far away (and there is no points of light at all) sprite disappear... It seems like Unity renders it only if at least some sort of light falls on it (in range of light sources)... Can some1 help me?
Here is my shader code:
Shader "Custom/HideInLight" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _MergeLevel("_MergeLevel", range(0, 1))=0.5 _Color ("_Color", Color) = (0.4,0.4,0.4,1) } SubShader { Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"} LOD 100 ZWrite Off Blend SrcAlpha OneMinusSrcAlpha LOD 200 CGPROGRAM #pragma surface surf Unlit alpha sampler2D _MainTex; float _MergeLevel; float _AlfaY; fixed4 _Color; struct Input { float2 uv_MainTex : TEXCOORD0; }; half4 LightingUnlit (SurfaceOutput s, half3 lightDir, half atten) { half4 c; c.rgb = s.Albedo *(1- max(0, (atten)*26 )); c.a = _LightColor0.a; return c; } void surf (Input IN, inout SurfaceOutput surface) { half4 col = tex2D (_MainTex, IN.uv_MainTex.xy); surface.Albedo = col.rgb*col.a; surface.Alpha = col.a; } ENDCG } }