Restructured for new direction.
This commit is contained in:
@@ -0,0 +1,191 @@
|
||||
Shader "BriarQueen/UI/Dissolve Blue Particles"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
_Color ("Tint", Color) = (1, 1, 1, 1)
|
||||
|
||||
_DissolveAmount ("Dissolve Amount", Range(0, 1)) = 0
|
||||
_EdgeWidth ("Edge Width", Range(0.001, 0.25)) = 0.06
|
||||
_ParticleColor ("Particle Color", Color) = (0.15, 0.65, 1, 1)
|
||||
_ParticleIntensity ("Particle Intensity", Range(0, 8)) = 2.5
|
||||
_ParticleDensity ("Particle Density", Range(0, 1)) = 0.82
|
||||
_ParticleScale ("Particle Scale", Range(10, 250)) = 95
|
||||
_ParticleDrift ("Particle Drift", Range(0, 3)) = 0.65
|
||||
|
||||
_NoiseScale ("Noise Scale", Range(1, 80)) = 24
|
||||
_NoiseStrength ("Noise Strength", Range(0, 1)) = 0.55
|
||||
[Toggle] _ReverseDirection ("Reverse Direction", 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 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;
|
||||
|
||||
float _DissolveAmount;
|
||||
float _EdgeWidth;
|
||||
fixed4 _ParticleColor;
|
||||
float _ParticleIntensity;
|
||||
float _ParticleDensity;
|
||||
float _ParticleScale;
|
||||
float _ParticleDrift;
|
||||
float _NoiseScale;
|
||||
float _NoiseStrength;
|
||||
float _ReverseDirection;
|
||||
|
||||
float Hash21(float2 p)
|
||||
{
|
||||
p = frac(p * float2(123.34, 345.45));
|
||||
p += dot(p, p + 34.345);
|
||||
return frac(p.x * p.y);
|
||||
}
|
||||
|
||||
float ValueNoise(float2 uv)
|
||||
{
|
||||
float2 i = floor(uv);
|
||||
float2 f = frac(uv);
|
||||
float2 u = f * f * (3.0 - 2.0 * f);
|
||||
|
||||
float a = Hash21(i);
|
||||
float b = Hash21(i + float2(1.0, 0.0));
|
||||
float c = Hash21(i + float2(0.0, 1.0));
|
||||
float d = Hash21(i + float2(1.0, 1.0));
|
||||
|
||||
return lerp(lerp(a, b, u.x), lerp(c, d, u.x), u.y);
|
||||
}
|
||||
|
||||
float DissolveNoise(float2 uv)
|
||||
{
|
||||
float n = ValueNoise(uv * _NoiseScale);
|
||||
n += ValueNoise(uv * _NoiseScale * 2.13 + 17.0) * 0.5;
|
||||
n += ValueNoise(uv * _NoiseScale * 4.07 + 43.0) * 0.25;
|
||||
n /= 1.75;
|
||||
|
||||
float verticalBias = lerp(uv.y, 1.0 - uv.y, step(0.5, _ReverseDirection));
|
||||
return saturate(lerp(verticalBias, n, _NoiseStrength));
|
||||
}
|
||||
|
||||
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 color = (tex2D(_MainTex, input.uv) + _TextureSampleAdd) * input.color;
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
color.a *= UnityGet2DClipping(input.worldPosition.xy, _ClipRect);
|
||||
#endif
|
||||
|
||||
float amount = saturate(_DissolveAmount);
|
||||
float dissolveNoise = DissolveNoise(input.uv);
|
||||
float visible = smoothstep(amount - _EdgeWidth, amount + _EdgeWidth, dissolveNoise);
|
||||
visible = amount <= 0.001 ? 1.0 : visible;
|
||||
visible = amount >= 0.999 ? 0.0 : visible;
|
||||
|
||||
float edge = 1.0 - smoothstep(0.0, _EdgeWidth, abs(dissolveNoise - amount));
|
||||
edge *= step(0.001, amount) * step(amount, 0.999);
|
||||
|
||||
float2 particleUv = input.uv * _ParticleScale;
|
||||
particleUv.y += _Time.y * _ParticleDrift;
|
||||
particleUv.x += sin(_Time.y + input.uv.y * 12.0) * 0.35;
|
||||
|
||||
float particles = step(_ParticleDensity, Hash21(floor(particleUv)));
|
||||
particles *= edge;
|
||||
particles *= visible;
|
||||
|
||||
color.rgb += _ParticleColor.rgb * particles * _ParticleIntensity;
|
||||
color.rgb = lerp(color.rgb, _ParticleColor.rgb, edge * 0.35);
|
||||
color.a *= visible;
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user