Restructured for new direction.
This commit is contained in:
143
Assets/Shaders/UIRowReveal/UIRowReveal.shader
Normal file
143
Assets/Shaders/UIRowReveal/UIRowReveal.shader
Normal file
@@ -0,0 +1,143 @@
|
||||
Shader "BriarQueen/UI/Row Highlight"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
_Color ("Tint", Color) = (1, 1, 1, 1)
|
||||
|
||||
_HighlightColor ("Highlight Color", Color) = (0, 0, 0, 1)
|
||||
_Intensity ("Intensity", Range(0, 1)) = 0.6
|
||||
_HorizontalWidth ("Horizontal Width", Range(0.1, 1)) = 0.7
|
||||
_VerticalWidth ("Vertical Width", Range(0.1, 1)) = 0.7
|
||||
_CentreDarkness ("Centre Darkness", Range(1, 4)) = 2.0
|
||||
|
||||
_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
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", 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 [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Default"
|
||||
CGPROGRAM
|
||||
#pragma vertex Vert
|
||||
#pragma fragment Frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_CLIP_RECT
|
||||
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
||||
|
||||
struct AppData
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _Color;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
fixed4 _HighlightColor;
|
||||
float _Intensity;
|
||||
float _HorizontalWidth;
|
||||
float _VerticalWidth;
|
||||
float _CentreDarkness;
|
||||
|
||||
Varyings Vert(AppData input)
|
||||
{
|
||||
Varyings output;
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.worldPosition = input.vertex;
|
||||
output.vertex = UnityObjectToClipPos(input.vertex);
|
||||
output.uv = input.texcoord;
|
||||
output.color = input.color * _Color;
|
||||
return output;
|
||||
}
|
||||
|
||||
fixed4 Frag(Varyings input) : SV_Target
|
||||
{
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
float clipAlpha = UnityGet2DClipping(input.worldPosition.xy, _ClipRect);
|
||||
#else
|
||||
float clipAlpha = 1.0;
|
||||
#endif
|
||||
|
||||
float2 uv = input.uv * 2.0 - 1.0;
|
||||
|
||||
// smoothstep reaches exactly 0 at _Width — no rect boundary visible
|
||||
float h = 1.0 - smoothstep(0.0, _HorizontalWidth, abs(uv.x));
|
||||
float v = 1.0 - smoothstep(0.0, _VerticalWidth, abs(uv.y));
|
||||
float mask = h * v;
|
||||
|
||||
// Darker in the centre, lighter toward the fade edge
|
||||
float radial = length(float2(abs(uv.x) / _HorizontalWidth,
|
||||
abs(uv.y) / _VerticalWidth));
|
||||
float centreBoost = pow(saturate(1.0 - radial), _CentreDarkness);
|
||||
float brightness = lerp(1.0, 0.25, centreBoost);
|
||||
|
||||
fixed4 result;
|
||||
result.rgb = _HighlightColor.rgb * brightness;
|
||||
|
||||
// Deliberately not multiplying by sprite or vertex alpha —
|
||||
// transparent image or color has no effect on the gradient
|
||||
result.a = mask * _Intensity * clipAlpha;
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip(result.a - 0.001);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user