Skip to content

Commit

Permalink
Sky/fog fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dashodanger committed Nov 21, 2024
1 parent 3c6da71 commit 4f37647
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions source_files/edge/r_sky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static void RenderSkySlice(float top, float bottom, float atop, float abottom, f
sg_color topcol = {1.0f, 1.0f, 1.0f, atop};
sg_color bottomcol = {1.0f, 1.0f, 1.0f, abottom};

RendererVertex *glvert = BeginRenderUnit(GL_QUADS, 128, GL_MODULATE, sky_tex_id, (GLuint)kTextureEnvironmentDisable, 0, 0, blend|kBlendingAlpha, fc_to_use, fd_to_use);
RendererVertex *glvert = BeginRenderUnit(GL_QUADS, 128, GL_MODULATE, sky_tex_id, (GLuint)kTextureEnvironmentDisable, 0, 0, blend, fc_to_use, fd_to_use);

// Go through circular points
for (unsigned a = 0; a < 31; a++)
Expand Down Expand Up @@ -432,6 +432,10 @@ static void RenderSkyCylinder(void)
fd_to_use = 0.0f;
blend = (BlendingMode)(blend|kBlendingNoFog);
}
else if (fc_to_use != kRGBANoValue)
{
fd_to_use *= 0.005f;
}

// Render top cap
RendererVertex *glvert = BeginRenderUnit(GL_QUADS, 4, GL_MODULATE, 0, (GLuint)kTextureEnvironmentDisable, 0, 0, blend, fc_to_use, fd_to_use);
Expand Down Expand Up @@ -469,6 +473,8 @@ static void RenderSkyCylinder(void)

// Render skybox sides

blend = (BlendingMode)(blend|kBlendingAlpha);

// Check for odd sky sizes
float tx = 0.125f;
float ty = 2.0f;
Expand Down Expand Up @@ -756,7 +762,7 @@ void FinishSky(void)
global_render_state->Disable(GL_DEPTH_TEST);

if (!renderer_dumb_sky.d_)
global_render_state->DepthFunction(GL_GREATER);
global_render_state->DepthFunction(GL_ALWAYS);
else
global_render_state->DepthMask(false);

Expand Down
2 changes: 1 addition & 1 deletion source_files/edge/r_units.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void RenderCurrentUnits(void)
global_render_state->ClearColor(fc.r, fc.g, fc.b, 1.0f);
global_render_state->FogColor(fc.r, fc.g, fc.b, 1.0f);
global_render_state->FogDensity(std::log1p(density));
if (density > 0.00009f)
if (!AlmostEquals(density, 0.0f))
global_render_state->Enable(GL_FOG);
else
global_render_state->Disable(GL_FOG);
Expand Down

0 comments on commit 4f37647

Please sign in to comment.