From c17db807349d400fb9bc6cac5bd28b15bb4b9329 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 8 Sep 2019 01:00:57 +0000 Subject: [PATCH] Fix npot sky rendering in Polymost Patch from Nuke.YKT. git-svn-id: https://svn.eduke32.com/eduke32@8076 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/build/src/polymost.cpp --- source/build/src/polymost.cpp | 56 +++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index ee48d97b1..2718531af 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -3982,8 +3982,6 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i flatskyrender = 0; vec2f_t xys[8]; - polymost_setClamp(2); - // Transform polygon to sky coordinates for (int i = 0; i < n; i++) { @@ -4028,6 +4026,11 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i if (xys[i].x > x1) x1 = xys[i].x; } + int const npot = (1<<(picsiz[globalpicnum]&15)) != tilesiz[globalpicnum].x; + int const xpanning = (r_parallaxskypanning?global_cf_xpanning:0); + + polymost_setClamp((npot || xpanning != 0) ? 0 : 2); + int picnumbak = globalpicnum; ti = globalpicnum; o.y = fviewingrange/(ghalfx*256.f); o.z = 1.f/o.y; @@ -4038,7 +4041,14 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i do { globalpicnum = dapskyoff[y&((1<floorypanning*(float)i*(1.f/256.f) : vv[0]; - int const npot = (1 << (picsiz[globalpicnum] & 15)) != tilesiz[globalpicnum].x; + int const npot = (1<<(picsiz[globalpicnum]&15)) != tilesiz[globalpicnum].x; + int const xpanning = (r_parallaxskypanning?sec->floorxpanning:0); i = globalpicnum; float const r = (fy1-fy0)/(x1-x0); //slope of line @@ -4399,15 +4411,14 @@ static void polymost_drawalls(int32_t const bunch) do { globalpicnum = dapskyoff[y&((1<floorxpanning:0)) - xtex.u*ghalfx; - else - { - int32_t picbits = picsiz[globalpicnum]&15; - int32_t np2 = tilesiz[globalpicnum].x != (1<floorxpanning:0)) - xtex.u*ghalfx; - } + if (npot) + { + fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx; + int tang = (y<<(11-dapskybits))&2047; + otex.u = otex.d*(t*((float)(tang)) * (1.f/2048.f) + xpanning) - xtex.u*fx; + } + else + otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + xpanning) - xtex.u*ghalfx; y++; o.x = fx; fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx; if (fx > x1) { fx = x1; i = -1; } @@ -4746,7 +4757,8 @@ static void polymost_drawalls(int32_t const bunch) ytex.v = vv[1]; otex.v = r_parallaxskypanning ? vv[0] + dd*(float)sec->ceilingypanning*(float)i*(1.f/256.f) : vv[0]; - int const npot = (1 << (picsiz[globalpicnum] & 15)) != tilesiz[globalpicnum].x; + int const npot = (1<<(picsiz[globalpicnum]&15)) != tilesiz[globalpicnum].x; + int const xpanning = (r_parallaxskypanning?sec->ceilingxpanning:0); i = globalpicnum; float const r = (cy1-cy0)/(x1-x0); //slope of line @@ -4757,14 +4769,14 @@ static void polymost_drawalls(int32_t const bunch) do { globalpicnum = dapskyoff[y&((1<ceilingxpanning:0)) - xtex.u*ghalfx; - else - { - int32_t picbits = picsiz[globalpicnum]&15; - int32_t np2 = tilesiz[globalpicnum].x != (1<ceilingxpanning:0)) - xtex.u*ghalfx; - } + if (npot) + { + fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx; + int tang = (y<<(11-dapskybits))&2047; + otex.u = otex.d*(t*((float)(tang)) * (1.f/2048.f) + xpanning) - xtex.u*fx; + } + else + otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + xpanning) - xtex.u*ghalfx; y++; o.x = fx; fx = (((float) (y<<(11-dapskybits))-fglobalang))*o.z+ghalfx; if (fx > x1) { fx = x1; i = -1; }