3layout(set = 0, binding = 1, std140) uniform SpriteExtended {
9 vec4 custom_uniforms[16];
13#define amp_peak ext.u2.w
14#define amp_smooth ext.u3.w
15#define history_head int(ext.u3.x)
16#define iResolution ext.u0.zw
18#define spectrum_history_head int(ext.audio_history.x)
19#define spectrum_history_size int(ext.audio_history.y)
29layout(location = 0) out vec4 color;
30layout(set = 0, binding = 0) uniform sampler2D samp;
31layout(set = 0, binding = 2) uniform sampler2DArray history;
36#ifndef CACHE_HISTORY_LAYER
37#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
39layout(set = 0, binding = 3) uniform sampler1D spectrum0;
40layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
43#ifndef SPECTRUM_HISTORY_LAYER
44#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
51const float TAU = 6.28318530718;
60 if (i == 0)
return texture(spectrum0, f).r;
77 if (i == 0)
return texture(samp, uv);
95 return 0.5 + 0.5 * cos(
TAU * (vec3(1.0) * t + d));
103mat2
rot(
float a) {
float c = cos(a), s = sin(a);
return mat2(c, -s, s, c); }
109vec2
mir(vec2 v) {
return abs(mod(v, 2.0) - 1.0); }
116 vec2 uv = (tc - 0.5) * vec2(aspect, 1.0);
118 vec3 acc = vec3(0.0);
119 for (
int i = 0; i < 8; i++) {
120 float h =
specHist(i, 0.05 +
float(i) * 0.06);
125 vec2 sectionSize = vec2(120.0 -
float(i) * 10.0);
126 vec2 sIdx = floor(px / sectionSize);
127 vec2 lUV = mod(px, sectionSize) / sectionSize;
128 float ang =
iTime * (0.3 +
h * 1.5) + length(sIdx) * (0.4 +
h2 * 0.6) +
float(i) * 0.5;
129 lUV =
rot(ang) * (lUV - 0.5) + 0.5;
131 vec2 suv = (sIdx + lUV) * sectionSize /
iResolution.xy;
134 float fAng = float(i) * 0.4 +
h2 * 3.0;
135 vec2 dir = vec2(cos(fAng), sin(fAng));
136 float fringe = sin(dot(uv, dir) * (40.0 +
h * 80.0) +
iTime * (1.0 +
h * 4.0));
137 fringe = pow(fringe * 0.5 + 0.5, 4.0);
138 suv += dir * fringe * 0.03 * (1.0 +
h);
141 c.r =
cacheHist(i, suv + vec2(
h * 0.06, 0.0)).r;
143 c.b =
cacheHist(i, suv - vec2(
h * 0.06, 0.0)).b;
145 vec3 tint =
palette(
float(i) * 0.13 +
h * 4.0, vec3(0.0, 0.33, 0.66));
146 acc += (c + tint * fringe * 0.5) * (1.0 +
h * 5.0) * pow(0.83,
float(i));
150 color = vec4(clamp(acc, 0.0, 1.0), 1.0);
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
#define CACHE_HISTORY_LAYER(index)
vec3 palette(float phase)
Evaluates palette for this shader effect.
#define SPECTRUM_HISTORY_LAYER(index)
vec2 h2(vec2 p)
Evaluates h2 for this shader effect.
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
float specHist(int i, float f)
Evaluates specHist for this shader effect.
vec4 cacheHist(int i, vec2 uv)
Evaluates cacheHist for this shader effect.
vec2 mir(vec2 v)
Evaluates mir for this shader effect.
float h(vec2 p)
Evaluates h for this shader effect.