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.2126, 0.7152, 0.0722)); }
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.055;
100 float baseAmp = 0.018;
102 vec3 tx = textureGrad(samp, uv, dFdx(uv), dFdy(uv)).rgb;
103 float waveLength = baseWave * (0.9 + 0.5*
luma(tx));
104 float amplitude = baseAmp * (0.75 + 0.5*drive);
105 float ripple = sin((dist / max(waveLength,1e-4) - t * speed) * 6.2831853);
106 ripple *= smoothstep(0.95, 0.2, 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.55 + 0.5*drive) / (1.0 + 8.0*r);
125 float spin = (0.22 + 0.18*drive) * t;
127 float pull = 0.10 / (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.085*k;
150 float timeLag = 0.11*k;
151 vec2 u =
spiralTwist(uv, center, aspect, t - timeLag, drive);
152 u =
rotateUV(u, (0.12+0.04*drive)*k, center, aspect);
153 vec3 s = textureGrad(samp, fract(u / radScale), dFdx(uv), dFdy(uv)).rgb;
154 float w = 1.0 / (1.0 + 0.85*k);
158 return acc / max(wsum, 1e-6);
176 if(Y > maxY) c *= maxY/(Y+1e-6);
187 vec2 center = (
iMouse.z > 0.5) ? mouseN : (hasClick ? clickN : vec2(0.5));
190 float aMix = clamp(
amp*0.7 +
uamp*0.3, 0.0, 12.0);
191 float drive = tanh(aMix*0.07);
195 vec3 echoCol =
spiralEcho(uvRipple, center, aspect, t, drive);
199 vec2 dir = normalize(vec2(cos(a), sin(a)));
200 float span = 0.22 + 0.10*sin(
time_f*0.35);
201 vec2 startP = m - dir*span;
202 vec2 endP = m + dir*span;
203 vec2 ab = endP - startP;
204 float L = max(length(ab), 1e-4);
206 float gradT = clamp(dot(tc - startP, u) / L, 0.0, 1.0);
209 vec3 grad = mix(c0, c1, gradT);
211 vec3 tex = textureGrad(samp, uvRipple, dFdx(uvRipple), dFdy(uvRipple)).rgb;
212 vec3 mixed = mix(tex, echoCol, 0.6);
213 float colorMix = 0.55*clamp(
amp, 0.0, 1.0);
214 mixed = mix(mixed, mixed * grad, colorMix);
216 float satAmt = 1.08 + 0.18*drive;
217 float Y =
luma(mixed);
218 mixed = mix(vec3(Y), mixed, satAmt);
220 mixed *= 1.08 + 0.15*drive;
223 mixed = pow(clamp(mixed,0.0,1.0), vec3(0.95));
225 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.
vec3 reinhard(vec3 x)
Evaluates reinhard for this shader effect.
vec3 softLimit(vec3 c, float maxY)
Evaluates softLimit for this shader effect.
vec2 spin(vec2 p, float a)
Evaluates spin for this shader effect.