I created fog by raw image and material with custom shader.
Now I want to darken some gameobjects(sprites) which cross fog border.
But I'm noob in shaders. How I can do this? Write any links on manuals/tutorials or some ideas.
Picture for clarity:
Fog shader:
Shader "Custom/Fog" {
Properties{
_Color("Main Color", Color) = (1,1,1,1)
_MainTex("Base (RGB)", 2D) = "white" {} // Base (RGB)
}
SubShader{
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" "LightMode" = "ForwardBase" "IgnoreProjector" = "True" }
Blend SrcAlpha OneMinusSrcAlpha
Lighting Off
LOD 200
CGPROGRAM
#pragma surface surf NoLighting noambient alpha:blend
fixed4 _Color;
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
};
void surf(Input IN, inout SurfaceOutput o) {
half4 baseColor = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = _Color.rgb * baseColor.b;
o.Alpha = _Color.a - baseColor.g;
}
ENDCG
}
FallBack "Diffuse"
}