Files
kaiju/Assets/Scenes/_Shader/EtherOrigish.shader
T

102 lines
3.0 KiB
GLSL

Shader "FullScreen/Ether"
{
Properties
{
_SpectrumTexture("SpectrumTexture", 2D) = "white" {}
_ThemeTexture("ThemeTexture", 2D) = "white" {}
_SpectrumSize("SpectrumSize", float) = 16
}
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;
// 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.5;
float magic = spectrum.y * 0.05;
float zing = spectrum.x * 0.05;
float zip = spectrum.z * 0.05;
float wow = 4.5; //lerp(4.0, 5.0, spectrum.w);
p.xz = mul(m(zing + t), p.xz);
p.xy = mul(m(magic + t), p.xy);
float3 q = p*wow + t;
return length(p +
// float3(sin(t - magic), sin(t + magic), sin(t - magic)))
float3(magic, zing, zip))
*log(length(p)+zip) + sin(q.x+sin(q.z+sin(q.y)))*0.5;
}
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);
float d = smoothstep(1.5, 3.5, sub);
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);
for(int i=0; i<=iterations; i++) {
float3 n = float3(0.,0.,str) + normalize(float3(p, -size))*d;
float rz = map(n, spectrum);
float f = clamp((rz - map(n+.1, spectrum))*0.5, -.1, 1.);
float3 l = float3(0.1,0.3,.4) + float3(5., 2.5, 3.)*f;
colour = colour*l + smoothstep(2.5, .0, rz)*.7*l;
d += 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
}