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;
52const float PI = 3.14159265359;
61 if (i == 0)
return texture(spectrum0, f).r;
78 if (i == 0)
return texture(samp, uv);
96 return 0.5 + 0.5 * cos(
TAU * (vec3(1.0, 1.0, 1.0) * t + d));
105 return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
114 for (
int i = 0; i < 8; i++) {
125 vec2 uv = (tc - 0.5) * vec2(aspect, 1.0);
126 float bass = texture(spectrum0, 0.03).r;
127 float mid = texture(spectrum0, 0.22).r;
128 float treble = texture(spectrum0, 0.58).r;
129 float air = texture(spectrum0, 0.85).r;
132 vec3 acc = vec3(0.0);
133 for (
int i = 0; i < 8; i++) {
134 float h =
specHist(i, 0.1 +
float(i) * 0.06);
136 for (
int j = 0; j < 3; j++) {
137 float fj = float(j) + float(i) * 0.3;
138 p += 0.04 * vec2(sin(p.y * (5.0 +
h * 20.0) +
iTime + fj),
139 cos(p.x * (4.0 +
h * 18.0) -
iTime + fj));
141 float caustic = pow(max(sin(p.x * 10.0) + sin(p.y * 11.0) + sin((p.x + p.y) * 9.0), 0.0), 3.0);
142 vec2 suv = p / vec2(aspect, 1.0) + 0.5;
144 vec3 tint =
palette(
float(i) * 0.13 +
h * 2.0, vec3(0.0, 0.4, 0.7));
145 acc += (tint *
caustic + c * 0.5) * (1.0 +
h * 5.0) * pow(0.83,
float(i));
149 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)
float hash(vec2 p)
Evaluates hash 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.
float energy()
Evaluates energy for this shader effect.
float h(vec2 p)
Evaluates h for this shader effect.
float caustic(vec2 p)
Evaluates caustic for this shader effect.