I have a custom fog shader that works great in unity and the editor, but once I deploy to Android (Gear VR, if that makes a difference), it comes out black and white.
This is my main shader for most of the environment, so I get the world in black and white, but the characters are all in color.
I can’t take credit for this shader, it was originally from a windows phone shader to get around the broken fog, but I broke it after trying to get it to fade to black after the fog.
There are 2 color lerps, one adds the fog and works great, but as soon as I add the second one that was supposed to fade to black, I lose all color.
Shader "Custom/Unlit_Fog" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Color ("Fog Color", Color) = (1,1,1,1)
_FogStart("Fog Start", float) = 40
_FogEnd("Fog End", float) = 150
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert finalcolor:mycolor vertex:myvert
sampler2D _MainTex;
uniform half4 _Color;
uniform half _FogStart;
uniform half _FogEnd;
float4 color : COLOR;
struct Input
{
float2 uv_MainTex;
half Myfog;
};
void myvert (inout appdata_full v, out Input data)
{
UNITY_INITIALIZE_OUTPUT(Input,data);
float pos = length(mul (UNITY_MATRIX_MV, v.vertex).xyz);
float diff = _FogEnd - _FogStart;
float invDiff = 1.0f / diff;
data.Myfog = clamp ((_FogEnd - pos) * invDiff, 0.0, 1.0);
}
void mycolor (Input IN, SurfaceOutput o, inout fixed4 color)
{
fixed3 fogColor = _Color.rgb;
fixed3 CalcColor = _Color.rgb;
CalcColor = lerp(fogColor, color.rgb, IN.Myfog);
CalcColor = lerp((0,0,0,0), CalcColor.rgb, IN.Myfog);
color.rgb = CalcColor.rgb;
}
void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}