- split up g_visibility into two variables.

This is preparation for experimenting with the weapon flashes that can be quite annoying with how they brighten distant parts of the level far more than nearby parts.
This commit is contained in:
Christoph Oelckers 2022-01-08 12:23:05 +01:00
parent da5a92852f
commit ddcee4ecbf
9 changed files with 24 additions and 41 deletions

View file

@ -119,7 +119,7 @@ enum {
PALETTE_TRANSLUC = 1<<2,
};
EXTERN int32_t g_visibility;
inline int32_t g_visibility = 512, g_relvisibility = 0;
EXTERN vec2_t windowxy1, windowxy2;
@ -189,8 +189,7 @@ enum {
EXTERN int32_t enginecompatibility_mode;
int32_t engineInit(void);
void engineUnInit(void);
void engineInit(void);
void videoSetCorrectedAspect();
void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2);

View file

@ -146,30 +146,21 @@ int32_t animateoffs(int const tilenum, int fakevar)
return offs;
}
static int32_t engineLoadTables(void)
void engineInit(void)
{
static char tablesloaded = 0;
int32_t i;
if (tablesloaded == 0)
{
int32_t i;
for (i=0; i<=512; i++)
sintable[i] = int(sin(i * BAngRadian) * +SINTABLEUNIT);
for (i=513; i<1024; i++)
sintable[i] = sintable[1024-i];
for (i=1024; i<2048; i++)
sintable[i] = -sintable[i-1024];
for (i=0; i<=512; i++)
sintable[i] = int(sin(i * BAngRadian) * +SINTABLEUNIT);
for (i=513; i<1024; i++)
sintable[i] = sintable[1024-i];
for (i=1024; i<2048; i++)
sintable[i] = -sintable[i-1024];
for (i=0; i<640; i++)
radarang[i] = atan((639.5 - i) / 160.) * (-64. / BAngRadian);
for (i=0; i<640; i++)
radarang[1279-i] = -radarang[i];
tablesloaded = 1;
}
return 0;
for (i=0; i<640; i++)
radarang[i] = atan((639.5 - i) / 160.) * (-64. / BAngRadian);
for (i=0; i<640; i++)
radarang[1279-i] = -radarang[i];
}
//
@ -342,18 +333,6 @@ const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits,
return psky->tileofs;
}
//
// initengine
//
int32_t engineInit(void)
{
engineLoadTables();
g_visibility = 512;
return 0;
}
//
// inside
//

View file

@ -337,7 +337,7 @@ static void polymost_updaterotmat(void)
multiplyMatrix4f(matrix, tiltmatrix);
renderSetViewMatrix(matrix);
float fxdimen = FixedToFloat(xdimenscale);
renderSetVisibility(g_visibility * fxdimen * (1.f / (65536.f)) / r_ambientlight);
renderSetVisibility((g_visibility + g_relvisibility) * fxdimen * (1.f / (65536.f)) / r_ambientlight);
}
const vec2_16_t tileSize(int index)

View file

@ -139,7 +139,7 @@ void HWDrawInfo::StartScene(FRenderViewpoint& parentvp, HWViewpointUniforms* uni
VPUniforms.mViewMatrix.loadIdentity();
VPUniforms.mNormalViewMatrix.loadIdentity();
//VPUniforms.mViewHeight = viewheight;
VPUniforms.mGlobVis = (2 / 65536.f) * g_visibility / r_ambientlight;
VPUniforms.mGlobVis = (2 / 65536.f) * (isBuildSoftwareLighting()? g_visibility + g_relvisibility : g_visibility) / r_ambientlight;
VPUniforms.mPalLightLevels = numshades | (static_cast<int>(gl_fogmode) << 8) | (5 << 16);
VPUniforms.mClipLine.X = -10000000.0f;

View file

@ -695,6 +695,7 @@ void SerializeMap(FSerializer& arc)
("randomseed", randomseed)
("numshades", numshades) // is this really needed?
("visibility", g_visibility)
("relvisibility", g_relvisibility)
("parallaxtype", parallaxtype)
("parallaxyo", parallaxyoffs_override)
("parallaxys", parallaxyscale_override)

View file

@ -739,7 +739,7 @@ void viewDrawScreen(bool sceneonly)
break;
}
}
g_visibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - brightness, 0));
g_relvisibility = (int32_t)(ClipLow(gVisibility - 32 * gView->visibility - brightness, 0)) - g_visibility;
cA += interpolatedangle(buildang(deliriumTurnO), buildang(deliriumTurn), gInterpolate);
int ceilingZ, floorZ;

View file

@ -563,6 +563,7 @@ void thunder(void)
{
if (testgotpic(RRTILE2577, true))
{
g_relvisibility = 0;
if (krand() > 65000)
{
thunderflash = 1;

View file

@ -271,7 +271,8 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
p->visibility = ud.const_visibility;
}
g_visibility = p->visibility;
g_visibility = ud.const_visibility;
g_relvisibility = p->visibility - ud.const_visibility;
videoSetCorrectedAspect();

View file

@ -1450,7 +1450,9 @@ void drawscreen(PLAYER* pp, double smoothratio, bool sceneonly)
pp->siang = tang.asbuild();
QuakeViewChange(camerapp, &quake_z, &quake_x, &quake_y, &quake_ang);
VisViewChange(camerapp, &g_visibility);
int vis = g_visibility;
VisViewChange(camerapp, &vis);
g_relvisibility = vis - g_visibility;
tz = tz + quake_z;
tx = tx + quake_x;
ty = ty + quake_y;