mirror of
https://github.com/ZDoom/Raze.git
synced 2025-06-01 17:52:13 +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);
|
auto di = HWDrawInfo::StartDrawInfo(nullptr, mainvp, nullptr);
|
||||||
|
di->SetVisibility();
|
||||||
auto& vp = di->Viewpoint;
|
auto& vp = di->Viewpoint;
|
||||||
vp = mainvp;
|
vp = mainvp;
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,9 @@ struct HWDrawInfo
|
||||||
bool ingeo;
|
bool ingeo;
|
||||||
FVector2 geoofs;
|
FVector2 geoofs;
|
||||||
|
|
||||||
|
int rellight;
|
||||||
|
float visibility;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool inview;
|
bool inview;
|
||||||
sectortype *currentsector;
|
sectortype *currentsector;
|
||||||
|
@ -178,6 +181,7 @@ public:
|
||||||
void EndDrawScene(FRenderState &state);
|
void EndDrawScene(FRenderState &state);
|
||||||
void Set3DViewport(FRenderState &state);
|
void Set3DViewport(FRenderState &state);
|
||||||
void ProcessScene(bool toscreen);
|
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 *self, float x, float y, float z, FLightNode *node, int portalgroup, float *out);
|
||||||
//void GetDynSpriteLight(AActor *thing, particle_t *particle, float *out);
|
//void GetDynSpriteLight(AActor *thing, particle_t *particle, float *out);
|
||||||
|
@ -198,7 +202,7 @@ public:
|
||||||
|
|
||||||
bool isBuildSoftwareLighting() const
|
bool isBuildSoftwareLighting() const
|
||||||
{
|
{
|
||||||
return hw_lightmode == 0;
|
return hw_lightmode == 0 || hw_int_useindexedcolortextures;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isDarkLightMode() const
|
bool isDarkLightMode() const
|
||||||
|
|
|
@ -47,7 +47,6 @@ CUSTOM_CVAR(Int, gl_distfog, 70, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
if (i < 64) l = -32 + i;
|
if (i < 64) l = -32 + i;
|
||||||
|
|
||||||
distfogtable[0][i] = (float)((gl_distfog >> 1) + (gl_distfog)*(164 - l) / 164);
|
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));
|
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;
|
int light;
|
||||||
|
|
||||||
|
if (numshades == 64)
|
||||||
|
{
|
||||||
|
//lightlevel = clamp(lightlevel * 55 / 50, 0, 255);
|
||||||
|
}
|
||||||
|
|
||||||
if (lightlevel <= 0) return 0;
|
if (lightlevel <= 0) return 0;
|
||||||
|
rellight = Scale(rellight, lightlevel, 255);
|
||||||
|
|
||||||
bool darklightmode = isDarkLightMode();
|
bool darklightmode = isDarkLightMode();
|
||||||
|
|
||||||
if (darklightmode && lightlevel < 192 && !weapon)
|
if (darklightmode && lightlevel < 192 && !weapon)
|
||||||
{
|
{
|
||||||
if (lightlevel > 100)
|
if (lightlevel > 90)
|
||||||
{
|
{
|
||||||
light = xs_CRoundToInt(192.f - (192 - lightlevel)* 1.87f);
|
light = int(192.f - (192 - lightlevel)* 1.5f) + rellight;
|
||||||
if (light + rellight < 20)
|
|
||||||
{
|
|
||||||
light = 20 + (light + rellight - 20) / 5;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
light += rellight;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
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;
|
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;
|
||||||
|
}
|
|
@ -561,6 +561,7 @@ bool HWMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe
|
||||||
state->MirrorFlag++;
|
state->MirrorFlag++;
|
||||||
di->SetClipLine(line);
|
di->SetClipLine(line);
|
||||||
di->SetupView(rstate, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, !!(state->MirrorFlag & 1), !!(state->PlaneMirrorFlag & 1));
|
di->SetupView(rstate, vp.Pos.X, vp.Pos.Y, vp.Pos.Z, !!(state->MirrorFlag & 1), !!(state->PlaneMirrorFlag & 1));
|
||||||
|
|
||||||
|
|
||||||
ClearClipper(di, clipper);
|
ClearClipper(di, clipper);
|
||||||
|
|
||||||
|
|
|
@ -166,14 +166,9 @@ void SetLightAndFog(HWDrawInfo* di, FRenderState& state, PalEntry fade, int pale
|
||||||
if (!fullbright) inverselight /= ShadeDiv;
|
if (!fullbright) inverselight /= ShadeDiv;
|
||||||
int lightlevel = !fullbright ? clamp(int(255 - inverselight), 0, 255) : 255;
|
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 };
|
FColormap cm = { 0xffffffff };
|
||||||
di->SetColor(state, lightlevel, 32*rellight, fullbright, cm, alpha);
|
di->SetColor(state, lightlevel, di->rellight, fullbright, cm, alpha);
|
||||||
di->SetFog(state, lightlevel, visibility * g_visibility * (1.f/512.f), fullbright, &cm, false);
|
di->SetFog(state, lightlevel, visibility * di->visibility, fullbright, &cm, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Fog must be done before the texture so that the texture selector can override it.
|
// Fog must be done before the texture so that the texture selector can override it.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue