Skip to content

Commit

Permalink
- made the new Build light mode operational
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Jun 11, 2020
1 parent 45210ef commit b20de18
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/rendering/hwrenderer/scene/hw_drawinfo.cpp
Expand Up @@ -146,8 +146,16 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni
VPUniforms.mViewMatrix.loadIdentity();
VPUniforms.mNormalViewMatrix.loadIdentity();
VPUniforms.mViewHeight = viewheight;
VPUniforms.mGlobVis = (float)R_GetGlobVis(r_viewwindow, r_visibility) / 32.f;
VPUniforms.mPalLightLevels = static_cast<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8) | ((int)lightmode << 16);
if (gl_lightmode == 5)
{
VPUniforms.mGlobVis = 1 / 64.f;
VPUniforms.mPalLightLevels = 32 | (static_cast<int>(gl_fogmode) << 8) | ((int)lightmode << 16);
}
else
{
VPUniforms.mGlobVis = (float)R_GetGlobVis(r_viewwindow, r_visibility) / 32.f;
VPUniforms.mPalLightLevels = static_cast<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8) | ((int)lightmode << 16);
}
VPUniforms.mClipLine.X = -10000000.0f;
VPUniforms.mShadowmapFilter = gl_shadowmap_filter;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_lighting.cpp
Expand Up @@ -185,7 +185,7 @@ float HWDrawInfo::GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfog
else if ((fogcolor.d & 0xffffff) == 0)
{
// case 2: black fog
if ((!isSoftwareLighting() || blendfactor > 0) && !(Level->flags3 & LEVEL3_NOLIGHTFADE))
if ((!isDoomSoftwareLighting() || blendfactor > 0) && !(Level->flags3 & LEVEL3_NOLIGHTFADE))
{
density = distfogtable[lightmode != ELightMode::LinearStandard][hw_ClampLight(lightlevel)];
}
Expand Down
4 changes: 4 additions & 0 deletions src/rendering/hwrenderer/scene/hw_setcolor.cpp
Expand Up @@ -135,6 +135,10 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
float light = (float)CalcLightLevel(lightlevel, rellight, false, cmap->BlendFactor);
SetShaderLight(state, light, lightlevel);
}
else if (lightmode == ELightMode::Build)
{
state.SetLightParms(0.2f * fogdensity, 1.f / 31.f);
}
else
{
state.SetLightParms(1.f, 0.f);
Expand Down
1 change: 1 addition & 0 deletions wadsrc/static/menudef.txt
Expand Up @@ -2401,6 +2401,7 @@ OptionValue "LightingModes"
2, "$OPTVAL_DOOM"
3, "$OPTVAL_DARK"
4, "$OPTVAL_LEGACY"
5, "$OPTVAL_BUILD"
8, "$OPTVAL_SOFTWARE"
16, "$OPTVAL_VANILLA"
}
Expand Down
2 changes: 1 addition & 1 deletion wadsrc/static/shaders/glsl/main.fp
Expand Up @@ -313,7 +313,7 @@ float R_DoomLightingEquation(float light)
{
// This is a lot more primitive than Doom's lighting...
float numShades = float(uPalLightLevels & 255);
float curshade = (1.0 - light) / (numShades - 1.0);
float curshade = (1.0 - light) * (numShades - 1.0);
float visibility = max(uGlobVis * uLightFactor * z, 0.0);
float shade = clamp((curshade + visibility), 0.0, numShades - 1.0);
return clamp(shade * uLightDist, 0.0, 1.0);
Expand Down

0 comments on commit b20de18

Please sign in to comment.