From 49569ffb25a45e7f7839e985cb0418263c494837 Mon Sep 17 00:00:00 2001 From: zoncabe Date: Mon, 14 Sep 2026 16:44:35 -0300 Subject: [PATCH] fix: fog range starts and saturates at twice the declared distance --- src/t3d/t3d.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/t3d/t3d.c b/src/t3d/t3d.c index 689d4067..111d97db 100644 --- a/src/t3d/t3d.c +++ b/src/t3d/t3d.c @@ -565,8 +565,9 @@ void t3d_fog_set_range(float near, float far) { } // @TODO: refactor in the ucode (right now it's offset and then scale) - float scale = 16384.0f / diff; - float offset = -near * 2.0f; + // offset cancels near, scale spans the full s16 over the range + float scale = 32768.0f / diff; + float offset = -near; scale = fm_floorf(scale); scale = CLAMP(scale, -32768.0f, 32767.0f);