7layout(set = 0, binding = 1, std140) uniform SpriteExtended {
13 vec4 custom_uniforms[16];
18#define iFrame int(ext.u2.x)
19#define iMouse ext.mouse
20#define iMouseClick ext.mouse.xy
21#define iResolution ext.u0.zw
22#define iSampleRate ext.u2.z
24#define time_f ext.u2.y
28layout(location = 0) in vec2 tc;
29layout(set = 0, binding = 0) uniform sampler2D samp;
40const
float PI = 3.1415926535897932384626433832795;
49 float m = mod(x, length*2.0);
50 return m <= length ? m : length*2.0 - m;
58float luma(vec3 c){
return dot(c, vec3(0.299, 0.587, 0.114)); }
66 return clamp(vec3(abs(t*6.0-3.0)-1.0, 2.0-abs(t*6.0-2.0), 2.0-abs(t*6.0-4.0)),0.0,1.0);
77vec2
rotateUV(vec2 uv,
float angle, vec2 c,
float aspect){
78 float s = sin(angle), cc = cos(angle);
81 p = mat2(cc, -s, s, cc) * p;
95vec2
rippleDisplace(vec2 uv, vec2 center,
float aspect,
float t,
float drive){
97 float dist = length(d);
98 vec2 dir = d / max(dist, 1e-6);
99 float baseWave = 0.05;
100 float baseAmp = 0.02;
102 float texLum =
luma(texture(samp, uv).rgb);
103 float waveLength = baseWave * (0.8 + 0.6*texLum);
104 float amplitude = baseAmp * (0.7 + 0.8*drive);
105 float ripple = sin((dist / max(waveLength,1e-4) - t * speed) * 6.2831853);
106 ripple *= smoothstep(0.95, 0.15, dist);
107 return uv + dir *
ripple * amplitude;
119vec2
spiralTwist(vec2 uv, vec2 center,
float aspect,
float t,
float drive){
120 vec2 p = uv - center;
122 float r = length(p)+1e-6;
123 float a = atan(p.y, p.x);
124 float swirl = (0.7 + 0.6*drive) / (1.0 + 8.0*r);
125 float spin = (0.35 + 0.25*drive) * t;
127 float pull = 0.12 / (1.0 + 6.0*r);
128 r = max(r - pull, 0.0);
129 vec2 q = vec2(cos(a), sin(a)) * r;
143vec3
spiralEcho(vec2 uv, vec2 center,
float aspect,
float t,
float drive){
145 vec3 acc = vec3(0.0);
147 for(
int i=0;i<TAPS;i++){
149 float radScale = 1.0 + 0.09*k;
150 float timeLag = 0.1*k;
151 vec2 u =
spiralTwist(uv, center, aspect, t - timeLag, drive);
152 u =
rotateUV(u, (0.15+0.05*drive)*k, center, aspect);
153 vec3 s = texture(samp, fract(u / radScale)).rgb;
154 float w = 1.0 / (1.0 + 0.8*k);
158 return acc / max(wsum, 1e-6);
168 vec2 center = (
iMouse.z > 0.5) ? mouseN : (hasClick ? clickN : vec2(0.5));
170 float aMix = clamp(
amp*0.7 +
uamp*0.3, 0.0, 20.0);
171 float drive = clamp(aMix*0.10, 0.0, 3.0);
174 vec3 echoCol =
spiralEcho(uvRipple, center, aspect, t, drive);
177 vec2 dir = normalize(vec2(cos(a), sin(a)));
178 float span = 0.25 + 0.15*sin(
time_f*0.7);
179 vec2 startP = m - dir*span;
180 vec2 endP = m + dir*span;
181 vec2 ab = endP - startP;
182 float L = max(length(ab), 1e-4);
184 float gradT = clamp(dot(tc - startP, u) / L, 0.0, 1.0);
187 vec3 grad = mix(c0, c1, gradT);
188 vec3 tex = texture(samp, uvRipple).rgb;
189 vec3 mixed = mix(tex, echoCol, 0.6);
190 mixed = mix(mixed, mixed * grad, clamp(
amp, 0.0, 1.0));
191 mixed = pow(abs(sin(mixed * (1.5 + 0.5*
uamp))), vec3(1.0));
192 mixed = clamp(mixed * (1.3 + 0.3*drive), 0.0, 1.0);
193 color = vec4(mixed, 1.0);
layout(set=0, binding=1, std140) uniform SpriteExtended
void main(void)
Executes the fragment shader entry point.
vec3 ripple(ivec2 p, ivec2 size)
Evaluates ripple for this shader effect.
float pingPong(float x, float length)
Evaluates pingPong 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 rippleDisplace(vec2 uv, vec2 center, float aspect, float t, float drive)
Evaluates rippleDisplace for this shader effect.
vec3 hue(float t)
Evaluates hue for this shader effect.
vec2 spiralTwist(vec2 uv, vec2 center, float aspect, float t, float drive)
Evaluates spiralTwist for this shader effect.
float luma(vec3 c)
Evaluates luma for this shader effect.
vec3 spiralEcho(vec2 uv, vec2 center, float aspect, float t, float drive)
Evaluates spiralEcho for this shader effect.
vec2 spin(vec2 p, float a)
Evaluates spin for this shader effect.