-
-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: The implementation way of the 'SoftMaskable' shader has been changed. Please refer to the "Migrating from v1 to v2" section in the Readme for details.
- Loading branch information
Showing
11 changed files
with
279 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Shader "Hidden/UI/SoftMask" | ||
{ | ||
Properties | ||
{ | ||
[Enum (UnityEngine.Rendering.BlendOp)] _BlendOp ("BlendOp", float) = 1 | ||
} | ||
|
||
SubShader | ||
{ | ||
Tags | ||
{ | ||
"Queue"="Transparent" | ||
"IgnoreProjector"="True" | ||
"RenderType"="Transparent" | ||
} | ||
LOD 100 | ||
|
||
Cull Off | ||
ZWrite Off | ||
Blend SrcColor One | ||
BlendOp [_BlendOp] | ||
|
||
Pass | ||
{ | ||
CGPROGRAM | ||
#pragma vertex vert_img | ||
#pragma fragment frag | ||
#pragma target 2.0 | ||
|
||
#include "UnityCG.cginc" | ||
|
||
sampler2D _MainTex; | ||
float _ThresholdMin; | ||
float _ThresholdMax; | ||
float4 _ColorMask; | ||
|
||
float invLerp(const float from, const float to, const float value) | ||
{ | ||
return saturate(max(0, value - from) / max(0.000000001, to - from)); | ||
} | ||
|
||
fixed4 frag(v2f_img i) : SV_Target | ||
{ | ||
const half maxValue = max(_ThresholdMin, _ThresholdMax); | ||
const half minValue = min(_ThresholdMin, _ThresholdMax); | ||
const half alpha = invLerp(minValue, maxValue, tex2D(_MainTex, i.uv).a); | ||
return alpha * _ColorMask; | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |
File renamed without changes.
78 changes: 78 additions & 0 deletions
78
Packages/src/Shaders/Hidden-UI-TerminalMaskingShape.shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
Shader "Hidden/UI/TerminalMaskingShape" | ||
{ | ||
Properties | ||
{ | ||
_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) = 0 | ||
} | ||
|
||
SubShader | ||
{ | ||
Tags | ||
{ | ||
"Queue"="Transparent" | ||
"IgnoreProjector"="True" | ||
"RenderType"="Transparent" | ||
"PreviewType"="Plane" | ||
"CanUseSpriteAtlas"="True" | ||
} | ||
|
||
Stencil | ||
{ | ||
Ref [_Stencil] | ||
Comp [_StencilComp] | ||
Pass [_StencilOp] | ||
ReadMask [_StencilReadMask] | ||
WriteMask [_StencilWriteMask] | ||
} | ||
|
||
Cull Off | ||
Lighting Off | ||
ZWrite Off | ||
ZTest Off | ||
Blend Zero Zero | ||
ColorMask 0 | ||
|
||
Pass | ||
{ | ||
Name "Terminal" | ||
CGPROGRAM | ||
#pragma vertex vert | ||
#pragma fragment frag | ||
|
||
#include "UnityCG.cginc" | ||
struct appdata_t | ||
{ | ||
float4 vertex : POSITION; | ||
UNITY_VERTEX_INPUT_INSTANCE_ID | ||
}; | ||
|
||
struct v2f | ||
{ | ||
float4 vertex : SV_POSITION; | ||
UNITY_VERTEX_OUTPUT_STEREO | ||
}; | ||
|
||
|
||
v2f vert(appdata_t v) | ||
{ | ||
v2f OUT; | ||
UNITY_SETUP_INSTANCE_ID(v); | ||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT); | ||
OUT.vertex = UnityObjectToClipPos(v.vertex); | ||
return OUT; | ||
} | ||
|
||
fixed4 frag(v2f IN) : SV_Target | ||
{ | ||
return fixed4(0, 0, 0, 0); | ||
} | ||
ENDCG | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Packages/src/Shaders/Hidden-UI-TerminalMaskingShape.shader.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.