You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
1.8 KiB
80 lines
1.8 KiB
3 years ago
|
Shader "Unlit/TestClipShader"
|
||
|
{
|
||
|
Properties
|
||
|
{
|
||
|
_MainTex ("Texture", 2D) = "white" {}
|
||
|
_CutOutTex("Cut Tex", 2D) = "white" {}
|
||
|
_CutOutValueX("Cut Value X",Float) = 1.0
|
||
|
_CutOutValueY("Cut Value Y",Float) = 1.0
|
||
|
_CutOutValueZ("Cut Value Z",Float) = 1.0
|
||
|
_CutOutColor("Cut Color",COLOR) = (1,1,1,1)
|
||
|
_CutOutStrength("Cut Strength",Range(0.5,10.0)) = 1.0
|
||
|
}
|
||
|
SubShader
|
||
|
{
|
||
|
Tags { "RenderType"="Opaque" }
|
||
|
LOD 100
|
||
|
|
||
|
Pass
|
||
|
{
|
||
|
Cull Off
|
||
|
CGPROGRAM
|
||
|
#pragma vertex vert
|
||
|
#pragma fragment frag
|
||
|
|
||
|
#include "UnityCG.cginc"
|
||
|
|
||
|
struct appdata
|
||
|
{
|
||
|
float4 vertex : POSITION;
|
||
|
float2 uv : TEXCOORD0;
|
||
|
};
|
||
|
|
||
|
struct v2f
|
||
|
{
|
||
|
float2 uv : TEXCOORD0;
|
||
|
float4 vertex : SV_POSITION;
|
||
|
float4 scrPos : TEXCOORD1;
|
||
|
float4 srcVertex : TEXCOORD2;
|
||
|
};
|
||
|
|
||
|
sampler2D _MainTex;
|
||
|
sampler2D _CutOutTex;
|
||
|
float4 _MainTex_ST;
|
||
|
float _CutOutValueX;
|
||
|
float _CutOutValueY;
|
||
|
float _CutOutValueZ;
|
||
|
fixed4 _CutOutColor;
|
||
|
float _CutOutStrength;
|
||
|
|
||
|
v2f vert (appdata v)
|
||
|
{
|
||
|
v2f o;
|
||
|
//o.vertex = v.vertex;
|
||
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
||
|
o.vertex = float4(o.vertex.x,o.vertex.y,o.vertex.z,o.vertex.w);
|
||
|
o.srcVertex = v.vertex;
|
||
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||
|
o.scrPos = ComputeScreenPos(o.vertex);
|
||
|
return o;
|
||
|
}
|
||
|
|
||
|
fixed4 frag (v2f i) : SV_Target
|
||
|
{
|
||
|
// sample the texture
|
||
|
fixed4 col = tex2D(_MainTex, i.uv);
|
||
|
fixed4 secondTex = tex2D(_CutOutTex,i.uv);
|
||
|
//float clipData = _CutOutValueX-i.srcVertex.x+secondTex.r/5;
|
||
|
//clip(clipData);
|
||
|
float clipData = _CutOutValueY-i.srcVertex.y+secondTex.r/5;
|
||
|
clip(clipData);
|
||
|
//clipData = _CutOutValueZ-i.srcVertex.z+secondTex.r/5;
|
||
|
//clip(clipData);
|
||
|
col = col + fixed4(clamp(_CutOutColor.rgb*(0.3-clipData)*_CutOutStrength,0,1),1);
|
||
|
return col;
|
||
|
}
|
||
|
ENDCG
|
||
|
}
|
||
|
}
|
||
|
}
|