is there any shader that will executed always. that means we should not care about the camera’s rendering mode.
yep, unity support us the keyword Always to solve this problem.
next, we will give the shader code like this:
// Upgrade NOTE: replzaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Course/Always"
{
SubShader
{
pass
{
Tags{ "LightMode"="Always"}
Blend One Zero
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#include "Lighting.cginc"
struct vertOut
{
float4 pos:SV_POSITION;
float4 color:COLOR;
};
vertOut vert(appdata_base v)
{
vertOut o;
o.pos=UnityObjectToClipPos(v.vertex);
o.color=float4(1,0,0,1);
return o;
}
float4 frag(vertOut i):COLOR
{
return i.color;
}
ENDCG
}
}
}
you can change the camera’s rendering mode to any of this:
the object will be render to red in every circumstances.
the effect is :