From 09ec515c5e94de741104038cd61f18b2b997e78c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 06:04:28 -0300 Subject: G5: lapis, 0x4200.cafe's manuscript, as a theme with its ornament A native theme `lapis` (src/themes/lapis.zig) from web/theme/lapis.css: a lapis-deep page, lapis tags with gold names, vellum text, vermilion rubrics, gold rules and a vermilion tag rule, gold selection in lapis ink. Its ornament is the theme's new `decor` (colors.Decor), drawn by a pixel shell inside the chrome it already has (decision 1), all of it off every focus indicator: - page_dots: the site's gold dot grid (#e8c46a22, 22 px), drawn by the cell shader on page-coloured cells alone (flag 0x10000000), so it lies under the text and never under a selection, a tag or the cursor; fixed to the window, a page the panes lie on. - rail_checker: the dither frame's gold and lapis checker in the scroll track (a decor kind, flag 0x08000000), anchored to its rail; the thumb stays solid gold. - tag plaques (tag_border, tag_shadow, tag_stripe): every tag a raised plaque inside its own band, the site's trail: a 2px gold frame and a hard 5px vermilion shadow down and right, both within the band's rows and columns (down, what the slack under the text leaves), so no shadow reaches a body, a grip or the next pane. The focused pane's plaque is the code window's title bar, gold and lapis stripes of 2px, its words on plates of the focused ground; unfocused ones are plain; column and workspace tags take the object-label language (1px frame, 2px shadow toward the page). Drawn as decor under the cells (a group's under range), with blank tag cells see-through and the cells blended premultiplied (pipeline_over) on such frames; opaque windows only. - title_shadow: the titles' vermilion offset shadow under a file name's letters, sampled in the cell shader inside the letters' own cells (flag 0x08000000), none on a cursor. Chrome carries the decor (decor_*, name_ink, active_name_ink); a theme file folds a nested decor literal field by field. Left out, with why, in docs/effects.md: the fonts, the ornaments, a decor crossfade, and in the tty anything but the colours (a tag row has no spare cell for a shadow). An empty column is the page. The effect id is masked to 27 bits (ui.vert/ui.frag) for the fifth flag. Tests: the cell flags land only on page ground and file-name cells, never a cursor, nothing without decor; lapis's plaques stay inside their tag's band, clear of every grip, only the focused one striped; its checker is in the track; no other theme draws any; the separator and focus tests cover lapis. Goldens: theme and themesel (the ring gains lapis after acme). Gates as G4. Feel review: .scratch/render/lapis/ (lapis.png, lapis-2x.png, tags-focused-vs-unfocused-2x.png, a PanelSlide at 60 fps and a quarter). --- shaders/decor.frag.glsl | 13 +++++++++++++ shaders/prebuilt/decor.frag.glsl | 13 +++++++++++++ shaders/prebuilt/decor.frag.spv | Bin 6560 -> 7852 bytes shaders/prebuilt/ui.frag.glsl | 32 ++++++++++++++++++++++++++++++-- shaders/prebuilt/ui.frag.spv | Bin 5700 -> 8448 bytes shaders/prebuilt/ui.vert.glsl | 10 ++++++---- shaders/prebuilt/ui.vert.spv | Bin 5612 -> 5612 bytes shaders/ui.frag.glsl | 32 ++++++++++++++++++++++++++++++-- shaders/ui.vert.glsl | 10 ++++++---- 9 files changed, 98 insertions(+), 12 deletions(-) (limited to 'shaders') diff --git a/shaders/decor.frag.glsl b/shaders/decor.frag.glsl index 3e2c286f..bb1ef0d6 100644 --- a/shaders/decor.frag.glsl +++ b/shaders/decor.frag.glsl @@ -8,6 +8,8 @@ // colour rides in the cell's ground (a_bg), its coverage in a_fg.r, so the // result is the overlay pipeline's exactly. // +// Checker (flag 0x08000000): two colours in squares, or in stripes, see main. +// // Soft (flag 0x10000000): a rectangle's shadow, rim or glow blurred by a Gaussian, // in closed form (the product of two erf edges), on one quad grown by 3 // sigma: no blur pass. Everything is in the quad's own 0..1 space, so a @@ -51,6 +53,17 @@ 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; float opacity = clamp(u_ui.background_opacity, 0.0, 1.0); + // Checker (flag 0x08000000): squares of v_uv.x pixels from the quad's + // own corner, so it moves with its rail, in the ground's colour and the + // ink's (lapis's scroll track). + vec2 in_quad = v_cell_uv / max(vec2(dFdx(v_cell_uv.x), dFdy(v_cell_uv.y)), vec2(1e-6)); + if ((v_effect.x & 0x08000000u) != 0u) { + ivec2 q = ivec2(floor(in_quad / max(v_uv.x, 1.0))); + // v_uv.y set: stripes across the quad (lapis's title bar), not squares. + int k = v_uv.y > 0.5 ? q.y : q.x + q.y; + o_col = vec4(((k & 1) == 0 ? v_bg : v_fg) * opacity, 1.0); + return; + } if ((v_effect.x & 0x10000000u) == 0u) { o_col = vec4(v_bg * opacity, v_fg.r); return; diff --git a/shaders/prebuilt/decor.frag.glsl b/shaders/prebuilt/decor.frag.glsl index 3e2c286f..bb1ef0d6 100644 --- a/shaders/prebuilt/decor.frag.glsl +++ b/shaders/prebuilt/decor.frag.glsl @@ -8,6 +8,8 @@ // colour rides in the cell's ground (a_bg), its coverage in a_fg.r, so the // result is the overlay pipeline's exactly. // +// Checker (flag 0x08000000): two colours in squares, or in stripes, see main. +// // Soft (flag 0x10000000): a rectangle's shadow, rim or glow blurred by a Gaussian, // in closed form (the product of two erf edges), on one quad grown by 3 // sigma: no blur pass. Everything is in the quad's own 0..1 space, so a @@ -51,6 +53,17 @@ 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; float opacity = clamp(u_ui.background_opacity, 0.0, 1.0); + // Checker (flag 0x08000000): squares of v_uv.x pixels from the quad's + // own corner, so it moves with its rail, in the ground's colour and the + // ink's (lapis's scroll track). + vec2 in_quad = v_cell_uv / max(vec2(dFdx(v_cell_uv.x), dFdy(v_cell_uv.y)), vec2(1e-6)); + if ((v_effect.x & 0x08000000u) != 0u) { + ivec2 q = ivec2(floor(in_quad / max(v_uv.x, 1.0))); + // v_uv.y set: stripes across the quad (lapis's title bar), not squares. + int k = v_uv.y > 0.5 ? q.y : q.x + q.y; + o_col = vec4(((k & 1) == 0 ? v_bg : v_fg) * opacity, 1.0); + return; + } if ((v_effect.x & 0x10000000u) == 0u) { o_col = vec4(v_bg * opacity, v_fg.r); return; diff --git a/shaders/prebuilt/decor.frag.spv b/shaders/prebuilt/decor.frag.spv index 3256f2b1..bd565d03 100644 Binary files a/shaders/prebuilt/decor.frag.spv and b/shaders/prebuilt/decor.frag.spv differ diff --git a/shaders/prebuilt/ui.frag.glsl b/shaders/prebuilt/ui.frag.glsl index dca224ba..62dbbfa2 100644 --- a/shaders/prebuilt/ui.frag.glsl +++ b/shaders/prebuilt/ui.frag.glsl @@ -10,6 +10,12 @@ layout(set = 2, binding = 0) uniform sampler2D u_atlas; layout(std140, set = 3, binding = 0) uniform UiUniforms { float background_opacity; + // A theme's ornament (colors.Decor): the page's dots (rgb, strength), + // their geometry (period, solid radius, faded radius, in pixels), and a + // file name's shadow (rgb, offset in pixels). + vec4 decor_dots; + vec4 decor_dot_geom; + vec4 decor_shadow; } u_ui; layout(location = 0) in vec2 v_uv; @@ -43,7 +49,7 @@ void main() { float bgA = (v_effect.x & 0x20000000u) != 0u ? 1.0 : (v_effect.x & 0x40000000u) != 0u ? 0.0 : clamp(u_ui.background_opacity, 0.0, 1.0); - uint effect = v_effect.x & 0x0fffffffu; + 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; @@ -52,7 +58,29 @@ void main() { // 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 // the mix(v_bg, v_fg, a) at alpha 1 this shader always wrote. - vec4 cell = vec4(mix(v_bg * bgA, v_fg, a), mix(bgA, 1.0, a)); + vec3 ground = v_bg; + // 0x10000000: the page's ground under a pane body, dotted (lapis): a + // 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; + 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); + } + vec4 under = vec4(ground * bgA, bgA); + // Derivatives outside any branch: a pixel's step in the atlas and in + // the cell, for the shadow's offset. + vec2 step_uv = vec2(dFdx(v_uv.x), dFdy(v_uv.y)) * u_ui.decor_shadow.a; + vec2 step_cell = vec2(dFdx(v_cell_uv.x), dFdy(v_cell_uv.y)) * u_ui.decor_shadow.a; + // 0x08000000: a file name's letters cast a shadow down and right onto + // their own cell's ground (lapis), under the ink; what would fall past + // the cell's edge is not drawn. + if ((v_effect.x & 0x08000000u) != 0u) { + vec2 from = v_cell_uv - step_cell; + float s = all(greaterThanEqual(from, vec2(0.0))) ? texture(u_atlas, v_uv - step_uv).r : 0.0; + under = mix(under, vec4(u_ui.decor_shadow.rgb, 1.0), s); + } + vec4 cell = vec4(mix(under.rgb, v_fg, a), mix(under.a, 1.0, a)); // 3 = data dissolve. Changed cells retain the frozen old cell until their // stable threshold, then atomically become the new cell. Exact endpoints diff --git a/shaders/prebuilt/ui.frag.spv b/shaders/prebuilt/ui.frag.spv index c8ee1604..d83d9c55 100644 Binary files a/shaders/prebuilt/ui.frag.spv and b/shaders/prebuilt/ui.frag.spv differ diff --git a/shaders/prebuilt/ui.vert.glsl b/shaders/prebuilt/ui.vert.glsl index 5551f3f1..de22adee 100644 --- a/shaders/prebuilt/ui.vert.glsl +++ b/shaders/prebuilt/ui.vert.glsl @@ -14,9 +14,11 @@ layout(location = 3) in vec3 a_bg; layout(location = 4) in vec4 a_panel_rect; layout(location = 5) in vec4 a_present_rect; // effect id, eased-progress float bits, pane serial, local row/column packed -// into one uint. The FOUR high effect bits are flags — the frozen-old cell -// layer, a see-through cell background, an opaque block-cursor fill and a -// soft shadow (decor.frag.glsl) — so the id is what is left below them; integer transport preserves the exact +// into one uint. The FIVE high effect bits are flags — the frozen-old cell +// layer, a see-through cell background, an opaque block-cursor fill, a soft +// shadow (decor.frag.glsl) or dotted page ground (ui.frag.glsl), and a +// checker (decor) or a file name's shadow (ui) — so the id is what is left +// below them; integer transport preserves the exact // cross-backend hash. layout(location = 6) in uvec4 a_effect; // A clip rectangle in target pixels (x0, y0, x1, y1): the fragment shader @@ -61,7 +63,7 @@ void main() { v_cell_uv = vec2(0.0, 1.0); } - uint effect = a_effect.x & 0x0fffffffu; + uint effect = a_effect.x & 0x07ffffffu; if (effect == 1u || effect == 2u || effect == 5u) { // NDC y points up, so a top-left/bottom-right box has a NEGATIVE y // delta. Preserve that sign or every local y is mirrored/outside. diff --git a/shaders/prebuilt/ui.vert.spv b/shaders/prebuilt/ui.vert.spv index b1e87ec1..af5b0738 100644 Binary files a/shaders/prebuilt/ui.vert.spv and b/shaders/prebuilt/ui.vert.spv differ diff --git a/shaders/ui.frag.glsl b/shaders/ui.frag.glsl index dca224ba..62dbbfa2 100644 --- a/shaders/ui.frag.glsl +++ b/shaders/ui.frag.glsl @@ -10,6 +10,12 @@ layout(set = 2, binding = 0) uniform sampler2D u_atlas; layout(std140, set = 3, binding = 0) uniform UiUniforms { float background_opacity; + // A theme's ornament (colors.Decor): the page's dots (rgb, strength), + // their geometry (period, solid radius, faded radius, in pixels), and a + // file name's shadow (rgb, offset in pixels). + vec4 decor_dots; + vec4 decor_dot_geom; + vec4 decor_shadow; } u_ui; layout(location = 0) in vec2 v_uv; @@ -43,7 +49,7 @@ void main() { float bgA = (v_effect.x & 0x20000000u) != 0u ? 1.0 : (v_effect.x & 0x40000000u) != 0u ? 0.0 : clamp(u_ui.background_opacity, 0.0, 1.0); - uint effect = v_effect.x & 0x0fffffffu; + 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; @@ -52,7 +58,29 @@ void main() { // 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 // the mix(v_bg, v_fg, a) at alpha 1 this shader always wrote. - vec4 cell = vec4(mix(v_bg * bgA, v_fg, a), mix(bgA, 1.0, a)); + vec3 ground = v_bg; + // 0x10000000: the page's ground under a pane body, dotted (lapis): a + // 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; + 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); + } + vec4 under = vec4(ground * bgA, bgA); + // Derivatives outside any branch: a pixel's step in the atlas and in + // the cell, for the shadow's offset. + vec2 step_uv = vec2(dFdx(v_uv.x), dFdy(v_uv.y)) * u_ui.decor_shadow.a; + vec2 step_cell = vec2(dFdx(v_cell_uv.x), dFdy(v_cell_uv.y)) * u_ui.decor_shadow.a; + // 0x08000000: a file name's letters cast a shadow down and right onto + // their own cell's ground (lapis), under the ink; what would fall past + // the cell's edge is not drawn. + if ((v_effect.x & 0x08000000u) != 0u) { + vec2 from = v_cell_uv - step_cell; + float s = all(greaterThanEqual(from, vec2(0.0))) ? texture(u_atlas, v_uv - step_uv).r : 0.0; + under = mix(under, vec4(u_ui.decor_shadow.rgb, 1.0), s); + } + vec4 cell = vec4(mix(under.rgb, v_fg, a), mix(under.a, 1.0, a)); // 3 = data dissolve. Changed cells retain the frozen old cell until their // stable threshold, then atomically become the new cell. Exact endpoints diff --git a/shaders/ui.vert.glsl b/shaders/ui.vert.glsl index 5551f3f1..de22adee 100644 --- a/shaders/ui.vert.glsl +++ b/shaders/ui.vert.glsl @@ -14,9 +14,11 @@ layout(location = 3) in vec3 a_bg; layout(location = 4) in vec4 a_panel_rect; layout(location = 5) in vec4 a_present_rect; // effect id, eased-progress float bits, pane serial, local row/column packed -// into one uint. The FOUR high effect bits are flags — the frozen-old cell -// layer, a see-through cell background, an opaque block-cursor fill and a -// soft shadow (decor.frag.glsl) — so the id is what is left below them; integer transport preserves the exact +// into one uint. The FIVE high effect bits are flags — the frozen-old cell +// layer, a see-through cell background, an opaque block-cursor fill, a soft +// shadow (decor.frag.glsl) or dotted page ground (ui.frag.glsl), and a +// checker (decor) or a file name's shadow (ui) — so the id is what is left +// below them; integer transport preserves the exact // cross-backend hash. layout(location = 6) in uvec4 a_effect; // A clip rectangle in target pixels (x0, y0, x1, y1): the fragment shader @@ -61,7 +63,7 @@ void main() { v_cell_uv = vec2(0.0, 1.0); } - uint effect = a_effect.x & 0x0fffffffu; + uint effect = a_effect.x & 0x07ffffffu; if (effect == 1u || effect == 2u || effect == 5u) { // NDC y points up, so a top-left/bottom-right box has a NEGATIVE y // delta. Preserve that sign or every local y is mirrored/outside. -- cgit v1.3