diff --git a/libs/video/renderer/sw/d_sky.c b/libs/video/renderer/sw/d_sky.c index 853a3e0e0..c6cd5832d 100644 --- a/libs/video/renderer/sw/d_sky.c +++ b/libs/video/renderer/sw/d_sky.c @@ -42,14 +42,16 @@ D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t) { float wu, wv, temp; vec3_t end; + int half_width = vid.width >> 1; + int half_height = vid.height >> 1; if (r_refdef.vrect.width >= r_refdef.vrect.height) temp = (float) r_refdef.vrect.width; else temp = (float) r_refdef.vrect.height; - wu = 8192.0 * (float) (u - (vid.width >> 1)) / temp; - wv = 8192.0 * (float) ((vid.height >> 1) - v) / temp; + wu = 8192.0 * (float) (u - half_width) / temp; + wv = 8192.0 * (float) (half_height - v) / temp; end[0] = 4096 * vpn[0] + wu * vright[0] + wv * vup[0]; end[1] = 4096 * vpn[1] + wu * vright[1] + wv * vup[1]; diff --git a/libs/video/renderer/sw32/d_sky.c b/libs/video/renderer/sw32/d_sky.c index 989fd4369..b9c03b5a0 100644 --- a/libs/video/renderer/sw32/d_sky.c +++ b/libs/video/renderer/sw32/d_sky.c @@ -47,14 +47,16 @@ D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t) { float wu, wv, temp; vec3_t end; + int half_width = vid.width >> 1; + int half_height = vid.height >> 1; if (r_refdef.vrect.width >= r_refdef.vrect.height) temp = (float) r_refdef.vrect.width; else temp = (float) r_refdef.vrect.height; - wu = 8192.0 * (float) (u - (vid.width >> 1)) / temp; - wv = 8192.0 * (float) ((vid.height >> 1) - v) / temp; + wu = 8192.0 * (float) (u - half_width) / temp; + wv = 8192.0 * (float) (half_height - v) / temp; end[0] = 4096 * vpn[0] + wu * vright[0] + wv * vup[0]; end[1] = 4096 * vpn[1] + wu * vright[1] + wv * vup[1];