Hi,
I made a very simple shader for a mobile game, it’s a vertex lit with a color (no texture)
sometimes it renders corerctly and sometimes it appears unlit. looks like it depends on the distance but not only that.
here is the code :
Shader "Mobile/VertexLitColor"
{
Properties
{
_Color("Main Color", COLOR) = (1,1,1,1)
}
SubShader
{
Pass
{
Tags{ "RenderType" = "Opaque" }
LOD 100
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "UnityLightingCommon.cginc"
struct v2f
{
fixed4 diff : COLOR0;
float4 vertex : SV_POSITION;
};
v2f vert(appdata_base v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
half3 worldNormal = UnityObjectToWorldNormal(v.normal);
half nl = max(0, dot(worldNormal, _WorldSpaceLightPos0.xyz));
o.diff = nl * _LightColor0 * 1.5f;
o.diff.rgb += unity_AmbientSky * 1.5f;
o.diff.rgb *= 0.5f;
return o;
}
float4 _Color;
fixed4 frag(v2f i) : SV_Target
{
fixed4 col = _Color * i.diff;
return col;
}
ENDCG
}
}
}
Any idea why it would do that and how to fix it ?
Thanks.