Pushing all my work to make OpenGL consistent with my changes to software's sky so far

This commit is contained in:
Monster Iestyn 2018-02-01 22:04:04 +00:00
parent 9e4c985d70
commit ecf2eed37f

View file

@ -1409,9 +1409,9 @@ static void HWR_SplitFog(sector_t *sector, wallVert3D *wallVerts, FSurfaceInfo*
HWR_AddTransparentWall(wallVerts, Surf, 0, PF_Translucent|PF_NoTexture, true, lightnum, colormap); HWR_AddTransparentWall(wallVerts, Surf, 0, PF_Translucent|PF_NoTexture, true, lightnum, colormap);
} }
// HWR_DrawSkyWalls // HWR_DrawSkyWall
// Draw walls into the depth buffer so that anything behind is culled properly // Draw walls into the depth buffer so that anything behind is culled properly
static void HWR_DrawSkyWall(wallVert3D *wallVerts, FSurfaceInfo *Surf, fixed_t bottom, fixed_t top) static void HWR_DrawSkyWall(wallVert3D *wallVerts, FSurfaceInfo *Surf)
{ {
HWD.pfnSetTexture(NULL); HWD.pfnSetTexture(NULL);
// no texture // no texture
@ -1419,9 +1419,7 @@ static void HWR_DrawSkyWall(wallVert3D *wallVerts, FSurfaceInfo *Surf, fixed_t b
wallVerts[0].t = wallVerts[1].t = 0; wallVerts[0].t = wallVerts[1].t = 0;
wallVerts[0].s = wallVerts[3].s = 0; wallVerts[0].s = wallVerts[3].s = 0;
wallVerts[2].s = wallVerts[1].s = 0; wallVerts[2].s = wallVerts[1].s = 0;
// set top/bottom coords // this no longer sets top/bottom coords, this should be done before caling the function
wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(top); // No real way to find the correct height of this
wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(bottom); // worldlow/bottom because it needs to cover up the lower thok barrier wall
HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_Clip|PF_NoTexture, 255, NULL); HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_Clip|PF_NoTexture, 255, NULL);
// PF_Invisible so it's not drawn into the colour buffer // PF_Invisible so it's not drawn into the colour buffer
// PF_NoTexture for no texture // PF_NoTexture for no texture
@ -1542,8 +1540,9 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
if (gr_backsector) if (gr_backsector)
{ {
INT32 gr_toptexture, gr_bottomtexture; INT32 gr_toptexture = 0, gr_bottomtexture = 0;
// two sided line // two sided line
boolean bothceilingssky = false; // turned on if both back and front ceilings are sky
#ifdef ESLOPE #ifdef ESLOPE
SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight)
@ -1559,12 +1558,14 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
if (gr_frontsector->ceilingpic == skyflatnum && if (gr_frontsector->ceilingpic == skyflatnum &&
gr_backsector->ceilingpic == skyflatnum) gr_backsector->ceilingpic == skyflatnum)
{ {
worldtop = worldhigh; bothceilingssky = true;
//worldtop = worldhigh;
#ifdef ESLOPE #ifdef ESLOPE
worldtopslope = worldhighslope; //worldtopslope = worldhighslope;
#endif #endif
} }
if (!bothceilingssky)
gr_toptexture = R_GetTextureNum(gr_sidedef->toptexture); gr_toptexture = R_GetTextureNum(gr_sidedef->toptexture);
gr_bottomtexture = R_GetTextureNum(gr_sidedef->bottomtexture); gr_bottomtexture = R_GetTextureNum(gr_sidedef->bottomtexture);
@ -2008,84 +2009,42 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
}*/ }*/
} }
// Isn't this just the most lovely mess #if 1
// Sky culling
// No longer so much a mess as before!
if (!gr_curline->polyseg) // Don't do it for polyobjects if (!gr_curline->polyseg) // Don't do it for polyobjects
{ {
if (gr_frontsector->ceilingpic == skyflatnum || gr_backsector->ceilingpic == skyflatnum) if (gr_frontsector->ceilingpic == skyflatnum)
{ {
fixed_t depthwallheight; if (gr_backsector->ceilingpic != skyflatnum) // don't cull if back sector is also sky
{
wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space
#ifdef ESLOPE
wallVerts[0].y = FIXED_TO_FLOAT(worldtop);
wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope);
#else
wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop);
#endif
HWR_DrawSkyWall(wallVerts, &Surf);
}
}
if (!gr_sidedef->toptexture || (gr_frontsector->ceilingpic == skyflatnum && gr_backsector->ceilingpic == skyflatnum)) // when both sectors are sky, the top texture isn't drawn if (gr_frontsector->floorpic == skyflatnum)
depthwallheight = gr_frontsector->ceilingheight < gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight;
else
depthwallheight = gr_frontsector->ceilingheight > gr_backsector->ceilingheight ? gr_frontsector->ceilingheight : gr_backsector->ceilingheight;
if (gr_frontsector->ceilingheight-gr_frontsector->floorheight <= 0) // current sector is a thok barrier
{ {
if (gr_backsector->ceilingheight-gr_backsector->floorheight <= 0) // behind sector is also a thok barrier if (gr_backsector->floorpic != skyflatnum) // don't cull if back sector is also sky
{ {
if (!gr_sidedef->bottomtexture) // Only extend further down if there's no texture #ifdef ESLOPE
HWR_DrawSkyWall(wallVerts, &Surf, worldbottom < worldlow ? worldbottom : worldlow, INT32_MAX); wallVerts[3].y = FIXED_TO_FLOAT(worldbottom);
else wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope);
HWR_DrawSkyWall(wallVerts, &Surf, worldbottom > worldlow ? worldbottom : worldlow, INT32_MAX); #else
} wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldbottom);
// behind sector is not a thok barrier #endif
else if (gr_backsector->ceilingheight <= gr_frontsector->ceilingheight) // behind sector ceiling is lower or equal to current sector wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); // draw to bottom of map space
HWR_DrawSkyWall(wallVerts, &Surf, depthwallheight, INT32_MAX); HWR_DrawSkyWall(wallVerts, &Surf);
// gr_front/backsector heights need to be used here because of the worldtop being set to worldhigh earlier on
}
else if (gr_backsector->ceilingheight-gr_backsector->floorheight <= 0) // behind sector is a thok barrier, current sector is not
{
if (gr_backsector->ceilingheight >= gr_frontsector->ceilingheight // thok barrier ceiling height is equal to or greater than current sector ceiling height
|| gr_backsector->floorheight <= gr_frontsector->floorheight // thok barrier ceiling height is equal to or less than current sector floor height
|| gr_backsector->ceilingpic != skyflatnum) // thok barrier is not a sky
HWR_DrawSkyWall(wallVerts, &Surf, depthwallheight, INT32_MAX);
}
else // neither sectors are thok barriers
{
if ((gr_backsector->ceilingheight < gr_frontsector->ceilingheight && !gr_sidedef->toptexture) // no top texture and sector behind is lower
|| gr_backsector->ceilingpic != skyflatnum) // behind sector is not a sky
HWR_DrawSkyWall(wallVerts, &Surf, depthwallheight, INT32_MAX);
}
}
// And now for sky floors!
if (gr_frontsector->floorpic == skyflatnum || gr_backsector->floorpic == skyflatnum)
{
fixed_t depthwallheight;
if (!gr_sidedef->bottomtexture)
depthwallheight = worldbottom > worldlow ? worldbottom : worldlow;
else
depthwallheight = worldbottom < worldlow ? worldbottom : worldlow;
if (gr_frontsector->ceilingheight-gr_frontsector->floorheight <= 0) // current sector is a thok barrier
{
if (gr_backsector->ceilingheight-gr_backsector->floorheight <= 0) // behind sector is also a thok barrier
{
if (!gr_sidedef->toptexture) // Only extend up if there's no texture
HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, worldtop > worldhigh ? worldtop : worldhigh);
else
HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, worldtop < worldhigh ? worldtop : worldhigh);
}
// behind sector is not a thok barrier
else if (gr_backsector->floorheight >= gr_frontsector->floorheight) // behind sector floor is greater or equal to current sector
HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, depthwallheight);
}
else if (gr_backsector->ceilingheight-gr_backsector->floorheight <= 0) // behind sector is a thok barrier, current sector is not
{
if (gr_backsector->floorheight <= gr_frontsector->floorheight // thok barrier floor height is equal to or less than current sector floor height
|| gr_backsector->ceilingheight >= gr_frontsector->ceilingheight // thok barrier floor height is equal to or greater than current sector ceiling height
|| gr_backsector->floorpic != skyflatnum) // thok barrier is not a sky
HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, depthwallheight);
}
else // neither sectors are thok barriers
{
if ((gr_backsector->floorheight > gr_frontsector->floorheight && !gr_sidedef->bottomtexture) // no bottom texture and sector behind is higher
|| gr_backsector->floorpic != skyflatnum) // behind sector is not a sky
HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, depthwallheight);
} }
} }
} }
#endif
} }
else else
{ {
@ -2156,9 +2115,27 @@ static void HWR_StoreWallRange(double startfrac, double endfrac)
if (!gr_curline->polyseg) if (!gr_curline->polyseg)
{ {
if (gr_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector if (gr_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector
HWR_DrawSkyWall(wallVerts, &Surf, worldtop, INT32_MAX); {
wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space
#ifdef ESLOPE
wallVerts[0].y = FIXED_TO_FLOAT(worldtop);
wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope);
#else
wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(worldtop);
#endif
HWR_DrawSkyWall(wallVerts, &Surf);
}
if (gr_frontsector->floorpic == skyflatnum) if (gr_frontsector->floorpic == skyflatnum)
HWR_DrawSkyWall(wallVerts, &Surf, INT32_MIN, worldbottom); {
#ifdef ESLOPE
wallVerts[3].y = FIXED_TO_FLOAT(worldbottom);
wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope);
#else
wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(worldbottom);
#endif
wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); // draw to bottom of map space
HWR_DrawSkyWall(wallVerts, &Surf);
}
} }
} }
@ -2483,16 +2460,15 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks
backf1 = backf2 = abacksector->floorheight; backf1 = backf2 = abacksector->floorheight;
backc1 = backc2 = abacksector->ceilingheight; backc1 = backc2 = abacksector->ceilingheight;
} }
// properly render skies (consider door "open" if both ceilings are sky)
if (abacksector->ceilingpic != skyflatnum || afrontsector->ceilingpic != skyflatnum)
{
// now check for closed sectors! // now check for closed sectors!
if (backc1 <= frontf1 && backc2 <= frontf2) if (backc1 <= frontf1 && backc2 <= frontf2)
{ {
checkforemptylines = false; checkforemptylines = false;
if (!seg->sidedef->toptexture) //if (!seg->sidedef->toptexture)
return false; //return false;
if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum)
return false;
return true; return true;
} }
@ -2500,38 +2476,23 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks
if (backf1 >= frontc1 && backf2 >= frontc2) if (backf1 >= frontc1 && backf2 >= frontc2)
{ {
checkforemptylines = false; checkforemptylines = false;
if (!seg->sidedef->bottomtexture) //if (!seg->sidedef->bottomtexture)
return false; //return false;
// properly render skies (consider door "open" if both floors are sky):
if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum)
return false;
return true; return true;
} }
if (backc1 <= backf1 && backc2 <= backf2) if (backc1 <= backf1 && backc2 <= backf2)
{ {
checkforemptylines = false;
// preserve a kind of transparent door/lift special effect: // preserve a kind of transparent door/lift special effect:
if (backc1 < frontc1 || backc2 < frontc2) if (((backc1 >= frontc1 && backc2 >= frontc2) || seg->sidedef->toptexture)
&& ((backf1 <= frontf1 && backf2 <= frontf2) || seg->sidedef->bottomtexture))
{ {
if (!seg->sidedef->toptexture) checkforemptylines = false;
return false;
}
if (backf1 > frontf1 || backf2 > frontf2)
{
if (!seg->sidedef->bottomtexture)
return false;
}
if (abacksector->ceilingpic == skyflatnum && afrontsector->ceilingpic == skyflatnum)
return false;
if (abacksector->floorpic == skyflatnum && afrontsector->floorpic == skyflatnum)
return false;
return true; return true;
} }
}
}
if (backc1 != frontc1 || backc2 != frontc2 if (backc1 != frontc1 || backc2 != frontc2
|| backf1 != frontf1 || backf2 != frontf2) || backf1 != frontf1 || backf2 != frontf2)
@ -3008,6 +2969,8 @@ static void HWR_AddLine(seg_t * line)
SLOPEPARAMS( gr_backsector->c_slope, backc1, backc2, gr_backsector->ceilingheight) SLOPEPARAMS( gr_backsector->c_slope, backc1, backc2, gr_backsector->ceilingheight)
#undef SLOPEPARAMS #undef SLOPEPARAMS
if (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)
{
// Closed door. // Closed door.
if ((backc1 <= frontf1 && backc2 <= frontf2) if ((backc1 <= frontf1 && backc2 <= frontf2)
|| (backf1 >= frontc1 && backf2 >= frontc2)) || (backf1 >= frontc1 && backf2 >= frontc2))
@ -3019,8 +2982,10 @@ static void HWR_AddLine(seg_t * line)
if (backc1 <= backf1 && backc2 <= backf2 if (backc1 <= backf1 && backc2 <= backf2
&& ((backc1 >= frontc1 && backc2 >= frontc2) || gr_curline->sidedef->toptexture) && ((backc1 >= frontc1 && backc2 >= frontc2) || gr_curline->sidedef->toptexture)
&& ((backf1 <= frontf1 && backf2 >= frontf2) || gr_curline->sidedef->bottomtexture) && ((backf1 <= frontf1 && backf2 >= frontf2) || gr_curline->sidedef->bottomtexture)
&& (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)) //&& (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)
)
goto clipsolid; goto clipsolid;
}
// Window. // Window.
if (backc1 != frontc1 || backc2 != frontc2 if (backc1 != frontc1 || backc2 != frontc2
@ -3031,6 +2996,9 @@ static void HWR_AddLine(seg_t * line)
} }
else else
#endif #endif
{
if (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)
{ {
// Closed door. // Closed door.
if (gr_backsector->ceilingheight <= gr_frontsector->floorheight || if (gr_backsector->ceilingheight <= gr_frontsector->floorheight ||
@ -3041,8 +3009,10 @@ static void HWR_AddLine(seg_t * line)
if (gr_backsector->ceilingheight <= gr_backsector->floorheight if (gr_backsector->ceilingheight <= gr_backsector->floorheight
&& ((gr_backsector->ceilingheight >= gr_frontsector->ceilingheight) || gr_curline->sidedef->toptexture) && ((gr_backsector->ceilingheight >= gr_frontsector->ceilingheight) || gr_curline->sidedef->toptexture)
&& ((gr_backsector->floorheight <= gr_backsector->floorheight) || gr_curline->sidedef->bottomtexture) && ((gr_backsector->floorheight <= gr_backsector->floorheight) || gr_curline->sidedef->bottomtexture)
&& (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)) //&& (gr_backsector->ceilingpic != skyflatnum || gr_frontsector->ceilingpic != skyflatnum)
)
goto clipsolid; goto clipsolid;
}
// Window. // Window.
if (gr_backsector->ceilingheight != gr_frontsector->ceilingheight || if (gr_backsector->ceilingheight != gr_frontsector->ceilingheight ||