From 582f3edbd9c5b6393f0e09c205570543c37f0315 Mon Sep 17 00:00:00 2001 From: MasterFeizz Date: Thu, 16 Nov 2023 21:46:59 -0500 Subject: [PATCH] Fix fog rendering --- source/gl_fog.c | 22 +++++++++++----------- source/gl_rmain.c | 23 ++++++----------------- source/gl_rsurf.c | 2 -- source/gl_vidctr.c | 2 +- source/gl_warp.c | 12 ++++++------ 5 files changed, 24 insertions(+), 37 deletions(-) diff --git a/source/gl_fog.c b/source/gl_fog.c index d266032..745a243 100644 --- a/source/gl_fog.c +++ b/source/gl_fog.c @@ -198,8 +198,8 @@ void Fog_ParseWorldspawn (void) fog_start = 0; old_start = 0; - fog_end = -1; - old_end = -1; + fog_end = 4000; + old_end = 4000; fog_red = 0.0; old_red = 0.0; @@ -316,7 +316,7 @@ called at the beginning of each frame void Fog_SetupFrame (void) { glFogfv(GL_FOG_COLOR, Fog_GetColor()); - glFogf(GL_FOG_DENSITY, (float)(1.0f / (18.0f * 1024.0f))); + glFogf(GL_FOG_DENSITY, 0.2f); glFogf(GL_FOG_START, fog_start); glFogf(GL_FOG_END, fog_end); } @@ -412,9 +412,9 @@ called before drawing stuff that should be fogged */ void Fog_EnableGFog (void) { - // if (!Fog_GetStart() == 0 || !Fog_GetEnd() <= 0) { - // glEnable(GL_FOG); - // } + if (!Fog_GetStart() == 0 || !Fog_GetEnd() <= 0) { + glEnable(GL_FOG); + } } /* @@ -426,8 +426,8 @@ called after drawing stuff that should be fogged */ void Fog_DisableGFog (void) { - // if (!Fog_GetStart() == 0 || !Fog_GetEnd() <= 0) - // glDisable(GL_FOG); + if (!Fog_GetStart() == 0 || !Fog_GetEnd() <= 0) + glDisable(GL_FOG); } /* @@ -504,8 +504,8 @@ void Fog_Init (void) Cmd_AddCommand ("fog",Fog_FogCommand_f); //set up global fog - fog_start = 0; - fog_end = -1; + fog_start = 300; + fog_end = 4000; fog_red = 0.5; fog_green = 0.5; fog_blue = 0.5; @@ -513,5 +513,5 @@ void Fog_Init (void) fog_density_gl = DEFAULT_DENSITY; fade_time = 1; - glFogi(GL_FOG_MODE, GL_EXP2); + glFogi(GL_FOG_MODE, GL_LINEAR); } \ No newline at end of file diff --git a/source/gl_rmain.c b/source/gl_rmain.c index 0345620..cd55190 100644 --- a/source/gl_rmain.c +++ b/source/gl_rmain.c @@ -283,7 +283,7 @@ void R_DrawSpriteModel (entity_t *e) GL_DisableMultitexture(); - GL_Bind(frame->gl_texturenum); + GL_Bind(frame->gl_texturenum); Fog_DisableGFog (); @@ -1352,10 +1352,10 @@ void R_PolyBlend (void) glDisable (GL_DEPTH_TEST); glDisable (GL_TEXTURE_2D); - glLoadIdentity (); + glLoadIdentity (); - glRotatef (-90, 1, 0, 0); // put Z going up - glRotatef (90, 0, 0, 1); // put Z going up + glRotatef (-90, 1, 0, 0); // put Z going up + glRotatef (90, 0, 0, 1); // put Z going up glColor4fv (v_blend); @@ -1581,7 +1581,6 @@ void R_RenderScene (void) R_MarkLeaves (); // done here so we know if we're in water - Fog_EnableGFog (); //johnfitz R_DrawWorld (); // adds static entities to the list S_ExtraUpdate (); // don't let sound get messed up if going slow @@ -1593,8 +1592,6 @@ void R_RenderScene (void) //R_RenderDlights (); R_DrawParticles (); - - Fog_DisableGFog (); //johnfitz } @@ -1752,22 +1749,14 @@ void R_RenderView (void) // render normal view -/***** Experimental silly looking fog ****** -****** Use r_fullbright if you enable ****** - glFogi(GL_FOG_MODE, GL_LINEAR); - glFogfv(GL_FOG_COLOR, colors); - glFogf(GL_FOG_END, 512.0); - glEnable(GL_FOG); -********************************************/ + Fog_EnableGFog (); //johnfitz R_RenderScene (); R_DrawViewModel (); R_DrawView2Model (); R_DrawWaterSurfaces (); -// More fog right here :) -// glDisable(GL_FOG); -// End of all fog code... + Fog_DisableGFog (); //johnfitz // render mirror view R_Mirror (); diff --git a/source/gl_rsurf.c b/source/gl_rsurf.c index 6dd57a1..7db72be 100644 --- a/source/gl_rsurf.c +++ b/source/gl_rsurf.c @@ -1458,8 +1458,6 @@ void R_DrawWorld (void) Fog_SetupFrame (/*false*/); //johnfitz R_BlendLightmaps(); - - Fog_EnableGFog (); } diff --git a/source/gl_vidctr.c b/source/gl_vidctr.c index cd4b9db..da387e7 100644 --- a/source/gl_vidctr.c +++ b/source/gl_vidctr.c @@ -30,7 +30,7 @@ int texture_extension_number = 1; float gldepthmin, gldepthmax; -cvar_t gl_ztrick = {"gl_ztrick","1"}; +cvar_t gl_ztrick = {"gl_ztrick","0"}; const char *gl_vendor; const char *gl_renderer; diff --git a/source/gl_warp.c b/source/gl_warp.c index b84fd43..65ccdaa 100644 --- a/source/gl_warp.c +++ b/source/gl_warp.c @@ -628,16 +628,16 @@ void R_DrawSkyBox (void) vec3_t v; float s, t; - Fog_DisableGFog(); - Fog_SetColorForSkyS(); + //Fog_DisableGFog(); + //Fog_SetColorForSkyS(); glDisable(GL_BLEND); glDisable(GL_ALPHA_TEST); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); - float skydepth = 256.f; + float skydepth = 1000.0f; for (i=0 ; i<5 ; i++) { @@ -711,8 +711,8 @@ void R_DrawSkyBox (void) glDepthMask(GL_TRUE); glEnable(GL_DEPTH_TEST); - Fog_SetColorForSkyE(); //setup for Sky - Fog_EnableGFog(); //setup for Sky + //Fog_SetColorForSkyE(); //setup for Sky + //Fog_EnableGFog(); //setup for Sky } //===============================================================