I am truly confused.
I searched "eyeball explosion" duplicated it and "edited code"..
pasted in
// Bottom-to-top sweep with gradient tail — stop-on-front option
// Expects: iTime (float), iResolution (vec3)
//-------------------- Controls --------------------
#define SPEED 0.20 // screen heights per second
#define TAIL_LENGTH 0.25 // 0..1 fraction of height fading behind head
#define FRONT_FEATHER 0.010 // 0..0.1 softness of leading edge (fraction of height)
#define TAIL_FEATHER 0.004 // extra smoothing in tail ramp
#define LOOP 0 // 1=wrap, 0=single pass
#define STOP_ON_FRONT 1 // 1=stop when (front) hits y=1; 0=stop when head hits y=1
#define FRONT_STOP_EPS_PX 1.0 // pixels before top edge to stop
#define SOLID_BEHIND 0 // 1=solid fill behind head except last TAIL_LENGTH
#define HEAD_HILIGHT 0.18 // 0..~0.3 subtle highlight at head (visual only)
#define FILL_COLOR vec3(1.0)
#define BG_COLOR vec3(0.0)
#define GLOBAL_ALPHA 1.0
//---------------------------------------------------
float remap01(float x, float a, float b){ return clamp((x-a)/(b-a),0.0,1.0); }
void mainImage(out vec4 fragColor, in vec2 fragCoord)
{
vec2 R = iResolution.xy;
vec2 uv = fragCoord / R;
float feFront = FRONT_FEATHER;
float feTail = max(TAIL_FEATHER, 1e-4);
float tailLen = max(TAIL_LENGTH, 1e-6);
float t = iTime * SPEED;
// Compute head position (in vertical space)
float head;
if (LOOP == 1) {
head = fract(t);
} else {
float py = 1.0 / R.y;
float stopCap = (STOP_ON_FRONT == 1)
? max(0.0, 1.0 - feFront - FRONT_STOP_EPS_PX * py) // stop slightly early
: 1.0;
head = min(t, stopCap);
}
float y = uv.y;
// Soft step for leading edge (0 above, 1 below)
float behind = smoothstep(head + feFront, head - feFront, y);
// Tail ramp
float tailRamp = 1.0 - remap01(y, head - tailLen, head);
tailRamp = smoothstep(0.0, 1.0, smoothstep(0.0, 1.0, tailRamp));
tailRamp = mix(tailRamp, smoothstep(0.0, 1.0, tailRamp), clamp(feTail * 50.0, 0.0, 1.0));
float alpha = (SOLID_BEHIND == 1)
? mix(tailRamp, 1.0, step(y, head - tailLen)) * behind
: (tailRamp * behind);
// Wrap-around only if LOOP==1
if (LOOP == 1) {
float head2 = head - 1.0;
float behind2 = smoothstep(head2 + feFront, head2 - feFront, y - 1.0);
float tail2 = 1.0 - remap01(y - 1.0, head2 - tailLen, head2);
tail2 = smoothstep(0.0, 1.0, smoothstep(0.0, 1.0, tail2));
tail2 = mix(tail2, smoothstep(0.0, 1.0, tail2), clamp(feTail * 50.0, 0.0, 1.0));
float a2 = (SOLID_BEHIND == 1)
? mix(tail2, 1.0, step(y - 1.0, head2 - tailLen)) * behind2
: (tail2 * behind2);
alpha = max(alpha, a2);
}
// Highlight near the head (does not influence stopping)
float highlight = exp(-pow((y - head) / (feFront * 0.6 + 1e-5), 2.0)) * HEAD_HILIGHT;
vec3 col = mix(BG_COLOR, FILL_COLOR, clamp(alpha, 0.0, 1.0));
col += FILL_COLOR * highlight;
fragColor = vec4(col, clamp(alpha * GLOBAL_ALPHA, 0.0, 1.0));
}
And it compiles and runs??
ANYWAY i'm so happy it works and am truly amazed by your amazing support
Op donderdag 25 september 2025 om 20:56:38 UTC+2 schreef Mathieu: