7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
13 vec4 custom_uniforms[16];
17#define iMouse ext.mouse
18#define iResolution ext.u0.zw
19#define time_f ext.u2.y
22layout(location = 0) in vec2 tc;
23layout(set = 0, binding = 0) uniform sampler2D samp;
35 float m = mod(x, length * 2.0);
36 return m <= length ? m : length * 2.0 - m;
44float h1(
float n){
return fract(sin(
n)*43758.5453123);}
50vec2
h2(
float n){
return fract(sin(vec2(
n,
n+1.0))*vec2(43758.5453,22578.1459));}
60vec2
rotateUV(vec2 uv,
float a, vec2 c,
float aspect) {
61 float s = sin(a), cv = cos(a);
64 p = mat2(cv, -s, s, cv) * p;
77vec2
reflectUV(vec2 uv,
float segments, vec2 c,
float aspect) {
80 float ang = atan(p.y, p.x);
82 float seg = 6.28318530718 / segments;
84 ang = abs(ang - seg * 0.5);
85 vec2 q = vec2(cos(ang), sin(ang)) * r;
98 vec2 p = (uv - c) *
tiles;
99 p = abs(fract(p) * 2.0 - 1.0);
100 return p /
tiles + c;
111vec2
swirl(vec2 uv, vec2 c,
float aspect,
float k) {
114 float r = length(p) + 1e-6;
115 float a = atan(p.y, p.x) + k * r;
116 vec2 q = vec2(cos(a), sin(a)) * r;
130vec2
fractalZoom(vec2 uv,
float zoom,
float t, vec2 c,
float aspect) {
132 for (
int i = 0; i < 5; i++) {
133 p = abs((p - c) * zoom) - 0.5 + c;
134 p =
rotateUV(p, t * 0.1, c, aspect);
148 float modef = mod(floor(t * 0.1666667), 4.0);
149 int mode = int(modef);
150 float seed = floor(t * 0.1666667);
151 float seg = 4.0 + floor(
h1(
seed) * 8.0);
153 float k = (
h1(
seed + 7.7) * 2.0 - 1.0) * (0.6 + 0.6 * sin(t * 0.37));
154 float zoom = 1.3 + 0.6 * sin(t * 0.5 +
h1(
seed + 1.7) * 6.2831853);
157 if (mode == 0) duv =
reflectUV(uv, seg, m, aspect);
159 if (mode == 2) duv =
swirl(uv, m, aspect, k * 6.0);
160 if (mode == 3) duv =
fractalZoom(uv, zoom, t, m, aspect);
163 float dist = length(d);
165 float w = 1.0 - smoothstep(0.0, r, dist);
166 vec2
warp = normalize(d + 1e-5) * sin(dist * (18.0 + seg) - t * (2.0 +
h1(
seed)*3.0)) * 0.12 * w;
169 duv = vec2(
pingPong(duv.x + 0.05 * sin(t), 1.0),
pingPong(duv.y + 0.05 * cos(t), 1.0));
171 vec4 base = texture(samp, uv);
172 vec4 fx = texture(samp, duv);
173 float blend = 0.45 + 0.25 * sin(t * 0.8);
174 vec4 mixedCol = mix(base, fx, blend);
176 mixedCol.rgb *= 0.5 + 0.5 * sin(duv.xyx * (2.0 + seg * 0.1) + t);
178 vec4 c1 = sin(mixedCol *
pingPong(t, 10.0));
179 vec4 t0 = texture(samp, tc);
180 vec4 c2 = sin(c1 * t0 * 0.8 *
pingPong(t, 15.0));
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
float pingPong(float x, float length)
Evaluates pingPong for this shader effect.
vec2 h2(vec2 p)
Evaluates h2 for this shader effect.
float h1(float n)
Evaluates h1 for this shader effect.
vec2 swirl(vec2 uv, float centerRadius, float swirlAmount)
Evaluates swirl for this shader effect.
vec2 rotateUV(vec2 uv, float angle, vec2 c, float aspect)
Evaluates rotateUV for this shader effect.
vec2 reflectUV(vec2 uv, float segments, vec2 c, float aspect)
Evaluates reflectUV for this shader effect.
float n(vec2 p)
Evaluates n for this shader effect.
vec2 warp(vec2 p, vec2 o, float k)
Evaluates warp for this shader effect.
vec2 fractalZoom(vec2 uv, float zoom, float time, vec2 center)
Evaluates fractalZoom for this shader effect.
vec2 tileMirror(vec2 uv, float tiles, vec2 c)
Evaluates tileMirror for this shader effect.