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
This commit is contained in:
terminx 2019-09-08 01:00:57 +00:00 committed by Christoph Oelckers
parent d0a49c3278
commit c17db80734

View file

@ -3982,8 +3982,6 @@ static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, i
flatskyrender = 0; flatskyrender = 0;
vec2f_t xys[8]; vec2f_t xys[8];
polymost_setClamp(2);
// Transform polygon to sky coordinates // Transform polygon to sky coordinates
for (int i = 0; i < n; i++) 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; 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; int picnumbak = globalpicnum;
ti = globalpicnum; ti = globalpicnum;
o.y = fviewingrange/(ghalfx*256.f); o.z = 1.f/o.y; 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 do
{ {
globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+ti; globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+ti;
otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?global_cf_xpanning: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++; y++;
o.x = fx; fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx; o.x = fx; fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
@ -4321,6 +4331,7 @@ static void polymost_drawalls(int32_t const bunch)
skyclamphack = 0; skyclamphack = 0;
flatskyrender = 1; flatskyrender = 1;
globalshade += globvis2*xdimscale*fviewingrange*(1.f / (64.f * 65536.f * 256.f * 1024.f)); globalshade += globvis2*xdimscale*fviewingrange*(1.f / (64.f * 65536.f * 256.f * 1024.f));
polymost_setVisibility(0.f);
polymost_domost(x0,fy0,x1,fy1); polymost_domost(x0,fy0,x1,fy1);
flatskyrender = 0; flatskyrender = 0;
} }
@ -4388,7 +4399,8 @@ static void polymost_drawalls(int32_t const bunch)
ytex.v = vv[1]; ytex.v = vv[1];
otex.v = r_parallaxskypanning ? vv[0] + dd*(float)sec->floorypanning*(float)i*(1.f/256.f) : vv[0]; otex.v = r_parallaxskypanning ? vv[0] + dd*(float)sec->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; i = globalpicnum;
float const r = (fy1-fy0)/(x1-x0); //slope of line float const r = (fy1-fy0)/(x1-x0); //slope of line
@ -4399,15 +4411,14 @@ static void polymost_drawalls(int32_t const bunch)
do do
{ {
globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+i; globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+i;
if (!npot) if (npot)
{
otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->floorxpanning:0)) - xtex.u*ghalfx; fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
else int tang = (y<<(11-dapskybits))&2047;
{ otex.u = otex.d*(t*((float)(tang)) * (1.f/2048.f) + xpanning) - xtex.u*fx;
int32_t picbits = picsiz[globalpicnum]&15; }
int32_t np2 = tilesiz[globalpicnum].x != (1<<picbits); else
otex.u = otex.d*(t*((float)(fglobalang-(np2 ? 0 : (y<<(11-dapskybits))))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->floorxpanning:0)) - xtex.u*ghalfx; otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + xpanning) - xtex.u*ghalfx;
}
y++; y++;
o.x = fx; fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx; o.x = fx; fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
if (fx > x1) { fx = x1; i = -1; } if (fx > x1) { fx = x1; i = -1; }
@ -4746,7 +4757,8 @@ static void polymost_drawalls(int32_t const bunch)
ytex.v = vv[1]; ytex.v = vv[1];
otex.v = r_parallaxskypanning ? vv[0] + dd*(float)sec->ceilingypanning*(float)i*(1.f/256.f) : vv[0]; 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; i = globalpicnum;
float const r = (cy1-cy0)/(x1-x0); //slope of line float const r = (cy1-cy0)/(x1-x0); //slope of line
@ -4757,14 +4769,14 @@ static void polymost_drawalls(int32_t const bunch)
do do
{ {
globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+i; globalpicnum = dapskyoff[y&((1<<dapskybits)-1)]+i;
if (!npot) if (npot)
otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->ceilingxpanning:0)) - xtex.u*ghalfx; {
else fx = ((float)((y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
{ int tang = (y<<(11-dapskybits))&2047;
int32_t picbits = picsiz[globalpicnum]&15; otex.u = otex.d*(t*((float)(tang)) * (1.f/2048.f) + xpanning) - xtex.u*fx;
int32_t np2 = tilesiz[globalpicnum].x != (1<<picbits); }
otex.u = otex.d*(t*((float)(fglobalang-(np2 ? 0 : (y<<(11-dapskybits))))) * (1.f/2048.f) + (float)((r_parallaxskypanning)?sec->ceilingxpanning:0)) - xtex.u*ghalfx; else
} otex.u = otex.d*(t*((float)(fglobalang-(y<<(11-dapskybits)))) * (1.f/2048.f) + xpanning) - xtex.u*ghalfx;
y++; y++;
o.x = fx; fx = (((float) (y<<(11-dapskybits))-fglobalang))*o.z+ghalfx; o.x = fx; fx = (((float) (y<<(11-dapskybits))-fglobalang))*o.z+ghalfx;
if (fx > x1) { fx = x1; i = -1; } if (fx > x1) { fx = x1; i = -1; }