diff --git a/kitty/shaders/custom/bloom.slang b/kitty/shaders/custom/bloom.slang index 35eca3ffc..3f574843d 100644 --- a/kitty/shaders/custom/bloom.slang +++ b/kitty/shaders/custom/bloom.slang @@ -37,9 +37,9 @@ static const float3 samples[24] = { }; // minimum luminance for a pixel to contribute bloom -extern static const float bloom_threshold = 0.2f; +extern static const float BLOOM_THRESHOLD = 0.2f; // strength of the bloom contribution -extern static const float bloom_strength = 0.2f; +extern static const float BLOOM_STRENGTH = 0.2f; float lum(float4 c) { return 0.299f * c.r + 0.587f * c.g + 0.114f * c.b; @@ -64,7 +64,7 @@ public float4 fragment_main( float3 s = samples[i]; float4 sc = t.backbuffer.Sample(uv + s.xy * step); float l = lum(sc); - result += (float4)(l * s.z * sc * bloom_strength) * ::step(bloom_threshold, l); + result += (float4)(l * s.z * sc * BLOOM_STRENGTH) * ::step(BLOOM_THRESHOLD, l); } return result; diff --git a/kitty/shaders/custom/crt.slang b/kitty/shaders/custom/crt.slang index ec0c607f2..1bd5c025f 100644 --- a/kitty/shaders/custom/crt.slang +++ b/kitty/shaders/custom/crt.slang @@ -9,9 +9,9 @@ import kitty_custom_shader_types; -extern static const float warp = 0.25f; // simulates curvature of CRT monitor -extern static const float scan = 0.50f; // simulates darkness between scanlines -extern static const float4 tint = float4(0, 0.8, 0.6, 0); // tint color set the fourth component to 1 to apply it fully +extern static const float WARP = 0.25f; // simulates curvature of CRT monitor +extern static const float SCAN = 0.50f; // simulates darkness between scanlines +extern static const float4 TINT = float4(0, 0.8, 0.6, 0); // tint color set the fourth component to 1 to apply it fully public float4 fragment_main( float4 color, @@ -28,20 +28,20 @@ public float4 fragment_main( dc *= dc; // Warp UV to simulate CRT screen curvature - uv.x -= 0.5f; uv.x *= 1.0f + (dc.y * (0.3f * warp)); uv.x += 0.5f; - uv.y -= 0.5f; uv.y *= 1.0f + (dc.x * (0.4f * warp)); uv.y += 0.5f; + uv.x -= 0.5f; uv.x *= 1.0f + (dc.y * (0.3f * WARP)); uv.x += 0.5f; + uv.y -= 0.5f; uv.y *= 1.0f + (dc.x * (0.4f * WARP)); uv.y += 0.5f; // Original Y pixel coordinate within the viewport (for scanline phase) float fragCoordY = (t.pos.y - viewport.y) * float(d.viewport_size_pixels.y); // Scanline darkness at this pixel row - float apply = abs(sin(fragCoordY) * 0.25f * scan); + float apply = abs(sin(fragCoordY) * 0.25f * SCAN); // Sample the backbuffer at the warped viewport UV float2 sample_uv = viewport.xy + uv * viewport.zw; float3 col = t.backbuffer.Sample(sample_uv).rgb; // apply the tint - col = lerp(col, col * tint.rgb, tint.a); + col = lerp(col, col * TINT.rgb, TINT.a); // since this shaders moves pixels around it cannot work with alpha < 1 return float4(lerp(col, float3(0.0f), apply), 1); diff --git a/kitty/shaders/custom/tft.slang b/kitty/shaders/custom/tft.slang index 187387c37..a76a8a674 100644 --- a/kitty/shaders/custom/tft.slang +++ b/kitty/shaders/custom/tft.slang @@ -7,15 +7,15 @@ import kitty_custom_shader_types; // size of the simulated pixels -extern static const float resolution = 4.0; +extern static const float RESOLUTION = 4.0; // strength of the effect -extern static const float strength = 0.5; +extern static const float STRENGTH = 0.5; void scanline(inout float3 color, float2 pixel_pos) { - float scanline = step(1.2, fmod(pixel_pos.y, resolution)); - float grille = step(1.2, fmod(pixel_pos.x, resolution)); - color *= max(1.0 - strength, scanline * grille); + float scanline = step(1.2, fmod(pixel_pos.y, RESOLUTION)); + float grille = step(1.2, fmod(pixel_pos.x, RESOLUTION)); + color *= max(1.0 - STRENGTH, scanline * grille); } public float4 fragment_main(