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;
47 float m = mod(x, length*2.0);
48 return m <= length ? m : length*2.0 - m;
56float luma(vec3 c){
return dot(c, vec3(0.2126, 0.7152, 0.0722)); }
64 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);
75vec2
rotateUV(vec2 uv,
float angle, vec2 c,
float aspect){
76 float s = sin(angle), cc = cos(angle);
79 p = mat2(cc, -s, s, cc) * p;
93vec2
rippleDisplace(vec2 uv, vec2 center,
float aspect,
float t,
float drive){
95 float dist = length(d);
96 vec2 dir = d / max(dist, 1e-6);
97 float baseWave = 0.055;
98 float baseAmp = 0.018;
100 vec3 tx = textureGrad(samp, uv, dFdx(uv), dFdy(uv)).rgb;
101 float waveLength = baseWave * (0.9 + 0.5*
luma(tx));
102 float amplitude = baseAmp * (0.75 + 0.5*drive);
103 float ripple = sin((dist / max(waveLength,1e-4) - t * speed) * 6.2831853);
104 ripple *= smoothstep(0.95, 0.22, dist);
105 return uv + dir *
ripple * amplitude;
117vec2
spiralTwist(vec2 uv, vec2 center,
float aspect,
float t,
float drive){
118 vec2 p = uv - center;
120 float r = length(p)+1e-6;
121 float a = atan(p.y, p.x);
122 float swirl = (0.5 + 0.45*drive) / (1.0 + 8.0*r);
123 float spin = (0.18 + 0.16*drive) * t;
125 float pull = 0.09 / (1.0 + 6.0*r);
126 r = max(r - pull, 0.0);
127 vec2 q = vec2(cos(a), sin(a)) * r;
141vec3
spiralEcho(vec2 uv, vec2 center,
float aspect,
float t,
float drive){
143 vec3 acc = vec3(0.0);
145 for(
int i=0;i<TAPS;i++){
147 float radScale = 1.0 + 0.085*k;
148 float timeLag = 0.11*k;
149 vec2 u =
spiralTwist(uv, center, aspect, t - timeLag, drive);
150 u =
rotateUV(u, (0.10+0.04*drive)*k, center, aspect);
151 vec3 s = textureGrad(samp, fract(u / radScale), dFdx(uv), dFdy(uv)).rgb;
152 float w = 1.0 / (1.0 + 0.85*k);
156 return acc / max(wsum, 1e-6);
174 if(Y > maxY) c *= maxY/(Y+1e-6);
186 return mix(vec3(Y), c, 1.0 + s);
196 vec2 center = (
iMouse.z > 0.5) ? mouseN : (hasClick ? clickN : vec2(0.5));
199 float aMix = clamp(
amp*0.7 +
uamp*0.3, 0.0, 12.0);
200 float drive = tanh(aMix*0.07);
204 vec3 echoCol =
spiralEcho(uvRipple, center, aspect, t, drive);
205 vec3 texCol = textureGrad(samp, uvRipple, dFdx(uvRipple), dFdy(uvRipple)).rgb;
206 vec3 mixed = mix(texCol, echoCol, 0.62);
209 vec2 dir = normalize(vec2(cos(a), sin(a)));
211 vec2 startP = center - dir*span;
212 vec2 endP = center + dir*span;
213 vec2 ab = endP - startP;
214 float L = max(length(ab), 1e-4);
216 float g = clamp(dot(tc - startP, u) / L, 0.0, 1.0);
218 float slowHue = fract(0.08*
time_f);
219 float slowHue2 = fract(0.08*
time_f + 0.33);
220 vec3 g0 =
hue(slowHue);
221 vec3 g1 =
hue(slowHue2);
222 vec3 gradCol = mix(g0, g1, smoothstep(0.0,1.0,g));
224 float ring = smoothstep(0.9, 0.2, length((tc-center)*vec2(aspect,1.0)));
225 float colorAmt = 0.45 + 0.25*drive;
226 vec3 colored = mix(mixed, mixed*(gradCol*(0.85+0.15*ring)), colorAmt);
228 colored =
satBoost(colored, 0.35 + 0.25*drive);
229 colored *= 1.08 + 0.12*drive;
233 colored = pow(clamp(colored,0.0,1.0), vec3(0.96));
235 color = vec4(colored, 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.
vec3 satBoost(vec3 c, float s)
Evaluates satBoost for this shader effect.
vec2 spin(vec2 p, float a)
Evaluates spin for this shader effect.