mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- tweaked light mode for weapon lighting and avoiding getting too dark.
This commit is contained in:
parent
aa7af0711a
commit
07eeb147ab
5 changed files with 28 additions and 20 deletions
|
@ -135,6 +135,7 @@ void RenderViewpoint(FRenderViewpoint& mainvp, IntRect* bounds, float fov, float
|
|||
}
|
||||
|
||||
auto di = HWDrawInfo::StartDrawInfo(nullptr, mainvp, nullptr);
|
||||
di->SetVisibility();
|
||||
auto& vp = di->Viewpoint;
|
||||
vp = mainvp;
|
||||
|
||||
|
|
|
@ -120,6 +120,9 @@ struct HWDrawInfo
|
|||
bool ingeo;
|
||||
FVector2 geoofs;
|
||||
|
||||
int rellight;
|
||||
float visibility;
|
||||
|
||||
private:
|
||||
bool inview;
|
||||
sectortype *currentsector;
|
||||
|
@ -178,6 +181,7 @@ public:
|
|||
void EndDrawScene(FRenderState &state);
|
||||
void Set3DViewport(FRenderState &state);
|
||||
void ProcessScene(bool toscreen);
|
||||
void SetVisibility();
|
||||
|
||||
//void GetDynSpriteLight(AActor *self, float x, float y, float z, FLightNode *node, int portalgroup, float *out);
|
||||
//void GetDynSpriteLight(AActor *thing, particle_t *particle, float *out);
|
||||
|
@ -198,7 +202,7 @@ public:
|
|||
|
||||
bool isBuildSoftwareLighting() const
|
||||
{
|
||||
return hw_lightmode == 0;
|
||||
return hw_lightmode == 0 || hw_int_useindexedcolortextures;
|
||||
}
|
||||
|
||||
bool isDarkLightMode() const
|
||||
|
|
|
@ -47,7 +47,6 @@ CUSTOM_CVAR(Int, gl_distfog, 70, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
|||
if (i < 64) l = -32 + i;
|
||||
|
||||
distfogtable[0][i] = (float)((gl_distfog >> 1) + (gl_distfog)*(164 - l) / 164);
|
||||
|
||||
distfogtable[1][i] = 5.f + (float)((gl_distfog >> 1) + (float)((gl_distfog)*(128 - (i >> 1)) / 70));
|
||||
}
|
||||
}
|
||||
|
@ -62,27 +61,25 @@ int HWDrawInfo::CalcLightLevel(int lightlevel, int rellight, bool weapon, int bl
|
|||
{
|
||||
int light;
|
||||
|
||||
if (numshades == 64)
|
||||
{
|
||||
//lightlevel = clamp(lightlevel * 55 / 50, 0, 255);
|
||||
}
|
||||
|
||||
if (lightlevel <= 0) return 0;
|
||||
rellight = Scale(rellight, lightlevel, 255);
|
||||
|
||||
bool darklightmode = isDarkLightMode();
|
||||
|
||||
if (darklightmode && lightlevel < 192 && !weapon)
|
||||
{
|
||||
if (lightlevel > 100)
|
||||
if (lightlevel > 90)
|
||||
{
|
||||
light = xs_CRoundToInt(192.f - (192 - lightlevel)* 1.87f);
|
||||
if (light + rellight < 20)
|
||||
{
|
||||
light = 20 + (light + rellight - 20) / 5;
|
||||
light = int(192.f - (192 - lightlevel)* 1.5f) + rellight;
|
||||
}
|
||||
else
|
||||
{
|
||||
light += rellight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
light = (lightlevel + rellight) / 5;
|
||||
light = int((lightlevel + rellight) * 0.444);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -168,3 +165,13 @@ float HWDrawInfo::GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfog
|
|||
return density;
|
||||
}
|
||||
|
||||
void HWDrawInfo::SetVisibility()
|
||||
{
|
||||
rellight = 0;
|
||||
if (g_relvisibility)
|
||||
{
|
||||
rellight = (sizeToBits(g_visibility) - sizeToBits(g_visibility + g_relvisibility)) * (32 * 32) / numshades;
|
||||
}
|
||||
// g_visibility == 512 is the baseline for 32 shades - this value is size dependent, so with twice the shades the visibility must be twice as high to get the same effect.
|
||||
visibility = g_visibility * (32.f / 512.f) / numshades;
|
||||
}
|
|
@ -562,6 +562,7 @@ bool HWMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe
|
|||
di->SetClipLine(line);
|
||||
di->SetupView(rstate, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, !!(state->MirrorFlag & 1), !!(state->PlaneMirrorFlag & 1));
|
||||
|
||||
|
||||
ClearClipper(di, clipper);
|
||||
|
||||
auto startan = bvectangbam(line->pos.X - newx, line->pos.Y - newy);
|
||||
|
|
|
@ -166,14 +166,9 @@ void SetLightAndFog(HWDrawInfo* di, FRenderState& state, PalEntry fade, int pale
|
|||
if (!fullbright) inverselight /= ShadeDiv;
|
||||
int lightlevel = !fullbright ? clamp(int(255 - inverselight), 0, 255) : 255;
|
||||
|
||||
int rellight = 0;
|
||||
if (g_relvisibility)
|
||||
{
|
||||
rellight = sizeToBits(g_visibility) - sizeToBits(g_visibility + g_relvisibility);
|
||||
}
|
||||
FColormap cm = { 0xffffffff };
|
||||
di->SetColor(state, lightlevel, 32*rellight, fullbright, cm, alpha);
|
||||
di->SetFog(state, lightlevel, visibility * g_visibility * (1.f/512.f), fullbright, &cm, false);
|
||||
di->SetColor(state, lightlevel, di->rellight, fullbright, cm, alpha);
|
||||
di->SetFog(state, lightlevel, visibility * di->visibility, fullbright, &cm, false);
|
||||
return;
|
||||
}
|
||||
// Fog must be done before the texture so that the texture selector can override it.
|
||||
|
|
Loading…
Reference in a new issue