Restructured for new direction.
This commit is contained in:
149
Assets/Shaders/UILightGlow/UILightGlow.shader
Normal file
149
Assets/Shaders/UILightGlow/UILightGlow.shader
Normal file
@@ -0,0 +1,149 @@
|
||||
Shader "BriarQueen/UI/Light Glow"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
_Color ("Tint", Color) = (1, 1, 1, 1)
|
||||
|
||||
_LightColor ("Light Color", Color) = (1, 0.78, 0.35, 1)
|
||||
_Intensity ("Intensity", Range(0, 8)) = 1.5
|
||||
_Radius ("Radius", Range(0, 1)) = 0.35
|
||||
_Falloff ("Falloff", Range(0.001, 1)) = 0.35
|
||||
_Softness ("Softness", Range(0.25, 6)) = 1.6
|
||||
_Center ("Center", Vector) = (0.5, 0.5, 0, 0)
|
||||
|
||||
_FlickerStrength ("Flicker Strength", Range(0, 1)) = 0.08
|
||||
_FlickerSpeed ("Flicker Speed", Range(0, 20)) = 6
|
||||
_FlickerOffset ("Flicker Offset", Float) = 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 One
|
||||
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 _LightColor;
|
||||
float _Intensity;
|
||||
float _Radius;
|
||||
float _Falloff;
|
||||
float _Softness;
|
||||
float4 _Center;
|
||||
float _FlickerStrength;
|
||||
float _FlickerSpeed;
|
||||
float _FlickerOffset;
|
||||
|
||||
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
|
||||
{
|
||||
fixed4 sprite = tex2D(_MainTex, input.uv) + _TextureSampleAdd;
|
||||
|
||||
float dist = distance(input.uv, _Center.xy);
|
||||
float glow = 1.0 - smoothstep(_Radius, _Radius + _Falloff, dist);
|
||||
glow = pow(saturate(glow), _Softness);
|
||||
|
||||
float flickerA = sin((_Time.y + _FlickerOffset) * _FlickerSpeed);
|
||||
float flickerB = sin((_Time.y + _FlickerOffset) * _FlickerSpeed * 2.37 + 1.91);
|
||||
float flicker = 1.0 + ((flickerA * 0.65 + flickerB * 0.35) * _FlickerStrength);
|
||||
|
||||
float alpha = glow * sprite.a * input.color.a * _LightColor.a * saturate(flicker);
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
alpha *= UnityGet2DClipping(input.worldPosition.xy, _ClipRect);
|
||||
#endif
|
||||
|
||||
fixed4 color;
|
||||
color.rgb = _LightColor.rgb * _Intensity;
|
||||
color.a = alpha;
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Assets/Shaders/UILightGlow/UILightGlow.shader.meta
Normal file
9
Assets/Shaders/UILightGlow/UILightGlow.shader.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37ffbc5d812345a3b233ed6d6929fbf5
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user