commit 692ac0da8f8300c6a61f49cf7d51f7f448ec7b7c
Author: jens <jens.se@icloud.com>
AuthorDate: Sat Aug 22 09:39:03 2026 +0200
Commit: jens <jens.se@icloud.com>
CommitDate: Sat Aug 22 09:39:03 2026 +0200
Fix sky texture offset from the larger screen buffer
skytexturemid (r_sky.c) was computed as SCREENHEIGHT/2*FRACUNIT, but
SCREENHEIGHT is no longer the same as the resolution the game's fixed-
point math was calibrated for (see i_video.h) - it's real screen
pixels, twice ORIGHEIGHT.
The sky column drawer (r_plane.c) computes
dc_texturemid + (dc_yl - centery) * dc_iscale. dc_iscale is already
scaled down in proportion to the larger real view (see pspriteiscale
in r_main.c), which exactly cancels (dc_yl - centery) being scaled up
by that same amount - so this additive base term needs to stay in
original vanilla-sized terms too. Using SCREENHEIGHT there added an
extra, unwanted offset to every sky column, which - since sky sampling
wraps at the texture's actual height - showed up as the sky shifting
down and seaming/duplicating partway down the screen instead of
wrapping cleanly at the top.
Changed to ORIGHEIGHT/2*FRACUNIT (the original vanilla constant,
100*FRACUNIT). Verified in E1M1 with noclip: the sky now renders as a
single coherent mountain skyline with no visible seam.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---
src/doom/r_sky.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/doom/r_sky.c b/src/doom/r_sky.c
index bcd5a75b..709bc9cd 100644
--- a/src/doom/r_sky.c
+++ b/src/doom/r_sky.c
@@ -28,6 +28,8 @@
// Needed for Flat retrieval.
#include "r_data.h"
+// Needed for ORIGHEIGHT.
+#include "i_video.h"
#include "r_sky.h"
@@ -47,6 +49,15 @@ int skytexturemid;
void R_InitSkyMap (void)
{
// skyflatnum = R_FlatNumForName ( SKYFLATNAME );
- skytexturemid = SCREENHEIGHT/2*FRACUNIT;
+ // Deliberately ORIGHEIGHT, not SCREENHEIGHT (see i_video.h for why
+ // they differ now): the column drawer computes
+ // dc_texturemid + (dc_yl - centery) * dc_iscale, and dc_iscale is
+ // already scaled down in proportion to the real view being bigger
+ // (see pspriteiscale in r_main.c), which cancels out (dc_yl -
+ // centery) being scaled up by that same real view size - so this
+ // additive base term needs to stay in the original vanilla-sized
+ // terms too, or every sky column ends up offset by the difference,
+ // wrapping (and so visibly seaming/duplicating) at the wrong row.
+ skytexturemid = ORIGHEIGHT/2*FRACUNIT;
}