155 lines
5.4 KiB
Plaintext
155 lines
5.4 KiB
Plaintext
Shader "AibisDream/DreamDataOverflow"
|
|
{
|
|
Properties
|
|
{
|
|
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
|
_Color("Tint", Color) = (1,1,1,1)
|
|
_OverflowIntensity("Overflow Intensity", Range(0, 1)) = 0
|
|
_OverflowExposure("Overflow Exposure", Range(0, 3)) = 1.45
|
|
_OverflowGlow("Overflow Glow", Range(0, 2)) = 0.65
|
|
_OverflowChromatic("Overflow Chromatic", Range(0, 0.04)) = 0.006
|
|
_OverflowNoise("Overflow Noise", Range(0, 0.5)) = 0.08
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"Queue" = "Transparent"
|
|
"RenderType" = "Transparent"
|
|
"RenderPipeline" = "UniversalPipeline"
|
|
"IgnoreProjector" = "True"
|
|
"CanUseSpriteAtlas" = "True"
|
|
}
|
|
|
|
Cull Off
|
|
ZWrite Off
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
HLSLINCLUDE
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
struct Attributes
|
|
{
|
|
float4 positionOS : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
float4 color : COLOR;
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 positionHCS : SV_POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
float4 color : COLOR;
|
|
float4 screenPosition : TEXCOORD1;
|
|
};
|
|
|
|
TEXTURE2D(_MainTex);
|
|
SAMPLER(sampler_MainTex);
|
|
float4 _MainTex_ST;
|
|
float4 _MainTex_TexelSize;
|
|
float4 _Color;
|
|
float _OverflowIntensity;
|
|
float _OverflowExposure;
|
|
float _OverflowGlow;
|
|
float _OverflowChromatic;
|
|
float _OverflowNoise;
|
|
|
|
float hash21(float2 value)
|
|
{
|
|
value = frac(value * float2(123.34, 456.21));
|
|
value += dot(value, value + 45.32);
|
|
return frac(value.x * value.y);
|
|
}
|
|
|
|
Varyings vert(Attributes input)
|
|
{
|
|
Varyings output;
|
|
output.positionHCS = TransformObjectToHClip(input.positionOS.xyz);
|
|
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
|
|
output.color = input.color * _Color;
|
|
output.screenPosition = ComputeScreenPos(output.positionHCS);
|
|
return output;
|
|
}
|
|
|
|
half4 SampleSprite(float2 uv)
|
|
{
|
|
return SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
|
|
}
|
|
|
|
half4 frag(Varyings input) : SV_Target
|
|
{
|
|
float intensity = saturate(_OverflowIntensity);
|
|
float pulse = 0.92 + sin(_Time.y * 17.0 + input.uv.y * 23.0) * 0.08;
|
|
float activeIntensity = saturate(intensity * pulse);
|
|
|
|
float2 radial = input.uv - 0.5;
|
|
float radialLength = max(length(radial), 0.001);
|
|
float2 chromaticDirection = radial / radialLength;
|
|
float chromaticOffset = _OverflowChromatic * activeIntensity;
|
|
|
|
half4 center = SampleSprite(input.uv);
|
|
half red = SampleSprite(input.uv + chromaticDirection * chromaticOffset).r;
|
|
half blue = SampleSprite(input.uv - chromaticDirection * chromaticOffset).b;
|
|
half3 chromatic = half3(red, center.g, blue);
|
|
|
|
float2 texel = _MainTex_TexelSize.xy * lerp(1.5, 7.0, activeIntensity);
|
|
half4 blur = center * 0.2;
|
|
blur += SampleSprite(input.uv + float2(texel.x, 0)) * 0.1;
|
|
blur += SampleSprite(input.uv - float2(texel.x, 0)) * 0.1;
|
|
blur += SampleSprite(input.uv + float2(0, texel.y)) * 0.1;
|
|
blur += SampleSprite(input.uv - float2(0, texel.y)) * 0.1;
|
|
blur += SampleSprite(input.uv + texel) * 0.1;
|
|
blur += SampleSprite(input.uv - texel) * 0.1;
|
|
blur += SampleSprite(input.uv + float2(texel.x, -texel.y)) * 0.1;
|
|
blur += SampleSprite(input.uv + float2(-texel.x, texel.y)) * 0.1;
|
|
|
|
half luminance = dot(chromatic, half3(0.2126, 0.7152, 0.0722));
|
|
half glowLuminance = dot(blur.rgb, half3(0.2126, 0.7152, 0.0722));
|
|
half whiteAmount = saturate(activeIntensity * (_OverflowExposure * 0.38 + luminance * 0.8));
|
|
half3 exposed = lerp(chromatic, half3(1, 1, 1), whiteAmount);
|
|
exposed += blur.rgb * glowLuminance * _OverflowGlow * activeIntensity;
|
|
|
|
float2 screenUv = input.screenPosition.xy / max(input.screenPosition.w, 0.0001);
|
|
float noiseSeed = floor(_Time.y * 24.0);
|
|
float noise = hash21(floor(screenUv * _ScreenParams.xy * 0.32) + noiseSeed);
|
|
float speck = smoothstep(0.82, 1.0, noise) * _OverflowNoise * activeIntensity;
|
|
float scan = sin((screenUv.y * _ScreenParams.y + _Time.y * 90.0) * 0.12) * 0.5 + 0.5;
|
|
exposed += speck * lerp(0.55, 1.0, scan);
|
|
|
|
half4 result;
|
|
result.rgb = exposed * input.color.rgb;
|
|
result.a = max(center.a, blur.a * activeIntensity * _OverflowGlow * 0.45) * input.color.a;
|
|
clip(result.a - 0.001);
|
|
return result;
|
|
}
|
|
ENDHLSL
|
|
|
|
Pass
|
|
{
|
|
Name "DreamDataOverflow2D"
|
|
Tags { "LightMode" = "Universal2D" }
|
|
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma target 3.0
|
|
ENDHLSL
|
|
}
|
|
|
|
Pass
|
|
{
|
|
Name "DreamDataOverflowUnlit"
|
|
Tags { "LightMode" = "SRPDefaultUnlit" }
|
|
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#pragma target 3.0
|
|
ENDHLSL
|
|
}
|
|
}
|
|
|
|
Fallback "Sprites/Default"
|
|
}
|