mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-14 00:20:51 +00:00
lightmode refactor
* make all legacy light modes except 'Doom' MAPINFO only. A CVAR still exists for testing but its value won't be saved to the config. * user can only select between "performance', 'software' and 'vanilla'. 'performance' is the old 'Doom' mode which is still needed to speed things up on low end hardware. * MAPINFO can not enforce any of the two software light modes, as low end users require the option to change this to the 'performance' setting. Selecting one will always revert to the user's light mode selection.
This commit is contained in:
parent
be2616ca97
commit
666a99f204
8 changed files with 43 additions and 18 deletions
|
@ -2012,6 +2012,9 @@ void DAutomap::drawSubsectors()
|
||||||
PalEntry flatcolor;
|
PalEntry flatcolor;
|
||||||
mpoint_t originpt;
|
mpoint_t originpt;
|
||||||
|
|
||||||
|
auto lm = getRealLightmode(Level, false);
|
||||||
|
bool softlightramp = !V_IsHardwareRenderer() || lm == ELightMode::Doom || lm == ELightMode::DoomDark;
|
||||||
|
|
||||||
auto &subsectors = Level->subsectors;
|
auto &subsectors = Level->subsectors;
|
||||||
for (unsigned i = 0; i < subsectors.Size(); ++i)
|
for (unsigned i = 0; i < subsectors.Size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -2186,15 +2189,14 @@ void DAutomap::drawSubsectors()
|
||||||
// Why the +12? I wish I knew, but experimentation indicates it
|
// Why the +12? I wish I knew, but experimentation indicates it
|
||||||
// is necessary in order to best reproduce Doom's original lighting.
|
// is necessary in order to best reproduce Doom's original lighting.
|
||||||
double fadelevel;
|
double fadelevel;
|
||||||
|
if (softlightramp)
|
||||||
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.));
|
double map = (NUMCOLORMAPS * 2.) - ((floorlight + 12) * (NUMCOLORMAPS / 128.));
|
||||||
fadelevel = clamp((map - 12) / NUMCOLORMAPS, 0.0, 1.0);
|
fadelevel = clamp((map - 12) / NUMCOLORMAPS, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// The hardware renderer's light modes 0, 1 and 4 use a linear light scale which must be used here as well. Otherwise the automap gets too dark.
|
// for the hardware renderer's light modes that use a linear light scale this must do the same. Otherwise the automap gets too dark.
|
||||||
fadelevel = 1. - clamp(floorlight, 0, 255) / 255.f;
|
fadelevel = 1. - clamp(floorlight, 0, 255) / 255.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ EXTERN_CVAR (Bool, gl_light_shadowmap);
|
||||||
EXTERN_CVAR (Int, gl_shadowmap_quality);
|
EXTERN_CVAR (Int, gl_shadowmap_quality);
|
||||||
|
|
||||||
EXTERN_CVAR(Int, gl_fogmode)
|
EXTERN_CVAR(Int, gl_fogmode)
|
||||||
EXTERN_CVAR(Int, gl_lightmode)
|
|
||||||
EXTERN_CVAR(Bool,gl_mirror_envmap)
|
EXTERN_CVAR(Bool,gl_mirror_envmap)
|
||||||
|
|
||||||
EXTERN_CVAR(Bool,gl_mirrors)
|
EXTERN_CVAR(Bool,gl_mirrors)
|
||||||
|
|
|
@ -146,17 +146,30 @@ CUSTOM_CVAR(Bool, gl_notexturefill, false, CVAR_NOINITCALL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_CVAR(Int, gl_lightmode, 3, CVAR_ARCHIVE | CVAR_NOINITCALL)
|
CUSTOM_CVAR(Int, gl_maplightmode, -1, CVAR_NOINITCALL) // this is just for testing. -1 means 'inactive'
|
||||||
{
|
{
|
||||||
int newself = self;
|
if (self > 5 || self < -1) self = -1;
|
||||||
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;
|
CUSTOM_CVAR(Int, gl_lightmode, 1, CVAR_ARCHIVE | CVAR_NOINITCALL)
|
||||||
if (self != newself) self = newself;
|
{
|
||||||
else for (auto Level : AllLevels())
|
if (self < 0 || self > 2) self = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
ELightMode getRealLightmode(FLevelLocals* Level, bool for3d)
|
||||||
|
{
|
||||||
|
auto lightmode = Level->info->lightmode;
|
||||||
|
if (lightmode == ELightMode::NotSet)
|
||||||
{
|
{
|
||||||
if ((Level->info == nullptr || Level->info->lightmode == ELightMode::NotSet)) Level->lightMode = (ELightMode)*self;
|
if (gl_maplightmode != -1) Level->info->lightmode == (ELightMode)*gl_maplightmode;
|
||||||
|
else Level->info->lightmode = ELightMode::Doom;
|
||||||
}
|
}
|
||||||
|
if (lightmode == ELightMode::Doom && for3d)
|
||||||
|
{
|
||||||
|
if (gl_lightmode == 1) lightmode = ELightMode::ZDoomSoftware;
|
||||||
|
else if (gl_lightmode == 2) lightmode = ELightMode::DoomSoftware;
|
||||||
|
}
|
||||||
|
return lightmode;
|
||||||
}
|
}
|
||||||
|
|
||||||
CVAR(Int, sv_alwaystally, 0, CVAR_SERVERINFO)
|
CVAR(Int, sv_alwaystally, 0, CVAR_SERVERINFO)
|
||||||
|
@ -1864,7 +1877,6 @@ void FLevelLocals::Init()
|
||||||
|
|
||||||
DefaultEnvironment = info->DefaultEnvironment;
|
DefaultEnvironment = info->DefaultEnvironment;
|
||||||
|
|
||||||
lightMode = info->lightmode == ELightMode::NotSet? (ELightMode)*gl_lightmode : info->lightmode;
|
|
||||||
brightfog = info->brightfog < 0? gl_brightfog : !!info->brightfog;
|
brightfog = info->brightfog < 0? gl_brightfog : !!info->brightfog;
|
||||||
lightadditivesurfaces = info->lightadditivesurfaces < 0 ? gl_lightadditivesurfaces : !!info->lightadditivesurfaces;
|
lightadditivesurfaces = info->lightadditivesurfaces < 0 ? gl_lightadditivesurfaces : !!info->lightadditivesurfaces;
|
||||||
notexturefill = info->notexturefill < 0 ? gl_notexturefill : !!info->notexturefill;
|
notexturefill = info->notexturefill < 0 ? gl_notexturefill : !!info->notexturefill;
|
||||||
|
|
|
@ -683,7 +683,6 @@ public:
|
||||||
float MusicVolume;
|
float MusicVolume;
|
||||||
|
|
||||||
// Hardware render stuff that can either be set via CVAR or MAPINFO
|
// Hardware render stuff that can either be set via CVAR or MAPINFO
|
||||||
ELightMode lightMode;
|
|
||||||
bool brightfog;
|
bool brightfog;
|
||||||
bool lightadditivesurfaces;
|
bool lightadditivesurfaces;
|
||||||
bool notexturefill;
|
bool notexturefill;
|
||||||
|
@ -883,3 +882,5 @@ inline TArrayView<FLevelLocals *> AllLevels()
|
||||||
{
|
{
|
||||||
return TArrayView<FLevelLocals *>(&primaryLevel, 1);
|
return TArrayView<FLevelLocals *>(&primaryLevel, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ELightMode getRealLightmode(FLevelLocals* Level, bool for3d);
|
||||||
|
|
|
@ -607,6 +607,15 @@ void FGameConfigFile::DoGlobalSetup ()
|
||||||
var->SetGenericRep(v, CVAR_Float);
|
var->SetGenericRep(v, CVAR_Float);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (last < 225)
|
||||||
|
{
|
||||||
|
if (const auto var = FindCVar("gl_lightmode", NULL))
|
||||||
|
{
|
||||||
|
UCVarValue v = var->GetGenericRep(CVAR_Int);
|
||||||
|
v.Int /= 8; // all legacy modes map to 0, ZDoom software to 1 and Vanilla software to 2.
|
||||||
|
var->SetGenericRep(v, CVAR_Int);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1521,7 +1521,8 @@ DEFINE_MAP_OPTION(lightmode, false)
|
||||||
parse.ParseAssign();
|
parse.ParseAssign();
|
||||||
parse.sc.MustGetNumber();
|
parse.sc.MustGetNumber();
|
||||||
|
|
||||||
if ((parse.sc.Number >= 0 && parse.sc.Number <= 4) || parse.sc.Number == 8 || parse.sc.Number == 16)
|
if (parse.sc.Number == 8 || parse.sc.Number == 16) info->lightmode = ELightMode::NotSet;
|
||||||
|
else if (parse.sc.Number >= 0 && parse.sc.Number <= 5)
|
||||||
{
|
{
|
||||||
info->lightmode = ELightMode(parse.sc.Number);
|
info->lightmode = ELightMode(parse.sc.Number);
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,8 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni
|
||||||
mClipper = &staticClipper;
|
mClipper = &staticClipper;
|
||||||
|
|
||||||
Viewpoint = parentvp;
|
Viewpoint = parentvp;
|
||||||
lightmode = Level->lightMode;
|
lightmode = getRealLightmode(Level, true);
|
||||||
|
|
||||||
if (uniforms)
|
if (uniforms)
|
||||||
{
|
{
|
||||||
VPUniforms = *uniforms;
|
VPUniforms = *uniforms;
|
||||||
|
@ -153,7 +154,7 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni
|
||||||
VPUniforms.mViewMatrix.loadIdentity();
|
VPUniforms.mViewMatrix.loadIdentity();
|
||||||
VPUniforms.mNormalViewMatrix.loadIdentity();
|
VPUniforms.mNormalViewMatrix.loadIdentity();
|
||||||
VPUniforms.mViewHeight = viewheight;
|
VPUniforms.mViewHeight = viewheight;
|
||||||
if (gl_lightmode == 5)
|
if (lightmode == ELightMode::Build)
|
||||||
{
|
{
|
||||||
VPUniforms.mGlobVis = 1 / 64.f;
|
VPUniforms.mGlobVis = 1 / 64.f;
|
||||||
VPUniforms.mPalLightLevels = 32 | (static_cast<int>(gl_fogmode) << 8) | ((int)lightmode << 16);
|
VPUniforms.mPalLightLevels = 32 | (static_cast<int>(gl_fogmode) << 8) | ((int)lightmode << 16);
|
||||||
|
|
|
@ -65,7 +65,7 @@ const char *GetVersionString();
|
||||||
// Version stored in the ini's [LastRun] section.
|
// Version stored in the ini's [LastRun] section.
|
||||||
// Bump it if you made some configuration change that you want to
|
// Bump it if you made some configuration change that you want to
|
||||||
// be able to migrate in FGameConfigFile::DoGlobalSetup().
|
// be able to migrate in FGameConfigFile::DoGlobalSetup().
|
||||||
#define LASTRUNVERSION "224"
|
#define LASTRUNVERSION "225"
|
||||||
|
|
||||||
// Protocol version used in demos.
|
// Protocol version used in demos.
|
||||||
// Bump it if you change existing DEM_ commands or add new ones.
|
// Bump it if you change existing DEM_ commands or add new ones.
|
||||||
|
|
Loading…
Reference in a new issue