edx/assignment10final/Assets/Shaders/ScreenCutoutShader.shader
2022-11-10 21:56:29 -03:00

70 lines
1.2 KiB
Plaintext
Executable File

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
Shader "Unlit/ScreenCutoutShader"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Mask ("Culling Mask", 2D) = "white" {}
}
SubShader
{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
Lighting Off
Cull Back
ZWrite On
ZTest Less
Blend SrcAlpha OneMinusSrcAlpha
Fog{ Mode Off }
Pass
{
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 screenPos : TEXCOORD1;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.screenPos = ComputeScreenPos(o.vertex);
return o;
}
sampler2D _MainTex;
fixed4 frag (v2f i) : SV_Target
{
i.screenPos /= i.screenPos.w;
fixed4 col = tex2D(_MainTex, float2(i.screenPos.x, i.screenPos.y));
return col;
}
ENDCG
}
}
Subshader {
Pass {
SetTexture[_Mask] {combine texture alpha}
}
}
}