I’m having a very odd problem here, a rim light shader I’m writing will disappear at certain viewing angles unless it’s rendering over the skybox (in which case it’s visible from all angles). The shader is transparent, but the issue persists even if I make it completely opaque.
Shader "Custom/RimLitTransparent"
{
Properties
{
_Color("Color", Color) = (1,1,1,1)
_RimPower("Rim Power", Range(0.5,8.0)) = 3.0
}
SubShader
{
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
LOD 100
ZWrite off
CGPROGRAM
#pragma surface surf Unlit alpha
#pragma multi_compile_fog
struct Input
{
float3 viewDir;
};
float4 _Color;
float _RimPower;
void surf(Input IN, inout SurfaceOutput o)
{
half rim = 1.0 - saturate(dot(normalize(IN.viewDir), o.Normal));
o.Albedo = _Color.rgb;
o.Alpha = _Color.a + pow(rim, _RimPower);
}
fixed4 LightingUnlit(SurfaceOutput s, fixed3 lightDir, fixed atten)
{
fixed4 c;
c.rgb = s.Albedo;
c.a = s.Alpha;
return c;
}
ENDCG
}
}