3layout(set = 0, binding = 1, std140) uniform SpriteExtended {
9 vec4 custom_uniforms[16];
13#define amp_high ext.audio_bands.z
14#define amp_low ext.audio_bands.x
15#define amp_mid ext.audio_bands.y
16#define amp_peak ext.u2.w
17#define amp_rms ext.u3.z
18#define amp_smooth ext.u3.w
19#define iMouse ext.mouse
20#define iResolution ext.u0.zw
22#define time_f ext.u2.y
31layout(location = 0) in vec2 tc;
32layout(set = 0, binding = 0) uniform sampler2D samp;
44const
float PI = 3.14159265358979323846;
45const
float TAU = 6.28318530717958647692;
60 float s = sin(a), c = cos(a);
61 return mat2(c, -s, s, c);
69float saturate(
float x) {
return clamp(x, 0.0, 1.0); }
75vec2
saturate(vec2 x) {
return clamp(x, 0.0, 1.0); }
81vec3
saturate(vec3 x) {
return clamp(x, 0.0, 1.0); }
89 vec3 q = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
90 q += dot(q, q.yzx + 33.33);
91 return fract((q.xx + q.yz) * q.zy);
102 vec2 u = f * f * (3.0 - 2.0 * f);
104 float b =
hash22(i + vec2(1.0, 0.0)).x;
105 float c =
hash22(i + vec2(0.0, 1.0)).x;
106 float d =
hash22(i + vec2(1.0, 1.0)).x;
107 return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
118 mat2 octave =
rot(0.53) * 2.03;
119 for (
int i = 0; i < 6; ++i) {
121 p = octave * p + vec2(17.13, 9.71);
124 return sum / 0.984375;
133 return vec2(
fbm6(p + vec2(7.1, 1.7)),
134 fbm6(
rot(1.57) * p + vec2(3.8, 11.3))) * 2.0 - 1.0;
144 return vec2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);
154 float d = max(dot(b, b), 1e-4);
155 return vec2(a.x * b.x + a.y * b.y, a.y * b.x - a.x * b.y) / d;
165 float radius = length(p);
166 float slice =
TAU / max(segments, 2.0);
167 float angle = atan(p.y, p.x);
168 angle = abs(mod(angle + 0.5 * slice, slice) - 0.5 * slice);
169 return radius * vec2(cos(angle), sin(angle));
178 return 1.0 - abs(mod(uv, 2.0) - 1.0);
188 if (p.y > p.x) p = p.yx;
189 return clamp(p, vec2(-3.0), vec2(3.0));
198float aaLine(
float distanceToLine,
float halfWidth) {
200 return 1.0 - smoothstep(halfWidth - aa, halfWidth + aa, abs(distanceToLine));
210 float wave = abs(fract(phase) - 0.5);
212 return 1.0 - smoothstep(width - aa, width + aa,
wave);
221 vec3 base = vec3(0.52, 0.48, 0.50);
222 vec3 amplitude = vec3(0.48, 0.46, 0.50);
239 float lineTrap = 10.0;
240 float pointTrap = 10.0;
242 for (
int i = 0; i < 12; ++i) {
244 z =
rot(0.37 +
SPIN_RATE * 0.17 + 0.025 * sin(t * 0.21 + fi)) * z;
245 z = abs(z) - vec2(0.42 + 0.035 * sin(fi * 1.7 + t * 0.13),
246 0.31 + 0.040 * cos(fi * 1.3 - t * 0.16));
247 float inverseRadius = clamp(dot(z, z), 0.16, 1.45);
248 z = z * (
FOLD_GAIN / inverseRadius) - vec2(0.36, 0.24);
249 z += 0.025 * audio.xy * vec2(sin(fi + t), cos(fi - t));
250 lineTrap = min(lineTrap, min(abs(z.x), abs(z.y)));
251 pointTrap = min(pointTrap, length(z - vec2(0.22, -0.18)));
252 energy += exp(-2.8 * abs(dot(z, normalize(vec2(0.8, 0.6))))) / 12.0;
254 return vec4(lineTrap, pointTrap,
energy, atan(z.y, z.x) /
TAU + 0.5);
267 vec2 texSize = max(vec2(textureSize(samp, 0)), vec2(1.0));
268 vec2 texel = 1.0 / texSize;
272 vec2 axis = normalize(direction + vec2(1e-5));
273 vec2 tangent = vec2(-axis.y, axis.x);
274 vec2 tapA = axis * texel * 0.72;
275 vec2 tapB = tangent * texel * 0.72;
276 vec3 center = textureGrad(samp, uv, gx, gy).rgb;
277 vec3 filtered = center * 0.40;
278 filtered += textureGrad(samp,
mirrorWrap(uv + tapA), gx, gy).rgb * 0.15;
279 filtered += textureGrad(samp,
mirrorWrap(uv - tapA), gx, gy).rgb * 0.15;
280 filtered += textureGrad(samp,
mirrorWrap(uv + tapB), gx, gy).rgb * 0.15;
281 filtered += textureGrad(samp,
mirrorWrap(uv - tapB), gx, gy).rgb * 0.15;
282 vec2 split = axis * texel * splitPixels;
283 float red = textureGrad(samp,
mirrorWrap(uv + split), gx, gy).r;
284 float blue = textureGrad(samp,
mirrorWrap(uv - split), gx, gy).b;
285 return mix(filtered, vec3(red, filtered.g, blue), 0.68);
298 float radius = max(length(p), 0.0015);
299 float angle = atan(p.y, p.x) +
WARP_STRENGTH / (0.18 + radius);
300 p = vec2(log(radius) * 0.72 - t * (0.08 + audio.x * 0.04),
302 for (
int i = 0; i < 9; ++i) {
304 p = abs(fract(p * (1.36 + 0.018 * fi) + 0.5) - 0.5) * 2.0 - 0.48;
306 p += 0.045 * vec2(sin(p.y * 5.0 + t + fi), cos(p.x * 4.0 - t));
308 return p * (1.25 + 0.15 * audio.w);
322vec3
remixDetail(vec2 p, vec2 original,
float t, vec4 audio, vec4 orbit) {
323 vec2 z = p * (1.28 + audio.x * 0.12);
324 vec2 c = vec2(-0.745 + 0.055 * sin(t * 0.071 +
HUE_SHIFT *
TAU),
326 float escapedAt = 40.0;
327 float circleTrap = 10.0;
328 float crossTrap = 10.0;
329 for (
int i = 0; i < 40; ++i) {
330 circleTrap = min(circleTrap, abs(length(z) - 0.52));
331 crossTrap = min(crossTrap, min(abs(z.x), abs(z.y)));
333 if (dot(z, z) > 256.0) {
334 escapedAt = float(i);
338 float smoothIteration = escapedAt;
339 if (escapedAt < 40.0) {
340 smoothIteration += 1.0 - log2(max(log2(max(dot(z, z), 2.0)), 1e-4));
342 float bands =
aaPulse(smoothIteration * 0.082 + orbit.w * 0.7 - t * 0.025, 0.16);
343 float orbitGlow = exp(-18.0 * circleTrap) + 0.55 * exp(-24.0 * crossTrap);
344 float interior = smoothstep(38.0, 40.0, smoothIteration);
355 return 1.0 - (1.0 - a) * (1.0 - b);
364 x = max(x, vec3(0.0));
365 return saturate((x * (2.51 * x + 0.03)) /
366 (x * (2.43 * x + 0.59) + 0.14));
374 float aspect = resolution.x / resolution.y;
375 vec2 aspectScale = vec2(aspect, 1.0);
376 vec4 source = texture(samp, tc);
383 vec4 audio = vec4(bass, mids, highs, peak);
386 vec2 original = (tc - center) * aspectScale;
387 float breathingZoom = 1.0 + 0.07 * sin(t * 0.19) + bass * 0.10;
388 original =
rot(t *
SPIN_RATE * 0.11) * original * breathingZoom;
391 vec4 orbit =
deepOrbit(domain, t, audio);
392 vec3 detail =
remixDetail(domain, original, t, audio, orbit);
394 float radius = length(domain);
395 float angle = atan(domain.y, domain.x);
396 float logPhase = log(radius + 0.025) * (1.7 +
WARP_STRENGTH) - t * (0.075 + bass * 0.045);
397 vec2 textureDomain =
rot(angle * 0.08 + orbit.w * 0.35) * domain;
398 textureDomain += 0.075 * vec2(sin(logPhase * 2.3 + t * 0.11),
399 cos(logPhase * 1.9 - t * 0.09));
400 vec2 warpedUV = center + textureDomain / aspectScale * (0.34 + 0.04 * sin(logPhase));
403 vec2 sampleDirection = normalize(vec2(cos(angle + orbit.w *
TAU),
404 sin(angle + orbit.w *
TAU)) + vec2(1e-5));
405 float splitPixels = 0.8 + highs * 5.5 + detail.y * 1.4;
406 vec3 warpedTexture =
sampleTextureHQ(warpedUV, sampleDirection, splitPixels);
408 float palettePhase = orbit.w + detail.x * 0.19 + detail.y * 0.13
409 + detail.z * 0.11 + logPhase * 0.075 + t * 0.018;
411 vec3 companion =
cosinePalette(palettePhase + 0.31 + orbit.z * 0.12);
413 float geometry =
saturate(0.28 + detail.x * 0.48 + detail.y * 0.30);
414 float luminosity = 0.68 + orbit.z * 0.38 + detail.z * 0.34;
415 vec3 coloredTexture = warpedTexture * mix(vec3(1.0),
palette * 1.34, 0.54 + mids * 0.14);
416 vec3 luminousLayer =
screenBlend(coloredTexture, companion * geometry * 0.82);
417 vec3
fractalColor = mix(coloredTexture, luminousLayer, 0.58 + peak * 0.18);
421 float sourceLuma = dot(source.rgb, vec3(0.2126, 0.7152, 0.0722));
424 vec3 outputColor = mix(source.rgb,
fractalColor, blendAmount);
426 vec2 vignettePoint = (tc - center) * aspectScale;
427 float vignette = 1.0 - smoothstep(0.58, 1.42, length(vignettePoint));
428 outputColor *= 0.82 + vignette * 0.18;
429 outputColor *=
EXPOSURE * (1.0 + peak * 0.24);
430 outputColor = mix(outputColor / (1.0 + outputColor),
filmicToneMap(outputColor), 0.72);
432 color = vec4(
saturate(outputColor), source.a);
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
vec3 palette(float phase)
Evaluates palette for this shader effect.
vec3 wave(ivec2 p, ivec2 size)
Evaluates wave for this shader effect.
vec2 rot(vec2 v, float a)
Evaluates rot for this shader effect.
float energy()
Evaluates energy for this shader effect.
vec2 kaleido(vec2 p, float seg)
Evaluates kaleido for this shader effect.
vec3 sampleTextureHQ(vec2 uv, vec2 direction, float splitPixels)
Evaluates sampleTextureHQ for this shader effect.
vec3 screenBlend(vec3 a, vec3 b)
Evaluates screenBlend for this shader effect.
vec2 hash22(vec2 p)
Evaluates hash22 for this shader effect.
float fbm6(vec2 p)
Evaluates fbm6 for this shader effect.
float aaPulse(float phase, float width)
Evaluates aaPulse for this shader effect.
vec2 complexDiv(vec2 a, vec2 b)
Evaluates complexDiv for this shader effect.
vec2 complexMul(vec2 a, vec2 b)
Evaluates complexMul for this shader effect.
vec3 filmicToneMap(vec3 x)
Evaluates filmicToneMap for this shader effect.
float valueNoise(vec2 p)
Evaluates valueNoise for this shader effect.
float aaLine(float distanceToLine, float halfWidth)
Evaluates aaLine for this shader effect.
float saturate(float x)
Evaluates saturate for this shader effect.
vec2 remixDomain(vec2 p, float t, vec4 audio)
Evaluates remixDomain for this shader effect.
vec3 remixDetail(vec2 p, vec2 original, float t, vec4 audio, vec4 orbit)
Evaluates remixDetail for this shader effect.
vec2 mirrorWrap(vec2 uv)
Evaluates mirrorWrap for this shader effect.
vec4 deepOrbit(vec2 seed, float t, vec4 audio)
Evaluates deepOrbit for this shader effect.
vec2 flowNoise(vec2 p)
Evaluates flowNoise for this shader effect.
vec2 boundedFold(vec2 p)
Evaluates boundedFold for this shader effect.
const float WARP_STRENGTH
vec3 cosinePalette(float x)
Evaluates cosinePalette for this shader effect.
vec4 fractalColor(vec2 uv)
Evaluates fractalColor for this shader effect.