Question by
redskidy · Jun 01, 2018 at 06:11 PM ·
shadersflickeringunlitvertex-lit
Shader flickering, becomes unlit
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.
Comment
Best Answer
Answer by redskidy · Jun 01, 2018 at 08:59 PM
So I've had this bug for 2 days but it just fixed itself right now, I have no idea what fixed it so if you were hoping for an answer I'm sorry
Your answer
![](https://koobas.hobune.stream/wayback/20220612163901im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why is my fog rendering through unlit textures? 0 Answers
Unlit shader not showing color in main preview 0 Answers
[BUG] Linear fog and Unlit shaders 0 Answers
Unlit separate alpha tint Shader 0 Answers