From cca5c9f6779edfa3aa0889f9c0fc59738e238fee Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Tue, 15 Jul 2025 12:32:47 +0200 Subject: [PATCH] Tweak shader settings for ghostty, make it less annoying. --- ghostty/shaders/bettercrt.glsl | 4 ++-- ghostty/shaders/bloom.glsl | 2 +- ghostty/shaders/cursor_smear.glsl | 33 +++++++++++++++++-------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ghostty/shaders/bettercrt.glsl b/ghostty/shaders/bettercrt.glsl index d0593e3..a38af1c 100644 --- a/ghostty/shaders/bettercrt.glsl +++ b/ghostty/shaders/bettercrt.glsl @@ -8,8 +8,8 @@ // - Removed tint // - Made the boundaries match ghostty's background color -float warp = 0.115; // simulate curvature of CRT monitor -float scan = 0.2; // simulate darkness between scanlines +float warp = 0.07; // simulate curvature of CRT monitor +float scan = 0.125; // simulate darkness between scanlines void mainImage(out vec4 fragColor, in vec2 fragCoord) { diff --git a/ghostty/shaders/bloom.glsl b/ghostty/shaders/bloom.glsl index 2da4915..855d86f 100644 --- a/ghostty/shaders/bloom.glsl +++ b/ghostty/shaders/bloom.glsl @@ -44,7 +44,7 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) { vec4 c = texture(iChannel0, uv + s.xy * step); float l = lum(c); if (l > 0.2) { - color += l * s.z * c * 0.0075; + color += l * s.z * c * 0.0035; } } diff --git a/ghostty/shaders/cursor_smear.glsl b/ghostty/shaders/cursor_smear.glsl index 789639b..92ba6bc 100644 --- a/ghostty/shaders/cursor_smear.glsl +++ b/ghostty/shaders/cursor_smear.glsl @@ -64,9 +64,10 @@ vec4 saturate(vec4 color, float factor) { } vec4 TRAIL_COLOR = iCurrentCursorColor; -const float OPACITY = 0.6; +const float OPACITY = 0.325; const float DURATION = 0.2; //IN SECONDS const float MAX_TRAIL_LENGTH = 0.6; +const float TRAIL_HEIGHT_FACTOR = 0.4; void mainImage(out vec4 fragColor, in vec2 fragCoord) { @@ -110,9 +111,13 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) trailStartPoint = prevCursorCenter; } - // Set vertices for the current cursor (full width) - vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, currentCursor.y - currentCursor.w); - vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, currentCursor.y); + // Calculate cursor center for thinner trail + vec2 cursorCenter = currentCursor.xy - (currentCursor.zw * offsetFactor); + float reducedHeight = currentCursor.w * TRAIL_HEIGHT_FACTOR; + + // Set vertices for a thinner trail (reduced height) + vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, cursorCenter.y - reducedHeight * 0.5); + vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, cursorCenter.y + reducedHeight * 0.5); // This creates the triangular shape with the point at the trail cutoff vec2 v2 = trailStartPoint; @@ -122,23 +127,21 @@ void mainImage(out vec4 fragColor, in vec2 fragCoord) float progress = clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1.0); float easedProgress = ease(progress); - - // We already calculated these values earlier - // Distance between cursors determine the total length of the parallelogram; - // vec2 centerCC = getRectangleCenter(currentCursor); - // vec2 centerCP = getRectangleCenter(previousCursor); - // float lineLength = distance(centerCC, centerCP); - // float cappedlinelength = min(lineLength, MAX_TRAIL_LENGTH); vec4 newColor = vec4(fragColor); vec4 trail = TRAIL_COLOR; trail = saturate(trail, 2.5); - // Draw trail - newColor = mix(newColor, trail, antialising(sdfTrail)); + trail.a *= OPACITY; // Apply transparency to the trail + + // Draw trail with transparency + float trailMask = antialising(sdfTrail); + newColor = mix(newColor, trail, trailMask * OPACITY); + // Draw current cursor newColor = mix(newColor, trail, antialising(sdfCurrentCursor)); newColor = mix(newColor, fragColor, step(sdfCurrentCursor, 0.)); - // Apply the trail effect - fragColor = mix(fragColor, newColor, step(sdfCurrentCursor, easedProgress * cappedlinelength)); + + // Apply the trail effect with transparency + fragColor = mix(fragColor, newColor, step(sdfCurrentCursor, easedProgress * cappedlinelength) * OPACITY); }