diff --git a/src/am_map.cpp b/src/am_map.cpp index aa7ed83b6a..b6ccce91b9 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2141,7 +2141,7 @@ void DAutomap::drawSubsectors() // is necessary in order to best reproduce Doom's original lighting. double fadelevel; - if (!V_IsHardwareRenderer() || primaryLevel->lightMode == ELightMode::Doom || primaryLevel->lightMode == ELightMode::ZDoomSoftware || primaryLevel->lightMode == ELightMode::DoomSoftware) + if (!V_IsHardwareRenderer() || primaryLevel->lightMode == ELightMode::DoomDark || primaryLevel->lightMode == ELightMode::Doom || primaryLevel->lightMode == ELightMode::ZDoomSoftware || primaryLevel->lightMode == ELightMode::DoomSoftware) { double map = (NUMCOLORMAPS * 2.) - ((floorlight + 12) * (NUMCOLORMAPS / 128.)); fadelevel = clamp((map - 12) / NUMCOLORMAPS, 0.0, 1.0); diff --git a/src/doomtype.h b/src/doomtype.h index 5b1819d085..2a3fecbd0f 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -48,6 +48,7 @@ enum class ELightMode : int8_t Doom = 2, DoomDark = 3, DoomLegacy = 4, + Build = 5, ZDoomSoftware = 8, DoomSoftware = 16 }; diff --git a/src/g_level.cpp b/src/g_level.cpp index 38e172687d..21010137ed 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -141,8 +141,8 @@ CUSTOM_CVAR(Bool, gl_notexturefill, false, CVAR_NOINITCALL) CUSTOM_CVAR(Int, gl_lightmode, 3, CVAR_ARCHIVE | CVAR_NOINITCALL) { int newself = self; - if (newself > 8) newself = 16; // use 8 and 16 for software lighting to avoid conflicts with the bit mask - else if (newself > 4) newself = 8; + if (newself > 8) newself = 16; // use 8 and 16 for software lighting to avoid conflicts with the bit mask ( in hindsight a bad idea.) + else if (newself > 5) newself = 8; else if (newself < 0) newself = 0; if (self != newself) self = newself; else for (auto Level : AllLevels()) diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.h b/src/rendering/hwrenderer/scene/hw_drawinfo.h index e603716742..262fee3f56 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.h +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.h @@ -314,12 +314,22 @@ public: bool isSoftwareLighting() const { - return lightmode >= ELightMode::ZDoomSoftware; + return lightmode == ELightMode::ZDoomSoftware || lightmode == ELightMode::DoomSoftware || lightmode == ELightMode::Build; + } + + bool isBuildSoftwareLighting() const + { + return lightmode == ELightMode::Build; + } + + bool isDoomSoftwareLighting() const + { + return lightmode == ELightMode::ZDoomSoftware || lightmode == ELightMode::DoomSoftware; } bool isDarkLightMode() const { - return !!((int)lightmode & (int)ELightMode::Doom); + return lightmode == ELightMode::Doom || lightmode == ELightMode::DoomDark; } void SetFallbackLightMode() diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 048579eeea..611dbe0b21 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -308,6 +308,16 @@ float R_DoomLightingEquation(float light) { z = pixelpos.w; } + + if ((uPalLightLevels >> 16) == 5) // gl_lightmode 5: Build software lighting emulation. + { + // This is a lot more primitive than Doom's lighting... + float numShades = float(uPalLightLevels & 255); + 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); + } float colormap = R_DoomColormap(light, z);