From 998ee7b6b2f17c690da85a55cd836c02aa70278c Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Mon, 24 Jun 2019 10:39:16 +0200 Subject: [PATCH] fix splitscreen, fix thok barriers, better fog settings --- src/hardware/hw_draw.c | 18 ++++++- src/hardware/hw_main.c | 93 +++++++++++++++++++------------- src/hardware/hw_main.h | 6 ++- src/hardware/r_opengl/r_opengl.c | 2 +- src/v_video.c | 4 +- 5 files changed, 78 insertions(+), 45 deletions(-) diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8570c3b3..4a0c0380 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -195,7 +195,10 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, } if (option & V_SPLITSCREEN) - cy /= 2; + cy += FIXED_TO_FLOAT((BASEVIDHEIGHT/2)<= vid.width || fy >= vid.height) @@ -1004,6 +1013,11 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) else if (!(color & V_SNAPTOTOP)) fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; } + if (color & V_SPLITSCREEN) + fy += ((float)BASEVIDHEIGHT * dupy)/2; + if (color & V_HORZSCREEN) + fx += ((float)BASEVIDWIDTH * dupx)/2; + } if (fx >= vid.width || fy >= vid.height) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 1cc358ee..b5c6d991 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -91,16 +91,23 @@ static void CV_anisotropic_ONChange(void) // base values set at SetViewSize static float gr_basecentery; +static float gr_basecenterx; float gr_baseviewwindowy, gr_basewindowcentery; +float gr_baseviewwindowx, gr_basewindowcenterx; float gr_viewwidth, gr_viewheight; // viewport clipping boundaries (screen coords) -float gr_viewwindowx; -static float gr_centerx, gr_centery; -static float gr_viewwindowy; // top left corner of view window +static float gr_centerx; +static float gr_viewwindowx; static float gr_windowcenterx; // center of view window, for projection + +static float gr_centery; +static float gr_viewwindowy; // top left corner of view window static float gr_windowcentery; +static float gr_pspritexscale, gr_pspriteyscale; + + static seg_t *gr_curline; static side_t *gr_sidedef; static line_t *gr_linedef; @@ -1905,39 +1912,44 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks backc1 = backc2 = abacksector->ceilingheight; } + // now check for closed sectors! + + // here we're talking about a CEILING lower than a floor. ...yeah we don't even need to bother. if (backc1 <= frontf1 && backc2 <= frontf2) { checkforemptylines = false; - //if (!seg->sidedef->toptexture) - // return false; - return true; } + // here we're talking about floors higher than ceilings, don't even bother either. if (backf1 >= frontc1 && backf2 >= frontc2) { checkforemptylines = false; - //if (!seg->sidedef->bottomtexture) - // return false; - return true; } + // Lat: Ok, here's what we need to do, we want to draw thok barriers. Let's define what a thok barrier is; + // -Must have ceilheight <= floorheight + // -ceilpic must be skyflatnum + // -an adjacant sector needs to have a ceilingheight or a floor height different than the one we have, otherwise, it's just a huge ass wall, we shouldn't render past it. + // -said adjacant sector cannot also be a thok barrier, because that's also dumb and we could render far more than we need to as a result :V + if (backc1 <= backf1 && backc2 <= backf2) { checkforemptylines = false; - // preserve a kind of transparent door/lift special effect: - /*if (backc1 < frontc1 || backc2 < frontc2) - { - if (!seg->sidedef->toptexture) - return false; - } + + // before we do anything, if both sectors are thok barriers, GET ME OUT OF HERE! + if (frontc1 <= backc1 && frontc2 <= frontc2) + return true; // STOP RENDERING. + + // draw floors at the top of thok barriers: + if (backc1 < frontc1 || backc2 < frontc2) + return false; + if (backf1 > frontf1 || backf2 > frontf2) - { - if (!seg->sidedef->bottomtexture) - return false; - }*/ + return false; + return true; } @@ -4539,8 +4551,8 @@ void HWR_DrawSkyBackground(void) // software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture - angle = (viewangle + xtoviewangle[0]); - dimensionmultiply = ((float)textures[skytexture]->width/256.0f)*2; + angle = (viewangle/2 + xtoviewangle[0]); + dimensionmultiply = ((float)textures[skytexture]->width/256.0f); if (atransform.mirror) { @@ -4634,25 +4646,22 @@ void HWR_SetViewSize(void) if (splitscreen > 1) gr_viewwidth /= 2; - gr_centerx = gr_viewwidth / 2; - gr_basecentery = gr_viewheight / 2; //note: this is (gr_centerx * gr_viewheight / gr_viewwidth) + gr_basecenterx = gr_viewwidth / 2; + gr_basecentery = gr_viewheight / 2; - gr_viewwindowx = (vid.width - gr_viewwidth) / 2; - gr_windowcenterx = (float)(vid.width / 2); - if (fabsf(gr_viewwidth - vid.width) < 1.0E-36f) - { - gr_baseviewwindowy = 0; - gr_basewindowcentery = gr_viewheight / 2; // window top left corner at 0,0 - } - else - { - gr_baseviewwindowy = (vid.height-gr_viewheight) / 2; - gr_basewindowcentery = (float)(vid.height / 2); - } + gr_baseviewwindowy = 0; + gr_basewindowcentery = (float)(gr_viewheight / 2); + + gr_baseviewwindowx = 0; + gr_basewindowcenterx = (float)(gr_viewwidth / 2); + + gr_pspritexscale = ((vid.width*gr_pspriteyscale*BASEVIDHEIGHT)/BASEVIDWIDTH)/vid.height; + gr_pspriteyscale = ((vid.height*gr_pspritexscale*BASEVIDWIDTH)/BASEVIDHEIGHT)/vid.width; HWD.pfnFlushScreenTextures(); } + // ========================================================================== // Render the current frame. // ========================================================================== @@ -4664,13 +4673,17 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) INT32 i; // set window position + gr_centerx = gr_basecenterx; + gr_viewwindowx = gr_baseviewwindowx; + gr_windowcenterx = gr_basewindowcenterx; gr_centery = gr_basecentery; gr_viewwindowy = gr_baseviewwindowy; gr_windowcentery = gr_basewindowcentery; - if (splitscreen && viewnumber == 1) + + if ((splitscreen == 1 && viewnumber == 1) || (splitscreen > 1 && viewnumber > 1)) { - gr_viewwindowy += (vid.height/2); - gr_windowcentery += (vid.height/2); + gr_viewwindowy += gr_viewheight; + gr_windowcentery += gr_viewheight; } if (splitscreen > 1 && viewnumber & 1) @@ -4679,6 +4692,7 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) gr_windowcenterx += gr_viewwidth; } + // check for new console commands. NetUpdate(); @@ -4816,6 +4830,9 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) HWD.pfnClearBuffer(true, false, &ClearColor); } + if (viewnumber > 3) + return; + // Render the skybox if there is one. drewsky = false; if (skybox) diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index d4f14a0b..91a95a30 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -34,8 +34,10 @@ void HWR_Startup(void); void HWR_Shutdown(void); -extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowy; -extern float gr_viewwindowx, gr_basewindowcentery; +extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowx, gr_baseviewwindowy; + +extern float gr_basewindowcenterx, gr_basewindowcentery; + extern FTransform atransform; // hw_draw.c diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 85c28e13..d4b04e1f 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -583,7 +583,7 @@ static gl_shaderprogram_t gl_shaderprograms[MAXSHADERPROGRAMS]; "float fog(const float dist, const float density, const float globaldensity) {\n" \ "const float LOG2 = -1.442695;\n" \ "float d = density * dist;\n" \ - "return 1.0 - clamp(exp2(d * d * globaldensity * LOG2), 0.0, 1.0);\n" \ + "return 1.0 - clamp(exp2(d * sqrt(d) * globaldensity * LOG2), 0.0, 1.0);\n" \ "}\n" // https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gpu_shader_fp64.txt diff --git a/src/v_video.c b/src/v_video.c index f34cf988..6292ffc6 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -58,11 +58,11 @@ static void CV_Gammaxxx_ONChange(void); // - You can change them in software, // but they won't do anything. static CV_PossibleValue_t grgamma_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t grfogdensity_cons_t[] = {{FRACUNIT/4, "MIN"}, {FRACUNIT*2, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t grfogdensity_cons_t[] = {{FRACUNIT/8, "MIN"}, {FRACUNIT*2, "MAX"}, {0, NULL}}; consvar_t cv_grshaders = {"gr_shaders", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grfog = {"gr_fog", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grfogdensity = {"gr_fogdensity", "0.60", CV_SAVE|CV_FLOAT, grfogdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grfogdensity = {"gr_fogdensity", "0.30", CV_SAVE|CV_FLOAT, grfogdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grgammared = {"gr_gammared", "127", CV_SAVE|CV_CALL, grgamma_cons_t, CV_Gammaxxx_ONChange, 0, NULL, NULL, 0, 0, NULL};