summaryrefslogtreecommitdiff
path: root/shaders/post/crt.glsl
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-05 10:46:03 -0300
committerGabriel Schneider <[email protected]>2026-11-05 15:12:36 -0300
commit11204e1206f7f7ffeaa861c1a442a312e563d3ed (patch)
treef788736bf5b6a56694563b664b5db73bc54bff72 /shaders/post/crt.glsl
parentc9b9dad8469f5d654c31d688d7e2d93da8325f39 (diff)
downloadpardes-11204e1206f7f7ffeaa861c1a442a312e563d3ed.tar.gz
pardes-11204e1206f7f7ffeaa861c1a442a312e563d3ed.zip
effects out, the post chain: Crt, Bloom, Vignette, Grain, Shader and ShaderAnimation go with src/gui/Post.zig, src/ShaderBuild.zig (the run-time glslc spawn and its watched files), shaders/post/, post.vert, bloom-down and bloom-up and their prebuilt .spv, the window's scene texture and its post-chain-only redraw (level A), the disable_scene_effects tape site and Pardes.disableSceneEffects; EffectCode goes with src/effect_sources.zig, which only embedded the effects' sources (/virtual keeps src/); the corner-click test keeps its point without a chain, the window monkey loses its Bloom axis; macOS's post-processor (ScenePostprocessor.swift, crt.ci.metal, pardes_scene) is a change of its own
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'shaders/post/crt.glsl')
-rw-r--r--shaders/post/crt.glsl85
1 files changed, 0 insertions, 85 deletions
diff --git a/shaders/post/crt.glsl b/shaders/post/crt.glsl
deleted file mode 100644
index 970d61ee..00000000
--- a/shaders/post/crt.glsl
+++ /dev/null
@@ -1,85 +0,0 @@
-// Crt: a slot-mask tube's light, with nothing that moves a pixel. There is
-// no barrel: every click lands where it is drawn, rails and grips at the
-// window's edges included. What is left is light: a beam profile for the
-// scanlines, an aperture mask, a soft bloom of the brightest ink, a faint
-// vignette and the hum of a live tube. Everything is worked out in linear
-// light and dithered back into 8 bits, so the vignette never bands. It is a
-// Shadertoy file: pardes puts its prefix before it (shaders/post/prefix.glsl).
-
-const float TAU = 6.28318530718;
-// Level 3 glows wider and from dimmer ink.
-float bloomRadiusPx() { return pardesByLevel(1.75, 1.75, 3.0); }
-float bloomThreshold() { return pardesByLevel(0.6, 0.6, 0.3); } // linear-light channel peak
-const float BLOOM_SOFTNESS = 0.25;
-const float SCAN_PERIOD_PX = 3.0;
-const float MASK_PERIOD_PX = 3.0;
-const float HUM_HZ = 0.11;
-
-// Each strength at levels 1, 2 and 3 (`Crt 1`..`Crt 3`): 2 is the default,
-// 3 as strong as the old barrel CRT looked.
-float chromaPx() { return pardesByLevel(0.2, 0.35, 2.2); } // red and blue apart, at the corners
-float bloomStrength() { return pardesByLevel(0.03, 0.05, 0.3); }
-float scanStrength() { return pardesByLevel(0.035, 0.07, 0.42); }
-float maskStrength() { return pardesByLevel(0.01, 0.018, 0.12); }
-float vignetteStrength() { return pardesByLevel(0.06, 0.12, 0.42); } // at the far corners only
-float humStrength() { return pardesByLevel(0.002, 0.004, 0.012); }
-float exposure() { return pardesByLevel(1.008, 1.015, 1.1); }
-
-vec3 toLinear(vec3 c) {
- return mix(pow((c + 0.055) / 1.055, vec3(2.4)), c / 12.92, lessThanEqual(c, vec3(0.04045)));
-}
-
-vec3 toSrgb(vec3 c) {
- c = max(c, vec3(0.0));
- return mix(1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, c * 12.92, lessThanEqual(c, vec3(0.0031308)));
-}
-
-vec3 scene(vec2 uv) {
- return toLinear(texture(iChannel0, uv).rgb);
-}
-
-vec3 brightPass(vec2 uv) {
- vec3 c = scene(uv);
- float peak = max(c.r, max(c.g, c.b));
- return c * smoothstep(bloomThreshold(), bloomThreshold() + BLOOM_SOFTNESS, peak);
-}
-
-// Interleaved gradient noise: a dither with no visible pattern.
-float ign(vec2 p) {
- return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715))));
-}
-
-void mainImage(out vec4 fragColor, in vec2 fragCoord) {
- vec2 size = iResolution.xy;
- vec2 texel = 1.0 / size;
- vec2 uv = fragCoord / size;
- vec2 cc = uv * 2.0 - 1.0;
- float r2 = dot(cc, cc);
-
- // The beam converges least at the corners: red and blue drift apart
- // there, by a third of a pixel.
- vec2 chroma = cc * (chromaPx() * r2 * 0.5) * texel;
- vec3 col = vec3(scene(uv + chroma).r, scene(uv).g, scene(uv - chroma).b);
-
- vec2 b = texel * bloomRadiusPx();
- vec3 bloom = brightPass(uv + vec2(b.x, 0.0)) + brightPass(uv - vec2(b.x, 0.0)) +
- brightPass(uv + vec2(0.0, b.y)) + brightPass(uv - vec2(0.0, b.y));
- col += bloom * (0.25 * bloomStrength());
-
- // 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.
- // 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 * 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);
- col *= vignette * hum * exposure();
-
- vec3 srgb = toSrgb(col);
- srgb += (ign(fragCoord + float(iFrame % 64) * vec2(5.588238, 5.588238)) - 0.5) / 255.0;
- fragColor = vec4(clamp(srgb, 0.0, 1.0), texture(iChannel0, uv).a);
-}