From 316b234b093cfef642c8583ea55a240ac783694f Mon Sep 17 00:00:00 2001 From: BearOso Date: Sun, 29 Jan 2023 18:40:20 -0600 Subject: [PATCH] crt-royale: Fix division by zero when border is 0. When border size is 0, a division by zero causes the border to become infinitely large. Special-case this. --- crt/shaders/crt-royale/src/geometry-functions.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crt/shaders/crt-royale/src/geometry-functions.h b/crt/shaders/crt-royale/src/geometry-functions.h index ed5a7f8..9e7bfa0 100644 --- a/crt/shaders/crt-royale/src/geometry-functions.h +++ b/crt/shaders/crt-royale/src/geometry-functions.h @@ -679,6 +679,8 @@ float get_border_dim_factor(const float2 video_uv, const float2 geom_aspect) const float2 border_penetration = max(float2(border_size) - edge_dists, float2(0.0)); const float penetration_ratio = length(border_penetration)/border_size; + if (border_size == 0.0) + penetration_ratio = 0.0; const float border_escape_ratio = max(1.0 - penetration_ratio, 0.0); const float border_dim_factor = pow(border_escape_ratio, border_darkness) * max(1.0, border_compress);