summaryrefslogtreecommitdiff
path: root/shaders/ui.frag.glsl
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 08:28:40 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit0a2694e935fa8a79f1a399f2d2cbc643f8c3734e (patch)
tree994775a97465d4ad279a8b13b848a2368b9a430b /shaders/ui.frag.glsl
parent6f7c79650857da578b9e6f8c49c772eb7c40bcae (diff)
downloadpardes-0a2694e935fa8a79f1a399f2d2cbc643f8c3734e.tar.gz
pardes-0a2694e935fa8a79f1a399f2d2cbc643f8c3734e.zip
G13: Parallax, lapis's dots drift with the text at a quarter of its speed
Parallax on|off (off, a pixel shell's; Chrome.fx bit 3). A body region carries its first line (Region.line, a file's scroll or a terminal's grid offset; the wire's region record grows a u32). The GUI offsets each body's page dots by a quarter of its line in rows, and of G6's glide offset while one runs, so the pattern drifts with the text and settles with it; the cell shader reads it from the instance's serial slot, whose per-cell dissolve noise G7 left unused (the dead noise code goes). Tests: a scrolled body tells its line; the shift handed to the shader is a quarter of it within the dots' period. Measured in a capture: four lines move the dots 13 px (140 px / 4 mod 22). Gates as before, goldens byte-identical. Feel review: .scratch/render/parallax/.
Diffstat (limited to 'shaders/ui.frag.glsl')
-rw-r--r--shaders/ui.frag.glsl18
1 files changed, 4 insertions, 14 deletions
diff --git a/shaders/ui.frag.glsl b/shaders/ui.frag.glsl
index cb38fff1..51ec5b8c 100644
--- a/shaders/ui.frag.glsl
+++ b/shaders/ui.frag.glsl
@@ -27,16 +27,6 @@ layout(location = 5) flat in vec4 v_clip;
layout(location = 0) out vec4 o_col;
-float cellNoise(uint serial, uint col, uint row) {
- uint x = serial ^ (col * 0x9e3779b9u) ^ (row * 0x85ebca6bu);
- x ^= x >> 16;
- x *= 0x7feb352du;
- x ^= x >> 15;
- x *= 0x846ca68bu;
- x ^= x >> 16;
- return float(x & 0xffffu) / 65535.0;
-}
-
void main() {
if (v_clip.z >= v_clip.x && (gl_FragCoord.x < v_clip.x || gl_FragCoord.x >= v_clip.z ||
gl_FragCoord.y < v_clip.y || gl_FragCoord.y >= v_clip.w)) discard;
@@ -51,9 +41,6 @@ void main() {
: clamp(u_ui.background_opacity, 0.0, 1.0);
uint effect = v_effect.x & 0x07ffffffu;
float progress = clamp(uintBitsToFloat(v_effect.y), 0.0, 1.0);
- uint cellCol = v_effect.w & 0xffffu;
- uint cellRow = v_effect.w >> 16;
- float noise = cellNoise(v_effect.z, cellCol, cellRow);
// Ink over ground, both premultiplied: v_fg*a + (v_bg*bgA)*(1-a), which is
// mix() with the ground already premultiplied. At bgA = 1 that is exactly
@@ -63,7 +50,10 @@ void main() {
// dot every period pixels, fixed to the window, under the text.
if ((v_effect.x & 0x10000000u) != 0u) {
float period = u_ui.decor_dot_geom.x;
- vec2 d = mod(gl_FragCoord.xy, period) - 0.5 * period;
+ // v_effect.z: how far its pane's text has moved the dots (G13's
+ // parallax), in pixels, as a float's bits (0 without).
+ vec2 at = gl_FragCoord.xy - vec2(0.0, uintBitsToFloat(v_effect.z));
+ vec2 d = mod(at, period) - 0.5 * period;
float dot_a = 1.0 - smoothstep(u_ui.decor_dot_geom.y, u_ui.decor_dot_geom.z, length(d));
ground = mix(ground, u_ui.decor_dots.rgb, u_ui.decor_dots.a * dot_a);
}