kik shader: fix random flicker while scrolling, smooth rain/radar/progress
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b158c36502
commit
eb154cdf53
1 changed files with 152 additions and 17 deletions
|
|
@ -33,9 +33,11 @@ vec3 line(float n) {
|
|||
vec3 sceneTerminal(float i, float t) {
|
||||
if (i < LAST - 1.0) {
|
||||
float s = t * 0.45;
|
||||
float scroll = floor(s) + smoothstep(0.5, 1.0, fract(s));
|
||||
float n = i + scroll;
|
||||
return line(n) + 0.10 * (line(n - 1.0) + line(n + 1.0));
|
||||
float slide = smoothstep(0.5, 1.0, fract(s)); // 0..1 between two lines
|
||||
float n = i + floor(s); // always an integer
|
||||
vec3 a = line(n) + 0.10 * (line(n - 1.0) + line(n + 1.0));
|
||||
vec3 b = line(n + 1.0) + 0.10 * (line(n) + line(n + 2.0));
|
||||
return mix(a, b, slide);
|
||||
}
|
||||
if (i < LAST) return DIM * 0.9; // visitor@khaos-im-kiez:~$
|
||||
return fract(t / 1.1) < 0.5 ? FG : BG; // blinking cursor, as on the site
|
||||
|
|
@ -47,9 +49,8 @@ vec3 sceneProgress(float i, float t) {
|
|||
float fill = min(ph / 0.78, 1.0) * (LAST + 1.0);
|
||||
float d = fill - (i + 0.5);
|
||||
vec3 col = BG + DIM * 0.06; // empty track
|
||||
if (d > 0.0) {
|
||||
col = mix(FG, DIM * 0.7, smoothstep(0.0, 2.0, d));
|
||||
}
|
||||
float on = smoothstep(-0.25, 0.35, d);
|
||||
col = mix(col, mix(FG, DIM * 0.7, smoothstep(0.0, 2.0, d)), on);
|
||||
if (ph > 0.78) {
|
||||
float p = (ph - 0.78) / 0.22;
|
||||
col = mix(col, FG, 0.5 + 0.5 * sin(p * 12.566 - 1.57)) * (1.0 - 0.6 * p);
|
||||
|
|
@ -60,12 +61,14 @@ vec3 sceneProgress(float i, float t) {
|
|||
// 2: radar, a blip sweeps back and forth leaving a phosphor trail,
|
||||
// now and then a red contact appears and fades
|
||||
vec3 sceneRadar(float i, float t) {
|
||||
float pos = 6.0 + 6.0 * sin(t * 0.7);
|
||||
float dir = cos(t * 0.7);
|
||||
float d = i - pos;
|
||||
float behind = -sign(dir) * d;
|
||||
float trail = behind > 0.0 ? exp(-behind * 0.45) : 0.0;
|
||||
float head = exp(-d * d * 1.2);
|
||||
float d0 = i - (6.0 + 6.0 * sin(t * 0.7));
|
||||
float head = exp(-d0 * d0 * 1.2);
|
||||
float trail = 0.0;
|
||||
for (int j = 1; j <= 10; j++) {
|
||||
float fj = float(j);
|
||||
float d = i - (6.0 + 6.0 * sin((t - fj * 0.15) * 0.7));
|
||||
trail = max(trail, exp(-fj * 0.3) * exp(-d * d * 1.2));
|
||||
}
|
||||
vec3 col = BG + DIM * 0.05 + DIM * 0.55 * trail + FG * head;
|
||||
|
||||
float k = floor(t / 7.0);
|
||||
|
|
@ -81,11 +84,10 @@ vec3 sceneRain(float i, float t) {
|
|||
for (int k = 0; k < 3; k++) {
|
||||
float fk = float(k);
|
||||
float speed = 0.9 + 0.5 * fk;
|
||||
float pos = mod(t * speed + fk * 5.3, 20.0);
|
||||
float behind = pos - i;
|
||||
if (behind >= 0.0 && behind < 8.0) {
|
||||
col += mix(DIM * 0.6, FG, step(behind, 0.7)) * exp(-behind * 0.6);
|
||||
}
|
||||
float b = mod(t * speed + fk * 5.3, 20.0) - 3.0 - i; // steps behind the drop, enters from off the stairs
|
||||
float trail = exp(-max(b, 0.0) * 0.6) * smoothstep(-0.9, 0.0, b);
|
||||
float head = max(0.0, 1.0 - abs(b));
|
||||
col += DIM * 0.6 * trail + FG * head;
|
||||
}
|
||||
return col;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue