89 lines
1.7 KiB
Plaintext
89 lines
1.7 KiB
Plaintext
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
|
|
|
Shader "Zhanyou/MaskGradient"
|
|
{
|
|
Properties
|
|
{
|
|
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
|
_Color("Tint", Color) = (1,1,1,1)
|
|
|
|
// required for UI.Mask
|
|
_StencilComp("Stencil Comparison", Float) = 8
|
|
_Stencil("Stencil ID", Float) = 0
|
|
_StencilOp("Stencil Operation", Float) = 0
|
|
_StencilWriteMask("Stencil Write Mask", Float) = 255
|
|
_StencilReadMask("Stencil Read Mask", Float) = 255
|
|
_ColorMask("Color Mask", Float) = 15
|
|
}
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
// ...
|
|
}
|
|
|
|
// required for UI.Mask
|
|
Stencil
|
|
{
|
|
Ref[_Stencil]
|
|
Comp[_StencilComp]
|
|
Pass[_StencilOp]
|
|
ReadMask[_StencilReadMask]
|
|
WriteMask[_StencilWriteMask]
|
|
}
|
|
ColorMask[_ColorMask]
|
|
|
|
Pass
|
|
{
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
Cull Back
|
|
|
|
// I tried to edit these with no results
|
|
ZWrite Off
|
|
ZTest Off
|
|
|
|
|
|
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#pragma target 2.0
|
|
#pragma glsl_no_auto_normalization
|
|
|
|
sampler2D _MainTex;
|
|
|
|
struct VertexInput
|
|
{
|
|
fixed4 position : POSITION;
|
|
fixed2 uv : TEXCOORD0;
|
|
fixed4 tintColor : COLOR;
|
|
};
|
|
|
|
struct VertexOutput
|
|
{
|
|
fixed4 position : SV_POSITION;
|
|
fixed2 uv : TEXCOORD0;
|
|
fixed4 tintColor : COLOR;
|
|
};
|
|
|
|
VertexOutput vert(VertexInput input)
|
|
{
|
|
VertexOutput output;
|
|
output.position = UnityObjectToClipPos(input.position);
|
|
output.uv = input.uv;
|
|
output.tintColor = input.tintColor;
|
|
|
|
return output;
|
|
}
|
|
|
|
fixed4 frag(VertexOutput input) : COLOR
|
|
{
|
|
fixed4 fragmentColor = tex2D(_MainTex, input.uv) * input.tintColor;
|
|
|
|
return fragmentColor;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
} |