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 vec2 pole = 0.32 * vec2(cos(t * 0.17), sin(t * 0.13));
299 vec2 numerator =
complexMul(p + vec2(0.18, -0.11), p - vec2(0.21, 0.16));
301 p *= 0.42 + 0.05 * audio.x;
302 for (
int i = 0; i < 9; ++i) {
305 p = abs(p) - vec2(0.41, 0.27 + 0.02 * sin(fi + t * 0.2));
306 float radius2 = clamp(dot(p, p), 0.14, 1.32);
307 p *= (1.06 +
FOLD_GAIN * 0.23) / radius2;
308 p -= vec2(0.47, 0.31);
323vec3
remixDetail(vec2 p, vec2 original,
float t, vec4 audio, vec4 orbit) {
325 float diamondTrap = 10.0;
326 float crossTrap = 10.0;
328 for (
int i = 0; i < 12; ++i) {
331 z *= 1.18 + 0.025 * sin(t * 0.3 + fi);
332 diamondTrap = min(diamondTrap, abs(z.x) + abs(z.y));
333 crossTrap = min(crossTrap, min(abs(z.x), abs(z.y)));
334 glow += exp(-8.0 * abs(length(z) - 0.44)) / 12.0;
336 float crystal =
aaLine(crossTrap - 0.025, 0.018 + audio.z * 0.012);
337 float facets =
aaPulse(diamondTrap * 3.7 + orbit.w * 2.0 - t * 0.08, 0.12);
348 return 1.0 - (1.0 - a) * (1.0 - b);
357 x = max(x, vec3(0.0));
358 return saturate((x * (2.51 * x + 0.03)) /
359 (x * (2.43 * x + 0.59) + 0.14));
367 float aspect = resolution.x / resolution.y;
368 vec2 aspectScale = vec2(aspect, 1.0);
369 vec4 source = texture(samp, tc);
376 vec4 audio = vec4(bass, mids, highs, peak);
379 vec2 original = (tc - center) * aspectScale;
380 float breathingZoom = 1.0 + 0.07 * sin(t * 0.19) + bass * 0.10;
381 original =
rot(t *
SPIN_RATE * 0.11) * original * breathingZoom;
384 vec4 orbit =
deepOrbit(domain, t, audio);
385 vec3 detail =
remixDetail(domain, original, t, audio, orbit);
387 float radius = length(domain);
388 float angle = atan(domain.y, domain.x);
389 float logPhase = log(radius + 0.025) * (1.7 +
WARP_STRENGTH) - t * (0.075 + bass * 0.045);
390 vec2 textureDomain =
rot(angle * 0.08 + orbit.w * 0.35) * domain;
391 textureDomain += 0.075 * vec2(sin(logPhase * 2.3 + t * 0.11),
392 cos(logPhase * 1.9 - t * 0.09));
393 vec2 warpedUV = center + textureDomain / aspectScale * (0.34 + 0.04 * sin(logPhase));
396 vec2 sampleDirection = normalize(vec2(cos(angle + orbit.w *
TAU),
397 sin(angle + orbit.w *
TAU)) + vec2(1e-5));
398 float splitPixels = 0.8 + highs * 5.5 + detail.y * 1.4;
399 vec3 warpedTexture =
sampleTextureHQ(warpedUV, sampleDirection, splitPixels);
401 float palettePhase = orbit.w + detail.x * 0.19 + detail.y * 0.13
402 + detail.z * 0.11 + logPhase * 0.075 + t * 0.018;
404 vec3 companion =
cosinePalette(palettePhase + 0.31 + orbit.z * 0.12);
406 float geometry =
saturate(0.28 + detail.x * 0.48 + detail.y * 0.30);
407 float luminosity = 0.68 + orbit.z * 0.38 + detail.z * 0.34;
408 vec3 coloredTexture = warpedTexture * mix(vec3(1.0),
palette * 1.34, 0.54 + mids * 0.14);
409 vec3 luminousLayer =
screenBlend(coloredTexture, companion * geometry * 0.82);
410 vec3
fractalColor = mix(coloredTexture, luminousLayer, 0.58 + peak * 0.18);
414 float sourceLuma = dot(source.rgb, vec3(0.2126, 0.7152, 0.0722));
417 vec3 outputColor = mix(source.rgb,
fractalColor, blendAmount);
419 vec2 vignettePoint = (tc - center) * aspectScale;
420 float vignette = 1.0 - smoothstep(0.58, 1.42, length(vignettePoint));
421 outputColor *= 0.82 + vignette * 0.18;
422 outputColor *=
EXPOSURE * (1.0 + peak * 0.24);
423 outputColor = mix(outputColor / (1.0 + outputColor),
filmicToneMap(outputColor), 0.72);
425 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.
vec3 crystal(float t)
Evaluates crystal 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.