mirror of
https://github.com/ZDoom/Raze.git
synced 2025-03-13 12:32:13 +00:00
- experimental new light mode, based on GZDoom's original light modes.
This commit is contained in:
parent
98c919fbe4
commit
26223ffca2
3 changed files with 20 additions and 10 deletions
|
@ -139,8 +139,9 @@ 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;
|
||||||
VPUniforms.mGlobVis = (2 / 65536.f) * (isBuildSoftwareLighting()? g_visibility + g_relvisibility : g_visibility) / r_ambientlight;
|
VPUniforms.mGlobVis = (2 / 65536.f) * (g_visibility + g_relvisibility) / r_ambientlight;
|
||||||
VPUniforms.mPalLightLevels = numshades | (static_cast<int>(gl_fogmode) << 8) | (5 << 16);
|
VPUniforms.mPalLightLevels = numshades | (static_cast<int>(gl_fogmode) << 8);
|
||||||
|
if (isBuildSoftwareLighting()) VPUniforms.mPalLightLevels |= (5 << 16);
|
||||||
|
|
||||||
VPUniforms.mClipLine.X = -10000000.0f;
|
VPUniforms.mClipLine.X = -10000000.0f;
|
||||||
VPUniforms.mShadowmapFilter = gl_shadowmap_filter;
|
VPUniforms.mShadowmapFilter = gl_shadowmap_filter;
|
||||||
|
|
|
@ -156,8 +156,7 @@ float HWDrawInfo::GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfog
|
||||||
else if ((fogcolor.d & 0xffffff) == 0)
|
else if ((fogcolor.d & 0xffffff) == 0)
|
||||||
{
|
{
|
||||||
// case 2: black fog
|
// case 2: black fog
|
||||||
density = distfogtable[0][hw_ClampLight(lightlevel)];
|
density = distfogtable[hw_lightmode != 1][hw_ClampLight(lightlevel)];
|
||||||
//density = distfogtable[lightmode != ELightMode::LinearStandard][hw_ClampLight(lightlevel)];
|
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
else if (Level->outsidefogdensity != 0 && APART(Level->info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (Level->info->outsidefog & 0xffffff))
|
else if (Level->outsidefogdensity != 0 && APART(Level->info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (Level->info->outsidefog & 0xffffff))
|
||||||
|
|
|
@ -154,16 +154,26 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
|
||||||
|
|
||||||
void SetLightAndFog(HWDrawInfo* di, FRenderState& state, PalEntry fade, int palette, int shade, float visibility, float alpha)
|
void SetLightAndFog(HWDrawInfo* di, FRenderState& state, PalEntry fade, int palette, int shade, float visibility, float alpha)
|
||||||
{
|
{
|
||||||
if (!di->isBuildSoftwareLighting())
|
|
||||||
{
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Fog must be done before the texture so that the texture selector can override it.
|
|
||||||
bool foggy = (GlobalMapFog || (fade & 0xffffff));
|
bool foggy = (GlobalMapFog || (fade & 0xffffff));
|
||||||
auto ShadeDiv = lookups.tables[palette].ShadeFactor;
|
auto ShadeDiv = lookups.tables[palette].ShadeFactor;
|
||||||
if (shade == 127) state.SetObjectColor(0xff000000); // 127 is generally used for shadow objects that must be black, even in foggy areas.
|
if (shade == 127) state.SetObjectColor(0xff000000); // 127 is generally used for shadow objects that must be black, even in foggy areas.
|
||||||
|
|
||||||
|
if (!di->isBuildSoftwareLighting() && !foggy)
|
||||||
|
{
|
||||||
|
bool fullbright = ShadeDiv < 1 / 1000.f;
|
||||||
|
float inverselight = shade * 255.f / numshades;
|
||||||
|
if (fullbright) inverselight /= ShadeDiv;
|
||||||
|
int vislight = 10 - sizeToBits(int(visibility));
|
||||||
|
int gvis = -sizeToBits(g_visibility) * 2;
|
||||||
|
int rellight = 10 - sizeToBits(g_visibility + g_relvisibility) - gvis;
|
||||||
|
int lightlevel = !fullbright ? clamp(int(255 - inverselight), 0, 255) : 255;
|
||||||
|
FColormap cm = { 0xffffffff };
|
||||||
|
di->SetColor(state, lightlevel, rellight, fullbright, cm, alpha);
|
||||||
|
di->SetFog(state, lightlevel/2 + gvis + vislight, rellight, fullbright, &cm, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Fog must be done before the texture so that the texture selector can override it.
|
||||||
|
|
||||||
// Disable brightmaps if non-black fog is used.
|
// Disable brightmaps if non-black fog is used.
|
||||||
if (ShadeDiv >= 1 / 1000.f && foggy)
|
if (ShadeDiv >= 1 / 1000.f && foggy)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue