7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
13 vec4 custom_uniforms[16];
18#define amp_peak ext.u2.w
19#define amp_smooth ext.u3.w
20#define history_head int(ext.u3.x)
21#define iMouse ext.mouse
22#define iResolution ext.u0.zw
24#define spectrum_history_head int(ext.audio_history.x)
25#define spectrum_history_size int(ext.audio_history.y)
26#define time_f ext.u2.y
31layout(location = 0) out vec4 color;
32layout(set = 0, binding = 0) uniform sampler2D samp;
33layout(set = 0, binding = 2) uniform sampler2DArray history;
38#ifndef CACHE_HISTORY_LAYER
39#define CACHE_HISTORY_LAYER(index) ((history_head + (index)) % SIZE)
41layout(set = 0, binding = 3) uniform sampler1D spectrum0;
42layout(set = 0, binding = 4) uniform sampler1DArray spectrum_history;
45#ifndef SPECTRUM_HISTORY_LAYER
46#define SPECTRUM_HISTORY_LAYER(index) ((spectrum_history_head - ((index) % max(spectrum_history_size, 1)) + max(spectrum_history_size, 1)) % max(spectrum_history_size, 1))
56const float TAU = 6.28318530718;
76 return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
85 return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453123);
95 vec2 local = fract(p);
96 local = local * local * (3.0 - 2.0 * local);
109 mat2 basis = mat2(0.80, -0.60, 0.60, 0.80);
110 for (
int octave = 0; octave < 5; ++octave) {
112 p = basis * p * 2.04 + vec2(1.8, 2.4);
125 float cosine = cos(angle);
126 float sine = sin(angle);
127 return mat2(cosine, -sine, sine, cosine) * p;
136 return 1.0 - abs(mod(uv, 2.0) - 1.0);
147vec2
kaleidoUV(vec2 uv,
float segments, vec2 center,
float aspect) {
148 vec2 p = (uv - center) * vec2(aspect, 1.0);
149 float angle = atan(p.y, p.x);
150 float radius = length(p);
151 float sector =
TAU / segments;
152 angle = abs(mod(angle + sector * 0.5, sector) - sector * 0.5);
153 vec2 folded = vec2(cos(angle), sin(angle)) * radius;
154 return folded / vec2(aspect, 1.0) + center;
168 for (
int iteration = 0; iteration < 5; ++iteration) {
169 float fi = float(iteration);
170 p = abs((p - center) * (zoom + fi * 0.035)) - 0.5 + center;
171 vec2 scaled = (p - center) * vec2(aspect, 1.0);
173 p = scaled / vec2(aspect, 1.0) + center;
184 vec3
wave = 0.5 + 0.5 * cos(
TAU * (phase +
HUE_OFFSET + vec3(0.00, 0.31, 0.67)));
185 return clamp((
wave - 0.08) * 1.18, 0.0, 1.0);
194 value = max(value, 0.0);
195 return clamp((value * (2.51 * value + 0.03)) / (value * (2.43 * value + 0.59) + 0.14), 0.0,
266 vec2 grid = p * (5.0 + band.y * 4.0);
267 vec2
id = floor(grid);
268 vec2 local = fract(grid);
271 vec2 direction = vec2(0.0);
272 for (
int y = -1; y <= 1; ++y) {
273 for (
int x = -1; x <= 1; ++x) {
274 vec2 neighbor = vec2(
float(x),
float(y));
275 vec2 point = 0.5 + 0.38 * sin(
TAU *
hash22(
id + neighbor) + t * 0.16 + age);
276 vec2 delta = neighbor + point - local;
277 float distanceToPoint = length(delta);
278 if (distanceToPoint < nearest) {
280 nearest = distanceToPoint;
282 }
else if (distanceToPoint < second) {
283 second = distanceToPoint;
287 float edge = exp(-(second - nearest) * (20.0 + band.z * 36.0));
288 float star = exp(-nearest * (14.0 + band.w * 24.0));
289 return vec3(edge * 0.75 + star * 0.35, normalize(direction + vec2(0.001)) * edge);
297 vec2 aspectScale = vec2(aspect, 1.0);
299 vec2 center = vec2(0.5) + (mouseCenter - 0.5) * (0.7 +
amp * 0.25);
300 vec2 p = (tc - center) * aspectScale;
301 vec3 live = texture(samp, tc).rgb;
303 vec3 accumulation = live * 0.28;
304 float totalWeight = 0.28;
307 float temporalChange = length(newest - oldest);
309 for (
int index = 0; index < 8; ++index) {
310 float age = float(index);
314 vec2 flow = clamp(
field.yz, vec2(-2.0), vec2(2.0));
316 float segmentCount =
SEGMENTS + 2.0 * floor(bands.z * 4.0);
317 vec2 historyUV =
kaleidoUV(tc, segmentCount, center, aspect);
319 1.28 + bands.x * 0.42 +
energy * 0.08 + 0.08 * sin(
clockTime() * 0.22 - age * 0.18);
322 historyUV += flow / aspectScale * (0.006 + bands.z * 0.018) *
INTENSITY;
325 vec3 cached =
cacheFrame(index, historyUV).rgb;
327 float emission = pow(clamp(
energy, 0.0, 1.0), 2.3);
328 vec3 layer = mix(cached, cached * tint * 1.32, 0.50);
329 layer += tint * emission * (0.16 + bands.z * 0.72);
331 float weight = pow(
PERSISTENCE, age + 1.0) * (0.52 + bands.x * 0.76 + bands.y * 0.38);
332 accumulation += layer * weight;
333 totalWeight += weight;
336 vec3 result = accumulation / max(totalWeight, 0.001);
337 vec3 currentField =
skyField(p, 0.0, newest);
338 float currentEnergy = clamp(abs(currentField.x), 0.0, 1.5);
341 float crown = pow(clamp(currentEnergy, 0.0, 1.0), 2.6);
342 float edge = fwidth(currentField.x);
344 result = 1.0 - (1.0 - result) * (1.0 - clamp(energyColor * crown * 0.48, 0.0, 0.88));
345 result += energyColor * edge * (1.8 + newest.w * 3.2);
346 result *= 1.0 + clamp(
amp_smooth +
amp * 0.25, 0.0, 1.5) * 0.24;
350 smoothstep(0.72, 0.98,
amp_peak) * smoothstep(0.06, 0.50, temporalChange) * 0.68;
351 vec3 inverted = mix(vec3(1.0) - result, (vec3(1.0) - result).gbr, 0.26);
352 result = mix(result, inverted, inversion);
353 color = vec4(clamp(result, 0.0, 1.0), texture(samp, tc).a);
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
float fbm(vec2 point)
Evaluates fbm for this shader effect.
#define CACHE_HISTORY_LAYER(index)
#define SPECTRUM_HISTORY_LAYER(index)
vec3 wave(ivec2 p, ivec2 size)
Evaluates wave for this shader effect.
float energy()
Evaluates energy for this shader effect.
vec2 mirrorUV(vec2 uv)
Evaluates mirrorUV for this shader effect.
vec2 hash22(vec2 p)
Evaluates hash22 for this shader effect.
float hash21(vec2 p)
Evaluates hash21 for this shader effect.
float field(vec2 p, float tm)
Evaluates field for this shader effect.
float noise21(vec2 p)
Evaluates noise21 for this shader effect.
vec2 cell(vec2 p)
Evaluates cell for this shader effect.
vec3 skyPalette(float phase)
Evaluates skyPalette for this shader effect.
vec4 historyBands(int index)
Evaluates historyBands for this shader effect.
vec4 cacheFrame(int index, vec2 uv)
Evaluates cacheFrame for this shader effect.
vec2 rotate2(vec2 p, float angle)
Evaluates rotate2 for this shader effect.
vec2 fractalSkyFold(vec2 uv, float zoom, float rotation, vec2 center, float aspect)
Evaluates fractalSkyFold for this shader effect.
float spectrumHistory(int index, float frequency)
Evaluates spectrumHistory for this shader effect.
vec2 kaleidoUV(vec2 uv, float segments, vec2 center, float aspect)
Evaluates kaleidoUV for this shader effect.
vec3 toneMap(vec3 value)
Evaluates toneMap for this shader effect.
vec3 skyField(vec2 p, float age, vec4 band)
Evaluates skyField for this shader effect.
float clockTime()
Evaluates clockTime for this shader effect.
mat2 rotation(float angle)
Evaluates rotation for this shader effect.