summaryrefslogtreecommitdiff
path: root/shaders/prebuilt/decor.frag.glsl
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 23:50:56 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commitfde030a699b3d6667d1fa21ae192b5011e3f373f (patch)
treeaae9bd94e7889cea53c82e1775290adcd94cd7e7 /shaders/prebuilt/decor.frag.glsl
parent34b631e75dd646809961cae0ab215b6c43643a13 (diff)
downloadpardes-fde030a699b3d6667d1fa21ae192b5011e3f373f.tar.gz
pardes-fde030a699b3d6667d1fa21ae192b5011e3f373f.zip
Rules and chrome scale with the display's density; dark pages get visible separators and focus tints
Density: dp() in gui.zig draws every size given in pixels in logical pixels (SDL's window display scale, rounded, at least one), as acme scales Border, ButtonBorder and Scrollgap: the rules (rule_px), the tag rule, the grip's ring, its dirty gap and mode bars, the rail's gap to the text and its minimum, the thumb's inset, the rim, a bar cursor's minimum width, underline and strikethrough thickness (the atlas is dropped on a scale change), the rule-grab margin, and the Crt's scanline and mask periods (pardesScale in the post prefix). Cell- and tagline-measured sizes stay: the rail's width, Lift's blur and offsets, every motion; iResolution, fragCoord and iMouse stay in the display's pixels, as ghostty's. PARDES_TEST_SCALE forces a density in a harness (a test window is 1x otherwise, whatever display it lands on) and sizes the test font with it. Colours: a separator that stands off its page by less than 1.5:1 is lifted toward the text to 1.6:1 (helix, atelier, paper; a theme with no page, dark, is judged against #121212), and empty_col follows it. forge's own rule already stands at 3.83:1; what hid it was density: 2 device pixels on a 3x screen, now 6 (dp). A focused tag's tint closer than 1.5:1 to the plain tag on a dark page (1.25:1 on a light one) is pushed further the way it leans, as far as its text keeps its own contrast or 4.5: forge 1.23 -> 1.51 (#2d3440 -> #374253), and likewise dusk, orchard, ink, lagoon, clay, harvest, spectrum, solarium, forge_soft; daybreak, atelier, paper to 1.25. dark and helix gain a tint of their own (dark: #484566 under #c8c8c8, 1.54:1; helix: ramp 237 under 250, 1.65:1). Tag caret: past a full row's end, the G3 glide box sits on the tag's right edge, where the layer's caret and the pixel shell's are. Tests: every native theme's separator >= 1.5 and every dark one has a tint >= 1.25 with readable text; forge keeps its own border; the tag caret glide box at a full row; at 2x the spine, tag rule, ring, rail start and gap, and bar cursor double. Legacy-ThemeFile test strips helix's new pair. Goldens: snapshot goldens change in colour rows only, the tints (orchard #283a2f -> #314738 at boot, forge, helix and dark in theme/themesel). GUI goldens: the harness's single Del of the renamed wide pane is refused since ysqnkyoy (a rename counted as unsaved; fixed on the 9P line in wkzlsqvy), so scenes 09-17 were recorded with that pane open and the file was stale since the merge (08 and 18 also moved with ykvnltvs's full-row tag wrap). The goldens here were recorded with that pane closed (as wkzlsqvy will close it); against the parent's binary under the same conditions they differ only in the tints: 01-13 forge's (#2d3440 -> #374253, and the glyph edges on it), 14 ink's; 15-18 are byte-identical. Until wkzlsqvy is merged, a run here fails 09-17. Each commit reproduces its own recorded goldens on this machine (checked at kvtmqkyn). A test window is 1x unless PARDES_TEST_SCALE says otherwise, whatever display it opens on. Prebuilt shaders refreshed from their sources. Captures: .scratch/render/dark-borders/{before,after,compare,scale2,scale3}.
Diffstat (limited to 'shaders/prebuilt/decor.frag.glsl')
-rw-r--r--shaders/prebuilt/decor.frag.glsl60
1 files changed, 53 insertions, 7 deletions
diff --git a/shaders/prebuilt/decor.frag.glsl b/shaders/prebuilt/decor.frag.glsl
index 4c2bd6d8..3e2c286f 100644
--- a/shaders/prebuilt/decor.frag.glsl
+++ b/shaders/prebuilt/decor.frag.glsl
@@ -1,24 +1,70 @@
#version 450
-// Decor: a flat, hard-edged fill (a rule, a rail, a grip mark, a bar cursor)
-// that ui.vert.glsl places like a cell, its track's transition included. Its
-// colour rides in the cell's ground (a_bg) and its coverage in a_fg.r. The
-// pipeline blends it as the overlay pipeline does (backgroundLayerBlend), so
-// a fading rule shows through, and the result is that pipeline's exactly.
-// Ink (a cursor) is drawn with the opacity uniform at 1.
+// Decor, drawn by ui.vert.glsl like a cell, its track's transition included,
+// and blended as the overlay pipeline blends (backgroundLayerBlend). Ink (a
+// cursor) is drawn with the opacity uniform at 1.
+//
+// Flat: a hard-edged fill (a rule, a rail, a grip mark, a bar cursor). Its
+// colour rides in the cell's ground (a_bg), its coverage in a_fg.r, so the
+// result is the overlay pipeline's exactly.
+//
+// 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
+// track's transform carries it: sigma per axis in the uv, the caster's
+// offset from its shadow in fg.gb, the strength in fg.r. The caster's own
+// rectangle is left alone (it is drawn already), and the alpha is pre-warped
+// so black darkens in linear light, then dithered so it never bands.
layout(std140, set = 3, binding = 0) uniform UiUniforms {
float background_opacity;
} u_ui;
+layout(location = 0) in vec2 v_uv;
layout(location = 1) in vec3 v_fg;
layout(location = 2) in vec3 v_bg;
+layout(location = 3) in vec2 v_cell_uv;
+layout(location = 4) flat in uvec4 v_effect;
layout(location = 5) flat in vec4 v_clip;
layout(location = 0) out vec4 o_col;
+// erf to about 4e-4 (Winitzki's approximation): smooth, cheap, odd.
+float erfApprox(float x) {
+ float x2 = x * x;
+ const float a = 0.147;
+ float e = sqrt(1.0 - exp(-x2 * (1.2732395 + a * x2) / (1.0 + a * x2)));
+ return x < 0.0 ? -e : e;
+}
+
+// How much of [lo, hi] a Gaussian of sigma s centred at x covers.
+float edge(float x, float lo, float hi, float s) {
+ float k = 0.70710678 / s;
+ return 0.5 * (erfApprox((x - lo) * k) - erfApprox((x - hi) * k));
+}
+
+float ign(vec2 p) {
+ return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));
+}
+
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;
- o_col = vec4(v_bg * clamp(u_ui.background_opacity, 0.0, 1.0), v_fg.r);
+ float opacity = clamp(u_ui.background_opacity, 0.0, 1.0);
+ if ((v_effect.x & 0x10000000u) == 0u) {
+ o_col = vec4(v_bg * opacity, v_fg.r);
+ return;
+ }
+ vec2 s = v_uv;
+ vec2 m = 3.0 * s;
+ vec2 p = v_cell_uv;
+ vec2 caster0 = m - v_fg.gb;
+ vec2 caster1 = 1.0 - m - v_fg.gb;
+ if (all(greaterThanEqual(p, caster0)) && all(lessThan(p, caster1))) discard;
+ float a = v_fg.r * edge(p.x, m.x, 1.0 - m.x, s.x) * edge(p.y, m.y, 1.0 - m.y, s.y);
+ // Black darkens in linear light; a light colour (a rim, a glow) is laid
+ // on as it is, within ยง8.2's 25%.
+ if (all(equal(v_bg, vec3(0.0)))) a = 1.0 - pow(max(1.0 - a, 0.0), 1.0 / 2.2);
+ a = clamp(a + (ign(gl_FragCoord.xy) - 0.5) / 255.0, 0.0, 1.0);
+ o_col = vec4(v_bg * opacity, a);
}