diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-28 16:12:01 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-09-01 08:30:41 -0300 |
| commit | 848ad99fa597387a85f75e752dc4c9e10f8c24f4 (patch) | |
| tree | 623ee400f6bec5e2a823e5a590dc4760a3084771 /shaders/crt.frag.glsl | |
| parent | b3595e04e67708c3b060a15cbbbf2478d9e6241e (diff) | |
| download | pardes-848ad99fa597387a85f75e752dc4c9e10f8c24f4.tar.gz pardes-848ad99fa597387a85f75e752dc4c9e10f8c24f4.zip | |
macos fix
Diffstat (limited to 'shaders/crt.frag.glsl')
| -rw-r--r-- | shaders/crt.frag.glsl | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/shaders/crt.frag.glsl b/shaders/crt.frag.glsl index e43d5b86..b0b0b93b 100644 --- a/shaders/crt.frag.glsl +++ b/shaders/crt.frag.glsl @@ -81,24 +81,29 @@ vec2 sceneUv(vec2 uv) { return uv; } -vec3 sceneSrgb(vec2 uv) { +// The scene, ALPHA INCLUDED: with a see-through ground the grid arrives +// premultiplied and partly empty, and a pass that dropped .a would turn the +// desktop behind a `*_transparent` theme into opaque black the moment Crt, +// Ripple or Glitch came on. +vec4 sceneSrgb(vec2 uv) { vec2 warped = sceneUv(uv); - vec3 center = texture(u_scene, warped).rgb; + vec4 center = texture(u_scene, warped); if (u_crt.effects.z <= 0.5) return center; float band = floor(warped.y * 96.0); float seed = noiseAt(vec2(band, floor(u_crt.time_seconds * 13.0))); float tear = smoothstep(0.955, 1.0, seed); vec2 chroma = vec2((0.35 + 1.25 * tear) / u_crt.viewport.x, 0.0); - return vec3( + return vec4( texture(u_scene, warped + chroma).r, center.g, - texture(u_scene, warped - chroma).b + texture(u_scene, warped - chroma).b, + center.a ); } vec3 effectSceneLinear(vec2 uv) { - return srgbToLinear(sceneSrgb(uv)); + return srgbToLinear(sceneSrgb(uv).rgb); } void main() { @@ -113,11 +118,16 @@ void main() { if (u_crt.effects.x <= 0.5) { // The scene texture is already sRGB. Avoid a needless transfer-curve // round trip so a coordinate-only effect preserves theme bytes. - o_col = vec4(clamp(sceneSrgb(uv), 0.0, 1.0), 1.0); + vec4 s = sceneSrgb(uv); + o_col = vec4(clamp(s.rgb, 0.0, 1.0), clamp(s.a, 0.0, 1.0)); return; } vec3 col = vec3(0.0); + // Outside the tube nothing is drawn, so nothing is covered either: the + // old opaque black there would have punched a rectangle out of the + // compositor's backdrop. + float alpha = 0.0; float edge = min(min(uv.x, uv.y), min(1.0 - uv.x, 1.0 - uv.y)); if (edge > 0.0) { vec3 center = effectSceneLinear(uv); @@ -153,10 +163,13 @@ void main() { float vignette = 1.0 - VIGNETTE_STRENGTH * pow(clamp(r2 * 0.5, 0.0, 1.0), 1.6); float hum = 1.0 + HUM_STRENGTH * sin((uv.y * 1.35 - u_crt.time_seconds * 0.11) * TAU); col *= tube * vignette * hum * EXPOSURE; + // The tube's edge falloff dims coverage as well as colour; everything + // else here is a light adjustment and leaves it alone. + alpha = sceneSrgb(uv).a * tube; float luma = dot(col, vec3(0.2126, 0.7152, 0.0722)); vec2 noise_seed = gl_FragCoord.xy + vec2(u_crt.frame * 17.0, u_crt.frame * 59.0); col += (noiseAt(noise_seed) - 0.5) * NOISE_STRENGTH * (0.15 + 0.85 * clamp(luma, 0.0, 1.0)); } - o_col = vec4(linearToSrgb(clamp(col, 0.0, 1.0)), 1.0); + o_col = vec4(linearToSrgb(clamp(col, 0.0, 1.0)), clamp(alpha, 0.0, 1.0)); } |
