- added a new light mode that emulates Build's depth fading.

Not active yet, this needs some testing and finetuning.
This commit is contained in:
Christoph Oelckers 2020-06-08 20:58:35 +02:00
parent 9e51a2f63c
commit 5896f24eba
5 changed files with 26 additions and 5 deletions

View file

@ -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);

View file

@ -48,6 +48,7 @@ enum class ELightMode : int8_t
Doom = 2,
DoomDark = 3,
DoomLegacy = 4,
Build = 5,
ZDoomSoftware = 8,
DoomSoftware = 16
};

View file

@ -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())

View file

@ -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()

View file

@ -309,6 +309,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);
if ((uPalLightLevels & 0xff) != 0)