diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index d00b42918..80549f240 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -1383,7 +1383,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // two sided line if (gl_backsector) { - INT32 gl_toptexture = 0, gl_bottomtexture = 0; + const INT32 gl_toptexture = R_GetTextureNum(gl_sidedef->toptexture); + const INT32 gl_bottomtexture = R_GetTextureNum(gl_sidedef->bottomtexture); fixed_t texturevpeg; @@ -1394,7 +1395,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (!gl_curline->polyseg) // Don't do it for polyobjects { // Sky Ceilings - wallVerts[3].y = wallVerts[2].y = FLOATMAX; + wallVerts[2].y = wallVerts[3].y = FLOATMAX; // draw to top of map space auto draw_sky_walls = [] (int vert1, int vert2, fixed_t world, fixed_t worldslope, auto& wwallVerts, auto& sSurf) FUNCINLINE @@ -1404,6 +1405,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_DrawSkyWall(wwallVerts, &sSurf); }; + // worldtop = front ceiling + // worldhigh = back ceiling + if (gl_frontsector->ceilingpic == skyflatnum) { if (gl_backsector->ceilingpic == skyflatnum) @@ -1422,6 +1426,17 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom worldtop = worldhigh; worldtopslope = worldhighslope; } + else if (!gl_toptexture && + (worldhigh <= worldtop && worldhighslope <= worldtopslope) && // Assuming ESLOPE is always on with my changes + (worldhigh != worldtop || worldhighslope != worldtopslope)) + { + // Only the frontsector is sky. + // If there's no upper texture, extend the sky wall + // down to the lower of the two ceilings. + fixed_t top = std::min(worldtop, worldhigh); + fixed_t topslope = std::min(worldtopslope, worldhighslope); + draw_sky_walls(0, 1, top, topslope, wallVerts, Surf); + } else { // Only the frontsector is sky, just draw a skywall from the front ceiling @@ -1434,8 +1449,11 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom draw_sky_walls(0, 1, worldtop, worldtopslope, wallVerts, Surf); } + // worldbottom = front floor + // worldlow = back floor + // Sky Floors - wallVerts[0].y = wallVerts[1].y = FLOATMIN; + wallVerts[0].y = wallVerts[1].y = FLOATMIN; // draw to bottom of map space if (gl_frontsector->floorpic == skyflatnum) { @@ -1447,7 +1465,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if ((worldlow >= worldbottom && worldlowslope >= worldbottomslope) && (worldlow != worldbottom || worldlowslope != worldbottomslope) // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race - && !(gl_sidedef->bottomtexture)) + && !(gl_bottomtexture)) { draw_sky_walls(3, 2, worldlow, worldlowslope, wallVerts, Surf); } @@ -1458,15 +1476,25 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom draw_sky_walls(3, 2, worldbottom, worldbottomslope, wallVerts, Surf); } } - else if ((gl_backsector->floorpic == skyflatnum) && !(gl_sidedef->bottomtexture)) + else if ((gl_backsector->floorpic == skyflatnum) && !(gl_bottomtexture)) { // Only the backsector has sky, just draw a skywall from the back floor if there's no bottomtexture draw_sky_walls(3, 2, worldlow, worldlowslope, wallVerts, Surf); } + else if (gl_frontsector->ceilingpic == skyflatnum && + gl_backsector->ceilingpic == skyflatnum && + (worldlow >= worldbottom && worldlowslope >= worldbottomslope) + && (worldlow != worldbottom || worldlowslope != worldbottomslope) + // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race + && !(gl_bottomtexture)) + { + // Both ceilings are sky, but neither floor is sky. + // If there's a lower wall gap without a bottom texture, + // draw a skywall from the backsector's higher floor. + draw_sky_walls(3, 2, worldlow, worldlowslope, wallVerts, Surf); + } } - gl_toptexture = R_GetTextureNum(gl_sidedef->toptexture); - // check TOP TEXTURE if (gl_toptexture && (worldhighslope < worldtopslope || worldhigh < worldtop)) { @@ -1530,8 +1558,6 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } - gl_bottomtexture = R_GetTextureNum(gl_sidedef->bottomtexture); - // check BOTTOM TEXTURE if (gl_bottomtexture && (worldlowslope > worldbottomslope || worldlow > worldbottom)) {