[HELP!!!!] ProjectorMultiPlyMask Shader add Unlit
I want to add Unlit shader.
PLEASE HELP ME !!!
Shader "Projector/MultiplyMask" {
Properties {
_ShadowTex ("Cookie", 2D) = "gray" {}
_FalloffTex ("FallOff", 2D) = "white" {}
_AlphaTex("Mask Clamp", 2D) = "" {}
_ProjectorDir("ProjectorDir", Vector) = (0,0,0,0)
}
Subshader {
Tags {"Queue"="Transparent"}
Pass {
ZWrite Off
//ZTest Equal
Cull Back
ColorMask RGB
Blend DstColor Zero
Offset -1, -1
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
struct v2f {
float4 uvShadow : TEXCOORD0;
float4 uvFalloff : TEXCOORD1;
UNITY_FOG_COORDS(2)
float4 pos : SV_POSITION;
};
struct VertexInput {
float4 vertex : POSITION;
fixed3 normal : NORMAL;
};
float4x4 unity_Projector;
float4x4 unity_ProjectorClip;
fixed4 _ProjectorDir;
v2f vert (VertexInput v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.uvShadow = mul (unity_Projector, v.vertex);
o.uvFalloff = mul (unity_ProjectorClip, v.vertex);
UNITY_TRANSFER_FOG(o,o.pos);
half3 worldNormal = UnityObjectToWorldNormal(v.normal.xyz);
if (dot(normalize(_ProjectorDir), worldNormal) >= 0)
o.uvFalloff.a = 0;
else
o.uvFalloff.a = 1;
return o;
}
sampler2D _ShadowTex;
sampler2D _FalloffTex;
sampler2D _AlphaTex;
fixed4 frag (v2f i) : SV_Target
{
fixed4 texS = tex2Dproj(_ShadowTex, UNITY_PROJ_COORD(i.uvShadow));
fixed4 texA = tex2Dproj(_AlphaTex, UNITY_PROJ_COORD(i.uvShadow));
texS.a = 1.0 - texS.a;
fixed4 texF = tex2Dproj(_FalloffTex, UNITY_PROJ_COORD(i.uvFalloff));
fixed4 res = lerp(fixed4(1,1,1,0), texS, abs(texF.a));
UNITY_APPLY_FOG_COLOR(i.fogCoord, res, fixed4(1,1,1,1));
if (texA.a == 0) {
discard;
}
return res;
}
ENDCG
}
}
}
Comment
Your answer

Follow this Question
Related Questions
Make a shader that lets me swap between lambert and unlit 0 Answers
How to change this Shader lit to unlit? 1 Answer
Unlit shader not showing color in main preview 0 Answers
Unlit unity terrain 1 Answer