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
17#define spectrum_history_head int(ext.audio_history.x)
18#define spectrum_history_size int(ext.audio_history.y)
19#define time_f ext.u2.y
33layout(location = 0) out vec4 color;
34layout(set = 0, binding = 0) uniform sampler2D samp;
35layout(set = 0, binding = 2) uniform sampler2DArray history;
40#ifndef CACHE_HISTORY_LAYER
41#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
43layout(set = 0, binding = 3) uniform sampler1D spectrum0;
44layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
47#ifndef SPECTRUM_HISTORY_LAYER
48#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
55const float TAU = 6.28318530718;
65 if (j == 0)
return texture(spectrum0, f).r;
81vec2
rot(vec2 p,
float a) {
82 float c = cos(a);
float s = sin(a);
83 return vec2(c * p.x - s * p.y, s * p.x + c * p.y);
92 p = fract(p * vec2(123.34, 456.21));
93 p += dot(p, p + 45.32);
94 return fract(p.x * p.y);
106vec3
palette(
float t, vec3 a, vec3 b, vec3 c, vec3 d) {
107 return a + b * cos(
TAU * (c * t + d));
123vec2
styleDrift(vec2 uv,
float layer,
float age,
float hB,
float hM,
float hT,
float hA, vec3 oldest) {
124 float r = length(uv) + 1e-3;
125 float ang = atan(uv.y, uv.x);
127 vec2 q = vec2(cos(ang +
twist), sin(ang +
twist)) * r;
128 return (q - uv) * 0.10;
141vec3
styleColor(vec3 cached,
float layer,
float age,
float hB,
float hT) {
142 return cached * (0.92 + 0.12 * sin(layer * 0.5 + hT * 4.0));
151 vec2 uv = (tc - 0.5) * vec2(aspect, 1.0);
153 float bass = texture(spectrum0, 0.03).r;
154 float mid = texture(spectrum0, 0.18).r;
155 float treble = texture(spectrum0, 0.52).r;
156 float air = texture(spectrum0, 0.86).r;
158 float histBass = 0.0;
160 float histTreble = 0.0;
162 for (
int i = 0; i < 8; ++i) {
168 histBass /= 8.0; histMid /= 8.0; histTreble /= 8.0; histAir /= 8.0;
172 vec3 live = texture(samp, tc +
styleDrift(uv, 0.0, 0.0, bass, mid, treble, air, oldest)).rgb;
175 float decay = mix(0.81, 0.94, clamp(
float(
SIZE - 8) / 24.0, 0.0, 1.0));
179 for (
int i = 0; i <
SIZE; ++i) {
180 float layer = float(i + 1);
181 float age = layer / float(
SIZE);
187 vec2 drift =
styleDrift(uv, layer, age, hB, hM, hT, hA, oldest);
189 cached =
styleColor(cached, layer, age, hB, hT);
191 float w = pow(decay, layer) * (1.0 + hT * 0.9 + hA * 0.3);
200 color = vec4(clamp(accum, 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 rot(vec2 v, float a)
Evaluates rot for this shader effect.
float specHist(int i, float f)
Evaluates specHist for this shader effect.
vec2 styleDrift(vec2 uv, float layer, float age, float hB, float hM, float hT, float hA, vec3 oldest)
Evaluates styleDrift for this shader effect.
float hash12(vec2 p)
Evaluates hash12 for this shader effect.
vec3 styleColor(vec3 cached, float layer, float age, float hB, float hT)
Evaluates styleColor for this shader effect.
vec2 twist(vec2 coord, float twistAmount, float time, float direction)
Evaluates twist for this shader effect.