Partially port newer sky rendering

Not the cause of the black sky bug, but doing this helped me diagnose it & it's cleaner
This commit is contained in:
Sally Coolatta 2022-05-01 21:48:48 -04:00 committed by Eidolon
parent 266264b1cf
commit d353252531
2 changed files with 52 additions and 47 deletions

View file

@ -69,7 +69,7 @@ fixed_t viewx, viewy, viewz;
angle_t viewangle, aimingangle; angle_t viewangle, aimingangle;
UINT8 viewssnum; UINT8 viewssnum;
fixed_t viewcos, viewsin; fixed_t viewcos, viewsin;
boolean viewsky, skyVisible; boolean skyVisible;
boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible for each splitscreen player boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible for each splitscreen player
sector_t *viewsector; sector_t *viewsector;
player_t *viewplayer; player_t *viewplayer;

View file

@ -27,6 +27,7 @@
#include "w_wad.h" #include "w_wad.h"
#include "z_zone.h" #include "z_zone.h"
#include "p_tick.h" #include "p_tick.h"
#include "r_fps.h"
#ifdef TIMING #ifdef TIMING
#include "p5prof.h" #include "p5prof.h"
@ -678,8 +679,6 @@ void R_MakeSpans(INT32 x, INT32 t1, INT32 b1, INT32 t2, INT32 b2)
void R_DrawPlanes(void) void R_DrawPlanes(void)
{ {
visplane_t *pl; visplane_t *pl;
INT32 x;
INT32 angle;
INT32 i; INT32 i;
spanfunc = basespanfunc; spanfunc = basespanfunc;
@ -689,50 +688,7 @@ void R_DrawPlanes(void)
{ {
for (pl = visplanes[i]; pl; pl = pl->next) for (pl = visplanes[i]; pl; pl = pl->next)
{ {
// sky flat if (pl->ffloor != NULL || pl->polyobj != NULL)
if (pl->picnum == skyflatnum)
{
if (!viewsky)
{
skyVisible = true;
continue;
}
// use correct aspect ratio scale
dc_iscale = skyscale;
// Sky is always drawn full bright,
// i.e. colormaps[0] is used.
// Because of this hack, sky is not affected
// by INVUL inverse mapping.
dc_colormap = colormaps;
if (encoremap)
dc_colormap += (256*32);
dc_texturemid = skytexturemid;
dc_texheight = textureheight[skytexture]
>>FRACBITS;
for (x = pl->minx; x <= pl->maxx; x++)
{
dc_yl = pl->top[x];
dc_yh = pl->bottom[x];
if (dc_yl <= dc_yh)
{
angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT));
dc_x = x;
dc_source =
R_GetColumn(texturetranslation[skytexture],
angle);
wallcolfunc();
}
}
continue;
}
if (pl->ffloor != NULL
|| pl->polyobj != NULL
)
continue; continue;
R_DrawSinglePlane(pl); R_DrawSinglePlane(pl);
@ -744,6 +700,48 @@ void R_DrawPlanes(void)
#endif #endif
} }
static void R_DrawSkyPlane(visplane_t *pl)
{
INT32 x;
INT32 angle;
if (!newview->sky)
{
skyVisible = true;
return;
}
wallcolfunc = walldrawerfunc;
// use correct aspect ratio scale
dc_iscale = skyscale;
// Sky is always drawn full bright,
// i.e. colormaps[0] is used.
// Because of this hack, sky is not affected
// by INVUL inverse mapping.
dc_colormap = colormaps;
if (encoremap)
dc_colormap += (256*32);
dc_texturemid = skytexturemid;
dc_texheight = textureheight[skytexture]
>>FRACBITS;
for (x = pl->minx; x <= pl->maxx; x++)
{
dc_yl = pl->top[x];
dc_yh = pl->bottom[x];
if (dc_yl <= dc_yh)
{
angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT));
dc_x = x;
dc_source =
R_GetColumn(texturetranslation[skytexture],
angle);
wallcolfunc();
}
}
}
void R_DrawSinglePlane(visplane_t *pl) void R_DrawSinglePlane(visplane_t *pl)
{ {
INT32 light = 0; INT32 light = 0;
@ -755,6 +753,13 @@ void R_DrawSinglePlane(visplane_t *pl)
if (!(pl->minx <= pl->maxx)) if (!(pl->minx <= pl->maxx))
return; return;
// sky flat
if (pl->picnum == skyflatnum)
{
R_DrawSkyPlane(pl);
return;
}
#ifndef NOWATER #ifndef NOWATER
itswater = false; itswater = false;
#endif #endif