106 lines
3.2 KiB
GLSL
106 lines
3.2 KiB
GLSL
Shader "FullScreen/Ether"
|
|
{
|
|
Properties
|
|
{
|
|
_SpectrumTexture("SpectrumTexture", 2D) = "white" {}
|
|
_ThemeTexture("ThemeTexture", 2D) = "white" {}
|
|
_SpectrumSize("SpectrumSize", float) = 16
|
|
|
|
_Zoom("Zoom", range(-2, 2)) = 0.5
|
|
_Wildness("Wildness", range(1, 10)) = 4.0
|
|
_Brightness("Brightness", range(1, 10)) = 4.0
|
|
}
|
|
|
|
HLSLINCLUDE
|
|
|
|
// HDRP stuff
|
|
#pragma vertex Vert
|
|
#pragma target 4.5
|
|
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl"
|
|
|
|
// here we go...
|
|
sampler2D _SpectrumTexture;
|
|
sampler2D _ThemeTexture;
|
|
float _Zoom;
|
|
float _Wildness;
|
|
float _Brightness;
|
|
|
|
// matrix fn
|
|
float2x2 m(float a) {
|
|
float c=cos(a), s=sin(a);
|
|
float2x2 mat = { c, -s, s, c };
|
|
return mat;
|
|
}
|
|
|
|
float map(float3 p, float4 spectrum) {
|
|
float t = _Time.y * 0.2;
|
|
p.xz = mul(m(t), p.xz);
|
|
p.xy = mul(m(t), p.xy);
|
|
float3 q = p*_Wildness;
|
|
return length(p +
|
|
float3(sin(t), sin(t), sin(t)))
|
|
*log(length(p)+_Zoom) + sin(q.x+sin(q.z+sin(q.y))) * spectrum.x;
|
|
}
|
|
|
|
float4 FullScreenPass(Varyings varyings) : SV_Target {
|
|
float depth = LoadCameraDepth(varyings.positionCS.xy);
|
|
PositionInputs posInput = GetPositionInput(varyings.positionCS.xy, _ScreenSize.zw, depth, UNITY_MATRIX_I_VP, UNITY_MATRIX_V);
|
|
|
|
// musique
|
|
float sub = tex2D(_SpectrumTexture, 0.0);
|
|
float bass = tex2D(_SpectrumTexture, 0.25);
|
|
float mids = tex2D(_SpectrumTexture, 0.50);
|
|
float highs = tex2D(_SpectrumTexture, 0.75);
|
|
float4 spectrum = float4(sub, bass, mids, highs);
|
|
|
|
// screen
|
|
float2 p = posInput.positionNDC - .5;
|
|
p.x *= _ScreenParams.x / _ScreenParams.y;
|
|
|
|
float t = _Time.y;
|
|
|
|
// float3 colour = float3(0.0, 0.0, 0.0);
|
|
float3 colour = float3(0.0, 0.0, 0.0);
|
|
float damage = smoothstep(1.5, 3.5, highs);
|
|
float iterations = 10.0;
|
|
// float iterations = lerp(10.0, 50.0, highs);
|
|
float str = 4.5; // lerp(4.9, 5.0, highs);
|
|
float size = 1.0; //lerp(0.5, 2.0, mids);
|
|
|
|
float3 theme = tex2D(_ThemeTexture, length(p)) * _Brightness;
|
|
|
|
for(int i=0; i<=iterations; i++) {
|
|
float3 n = float3(0.,0.,str) + normalize(float3(p, -size))*damage;
|
|
float rz = map(n, spectrum);
|
|
float f = clamp((rz - map(n+.1, spectrum)), 0., 1.);
|
|
float3 l = float3(0.01, 0.01, 0.01) * f + theme * f;
|
|
colour = colour*l + smoothstep(2.5, .0, rz)*.7*l;
|
|
damage += min(rz, 1.);
|
|
}
|
|
|
|
return float4(colour, 1.);
|
|
}
|
|
|
|
ENDHLSL
|
|
|
|
SubShader
|
|
{
|
|
Tags{ "RenderPipeline" = "HDRenderPipeline" }
|
|
Pass
|
|
{
|
|
Name "Custom Pass 0"
|
|
|
|
ZWrite Off
|
|
ZTest Always
|
|
// Blend SrcAlpha OneMinusSrcAlpha
|
|
Cull Off
|
|
|
|
HLSLPROGRAM
|
|
#pragma fragment FullScreenPass
|
|
ENDHLSL
|
|
}
|
|
}
|
|
Fallback Off
|
|
}
|