summaryrefslogtreecommitdiff
path: root/shaders/prebuilt/post-crt.frag.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'shaders/prebuilt/post-crt.frag.glsl')
-rw-r--r--shaders/prebuilt/post-crt.frag.glsl37
1 files changed, 33 insertions, 4 deletions
diff --git a/shaders/prebuilt/post-crt.frag.glsl b/shaders/prebuilt/post-crt.frag.glsl
index c2cadfa2..ca44d014 100644
--- a/shaders/prebuilt/post-crt.frag.glsl
+++ b/shaders/prebuilt/post-crt.frag.glsl
@@ -30,7 +30,14 @@ layout(set = 3, binding = 0, std140) uniform Globals {
uniform float iTimeCursorChange;
uniform float iTimeFocus;
uniform int iFocus;
+};
+// ghostty's one block, cut in three: SDL GPU binds at most 4 KiB of a
+// uniform block (Vulkan), and the palette alone is 4 KiB. The names and
+// their order are ghostty's; each block is a slice of the same memory.
+layout(set = 3, binding = 1, std140) uniform Palette {
uniform vec3 iPalette[256];
+};
+layout(set = 3, binding = 2, std140) uniform Colors {
uniform vec3 iBackgroundColor;
uniform vec3 iForegroundColor;
uniform vec3 iCursorColor;
@@ -41,12 +48,32 @@ layout(set = 3, binding = 0, std140) uniform Globals {
// pardes's own: pardesOpaque is 1 when the window is opaque, so a pass
// cannot punch holes in it through its alpha; pardesLevel is a bundled
-// pass's strength, 1 to 3 (`Crt 3`), and 0 for a user's file.
-layout(set = 3, binding = 1, std140) uniform PardesPost {
+// pass's strength, 1 to 3 (`Crt 3`), and 0 for a user's file; pardesScale
+// is the display's density (2 on a 2x screen), for a pass whose pattern is
+// in logical pixels. iResolution, fragCoord and iMouse stay in the display's
+// pixels, as ghostty's do. pardesCap is the most a bundled pass may do on
+// this theme and still leave its text, and its selection's, at their own
+// contrast or 4.5 (docs/effects.md); pardesSpare holds pardesSpareCount
+// rectangles (x0, y0, x1, y1 in fragCoord's pixels) a bundled pass leaves
+// alone: every tag, grip and notice, and the cursor, so no pass ever touches
+// a focus indicator.
+layout(set = 3, binding = 3, std140) uniform PardesPost {
float pardesOpaque;
float pardesLevel;
+ float pardesScale;
+ float pardesCap;
+ float pardesSpareCount;
+ vec4 pardesSpare[32];
};
+bool pardesSpared(vec2 p) {
+ for (int i = 0; i < int(pardesSpareCount); i++) {
+ vec4 r = pardesSpare[i];
+ if (p.x >= r.x && p.y >= r.y && p.x < r.z && p.y < r.w) return true;
+ }
+ return false;
+}
+
// A bundled pass's constant at levels 1, 2 and 3.
float pardesByLevel(float one, float two, float three) {
return pardesLevel < 1.5 ? one : (pardesLevel < 2.5 ? two : three);
@@ -143,9 +170,11 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) {
// A beam is brightest on its line and falls off between lines; the
// mask is three phosphor stripes a triad. Both average to one, so the
// theme keeps its brightness.
- float line = 0.5 + 0.5 * cos(fragCoord.y * TAU / SCAN_PERIOD_PX);
+ // Periods in logical pixels: the same look at any density.
+ float density = max(1.0, pardesScale);
+ float line = 0.5 + 0.5 * cos(fragCoord.y * TAU / (SCAN_PERIOD_PX * density));
col *= 1.0 - scanStrength() * (line * line - 0.375) / 0.625;
- col *= 1.0 + maskStrength() * cos(fragCoord.x * TAU / MASK_PERIOD_PX + vec3(0.0, TAU / 3.0, 2.0 * TAU / 3.0));
+ col *= 1.0 + maskStrength() * cos(fragCoord.x * TAU / (MASK_PERIOD_PX * density) + vec3(0.0, TAU / 3.0, 2.0 * TAU / 3.0));
float vignette = 1.0 - vignetteStrength() * pow(clamp(r2 * 0.5, 0.0, 1.0), 1.6);
float hum = 1.0 + humStrength() * sin((uv.y * 1.35 - iTime * HUM_HZ) * TAU);