mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 04:00:42 +00:00
- split up the visibility factor into a scene specific and an element specific part.
The main reason here is that the scene specific part contains a projection dependent component which would be a problem when transitioning to GZDoom's code. The global viewpoint data already has a field for such a factor so now that gets used. This also means a significant simplification of the visibility code in Polymost and the removal of several global variables.
This commit is contained in:
parent
9dfd3ddd02
commit
0bd460d9e3
6 changed files with 30 additions and 85 deletions
|
@ -1101,11 +1101,6 @@ fix16_t qglobalang;
|
|||
int32_t globalpal, cosglobalang, singlobalang;
|
||||
int32_t cosviewingrangeglobalang, sinviewingrangeglobalang;
|
||||
static int32_t globaluclip, globaldclip;
|
||||
int32_t globalvisibility;
|
||||
int32_t globalhisibility, globalpisibility, globalcisibility;
|
||||
#ifdef USE_OPENGL
|
||||
int32_t globvis2, globalvisibility2, globalhisibility2, globalpisibility2, globalcisibility2;
|
||||
#endif
|
||||
//char globparaceilclip, globparaflorclip;
|
||||
|
||||
int32_t xyaspect;
|
||||
|
@ -2239,19 +2234,6 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
|
|||
globaluclip = (0-globalhoriz)*xdimscale;
|
||||
globaldclip = (ydimen-globalhoriz)*xdimscale;
|
||||
|
||||
i = mulscale16(xdimenscale,viewingrangerecip);
|
||||
globalpisibility = mulscale16(parallaxvisibility,i);
|
||||
globalvisibility = g_visibility * xdimen;
|
||||
globalvisibility2 = mulscale16(g_visibility, i);
|
||||
|
||||
globalhisibility = mulscale16(globalvisibility,xyaspect);
|
||||
globalcisibility = mulscale8(globalhisibility,320);
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
globalhisibility2 = mulscale16(globalvisibility2,xyaspect);
|
||||
globalcisibility2 = mulscale8(globalhisibility2,320);
|
||||
#endif
|
||||
|
||||
globalcursectnum = dacursectnum;
|
||||
totalclocklock = totalclock;
|
||||
|
||||
|
|
|
@ -94,11 +94,6 @@ extern float fglobalposx, fglobalposy, fglobalposz;
|
|||
extern int16_t globalang, globalcursectnum;
|
||||
extern int32_t globalpal, cosglobalang, singlobalang;
|
||||
extern int32_t cosviewingrangeglobalang, sinviewingrangeglobalang;
|
||||
extern int32_t globalhisibility, globalpisibility, globalcisibility;
|
||||
#ifdef USE_OPENGL
|
||||
extern int32_t globvis2, globalvisibility2, globalhisibility2, globalpisibility2, globalcisibility2;
|
||||
#endif
|
||||
extern int32_t globalvisibility;
|
||||
extern int32_t xyaspect;
|
||||
extern int32_t globalshade;
|
||||
extern int16_t globalpicnum;
|
||||
|
|
|
@ -38,12 +38,6 @@ CUSTOM_CVARD(Bool, hw_useindexedcolortextures, false, CVAR_ARCHIVE | CVAR_GLOBAL
|
|||
}
|
||||
|
||||
|
||||
void PrintVis(int sectvis, char type)
|
||||
{
|
||||
Printf("%c: g_vis = %d, gv = %d, gv2 = %d, gc = %d, gc2 = %d, gh2 = %d, globvis2 = %d, fviewingrange = %f, sectvis = %d, result = %f\n",
|
||||
type, g_visibility, globalvisibility, globalvisibility2, globalcisibility, globalcisibility2, globalhisibility2, globvis2, fviewingrange, sectvis, GLInterface.renderState.VisFactor);
|
||||
}
|
||||
|
||||
//{ "r_yshearing", "enable/disable y-shearing", (void*)&r_yshearing, CVAR_BOOL, 0, 1 }, disabled because not fully functional
|
||||
|
||||
// For testing - will be removed later.
|
||||
|
@ -121,6 +115,13 @@ void polymost_outputGLDebugMessage(uint8_t severity, const char* format, ...)
|
|||
{
|
||||
}
|
||||
|
||||
float sectorVisibility(int sectnum)
|
||||
{
|
||||
// Beware of wraparound madness...
|
||||
int v = sector[sectnum].visibility;
|
||||
return v? ((uint8_t)(v + 16)) / 16.f : 1.f;
|
||||
}
|
||||
|
||||
void gltexapplyprops(void)
|
||||
{
|
||||
if (GLInterface.glinfo.maxanisotropy > 1.f)
|
||||
|
@ -289,6 +290,7 @@ static void polymost_updaterotmat(void)
|
|||
};
|
||||
multiplyMatrix4f(matrix, tiltmatrix);
|
||||
renderSetViewMatrix(matrix);
|
||||
renderSetVisibility(g_visibility * fviewingrange * (4.f / (65536.f * 65536.f)));
|
||||
}
|
||||
|
||||
static void polymost_flatskyrender(vec2f_t const* const dpxy, int32_t const n, int32_t method, const vec2_16_t& tilesiz);
|
||||
|
@ -2090,11 +2092,8 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
globalshade = sec->floorshade;
|
||||
globalpal = sec->floorpal;
|
||||
globalorientation = sec->floorstat;
|
||||
globvis2 = (sector[sectnum].visibility != 0) ?
|
||||
mulscale4(globalcisibility2, (uint8_t)(sector[sectnum].visibility + 16)) :
|
||||
globalcisibility2;
|
||||
PrintVis(sector[sectnum].visibility, 'c');
|
||||
GLInterface.SetVisibility(globvis2, fviewingrange);
|
||||
|
||||
GLInterface.SetVisibility(sectorVisibility(sectnum));
|
||||
|
||||
tileUpdatePicnum(&globalpicnum, sectnum);
|
||||
|
||||
|
@ -2124,12 +2123,6 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
}
|
||||
else if ((nextsectnum < 0) || (!(sector[nextsectnum].floorstat&1)))
|
||||
{
|
||||
globvis2 = globalpisibility;
|
||||
if (sec->visibility != 0)
|
||||
globvis2 = mulscale4(globvis2, (uint8_t)(sec->visibility + 16));
|
||||
float viscale = xdimscale*fxdimen*(.0000001f/256.f);
|
||||
GLInterface.SetVisibility(globvis2*viscale, fviewingrange);
|
||||
|
||||
//Use clamping for tiled sky textures
|
||||
//(don't wrap around edges if the sky use multiple panels)
|
||||
for (bssize_t i=(1<<dapskybits)-1; i>0; i--)
|
||||
|
@ -2144,8 +2137,8 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
pow2xsplit = 0;
|
||||
skyclamphack = 0;
|
||||
flatskyrender = 1;
|
||||
globalshade += globvis2*xdimscale*fviewingrange*(1.f / (64.f * 65536.f * 256.f * 1024.f));
|
||||
GLInterface.SetVisibility(0.f, fviewingrange);
|
||||
//globalshade += globvis2*xdimscale*fviewingrange*(1.f / (64.f * 65536.f * 256.f * 1024.f));
|
||||
GLInterface.SetVisibility(0.f);
|
||||
polymost_domost(x0,fy0,x1,fy1);
|
||||
flatskyrender = 0;
|
||||
ghoriz = ghorizbak;
|
||||
|
@ -2346,11 +2339,7 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
globalshade = sec->ceilingshade;
|
||||
globalpal = sec->ceilingpal;
|
||||
globalorientation = sec->ceilingstat;
|
||||
globvis2 = (sector[sectnum].visibility != 0) ?
|
||||
mulscale4(globalcisibility2, (uint8_t)(sector[sectnum].visibility + 16)) :
|
||||
globalcisibility2;
|
||||
PrintVis(sector[sectnum].visibility, 'c');
|
||||
GLInterface.SetVisibility(globvis2, fviewingrange);
|
||||
GLInterface.SetVisibility(sectorVisibility(sectnum));
|
||||
|
||||
tileUpdatePicnum(&globalpicnum, sectnum);
|
||||
|
||||
|
@ -2380,12 +2369,6 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
}
|
||||
else if ((nextsectnum < 0) || (!(sector[nextsectnum].ceilingstat&1)))
|
||||
{
|
||||
globvis2 = globalpisibility;
|
||||
if (sec->visibility != 0)
|
||||
globvis2 = mulscale4(globvis2, (uint8_t)(sec->visibility + 16));
|
||||
float viscale = xdimscale*fxdimen*(.0000001f/256.f);
|
||||
GLInterface.SetVisibility(globvis2*viscale, fviewingrange);
|
||||
|
||||
//Use clamping for tiled sky textures
|
||||
//(don't wrap around edges if the sky use multiple panels)
|
||||
for (bssize_t i=(1<<dapskybits)-1; i>0; i--)
|
||||
|
@ -2400,8 +2383,8 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
pow2xsplit = 0;
|
||||
skyclamphack = 0;
|
||||
flatskyrender = 1;
|
||||
globalshade += globvis2 * xdimscale * fviewingrange * (1.f / (64.f * 65536.f * 256.f * 1024.f));
|
||||
GLInterface.SetVisibility(0.f, fviewingrange);
|
||||
//globalshade += globvis2 * xdimscale * fviewingrange * (1.f / (64.f * 65536.f * 256.f * 1024.f));
|
||||
GLInterface.SetVisibility(0.f);
|
||||
polymost_domost(x1, cy1, x0, cy0);
|
||||
flatskyrender = 0;
|
||||
ghoriz = ghorizbak;
|
||||
|
@ -2670,10 +2653,7 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
if (((cy0 < ocy0) || (cy1 < ocy1)) && (!((sec->ceilingstat§or[nextsectnum].ceilingstat)&1)))
|
||||
{
|
||||
globalpicnum = wal->picnum; globalshade = wal->shade; globalpal = (int32_t)((uint8_t)wal->pal);
|
||||
globvis2 = globalvisibility2;
|
||||
if (sector[sectnum].visibility != 0) globvis2 = mulscale4(globvis2, (uint8_t)(sector[sectnum].visibility+16));
|
||||
PrintVis(sector[sectnum].visibility, 'v');
|
||||
GLInterface.SetVisibility(globvis2, fviewingrange);
|
||||
GLInterface.SetVisibility(sectorVisibility(sectnum));
|
||||
globalorientation = wal->cstat;
|
||||
tileUpdatePicnum(&globalpicnum, wallnum+16384);
|
||||
|
||||
|
@ -2711,10 +2691,7 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
ytex.u += (float)(nwal->xpanning - wal->xpanning) * ytex.d;
|
||||
}
|
||||
globalpicnum = nwal->picnum; globalshade = nwal->shade; globalpal = (int32_t)((uint8_t)nwal->pal);
|
||||
globvis2 = globalvisibility2;
|
||||
if (sector[sectnum].visibility != 0) globvis2 = mulscale4(globvis2, (uint8_t)(sector[sectnum].visibility+16));
|
||||
PrintVis(sector[sectnum].visibility, 'v');
|
||||
GLInterface.SetVisibility(globvis2, fviewingrange);
|
||||
GLInterface.SetVisibility(sectorVisibility(sectnum));
|
||||
globalorientation = nwal->cstat;
|
||||
tileUpdatePicnum(&globalpicnum, wallnum+16384);
|
||||
|
||||
|
@ -2758,11 +2735,7 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
|
||||
globalshade = wal->shade;
|
||||
globalpal = wal->pal;
|
||||
globvis2 = (sector[sectnum].visibility != 0) ?
|
||||
mulscale4(globalvisibility2, (uint8_t)(sector[sectnum].visibility + 16)) :
|
||||
globalvisibility2;
|
||||
PrintVis(sector[sectnum].visibility, 'v');
|
||||
GLInterface.SetVisibility(globvis2, fviewingrange);
|
||||
GLInterface.SetVisibility(sectorVisibility(sectnum));
|
||||
globalorientation = wal->cstat;
|
||||
tileUpdatePicnum(&globalpicnum, wallnum+16384);
|
||||
|
||||
|
@ -3354,10 +3327,7 @@ static void polymost_drawmaskwallinternal(int32_t wallIndex)
|
|||
globalorientation = (int32_t)wal->cstat;
|
||||
tileUpdatePicnum(&globalpicnum, (int16_t)wallIndex+16384);
|
||||
|
||||
globvis2 = globalvisibility2;
|
||||
globvis2 = (sector[sectnum].visibility != 0) ? mulscale4(globvis2, (uint8_t)(sector[sectnum].visibility + 16)) : globalvisibility2;
|
||||
PrintVis(sector[sectnum].visibility, 'v');
|
||||
GLInterface.SetVisibility(globvis2, fviewingrange);
|
||||
GLInterface.SetVisibility(sectorVisibility(sectnum));
|
||||
|
||||
globalshade = (int32_t)wal->shade;
|
||||
globalpal = (int32_t)((uint8_t)wal->pal);
|
||||
|
@ -3730,11 +3700,7 @@ void polymost_drawsprite(int32_t snum)
|
|||
globalpal = tspr->pal;
|
||||
globalorientation = tspr->cstat;
|
||||
|
||||
globvis2 = globalvisibility2;
|
||||
if (sector[tspr->sectnum].visibility != 0)
|
||||
globvis2 = mulscale4(globvis2, (uint8_t)(sector[tspr->sectnum].visibility + 16));
|
||||
PrintVis(sector[tspr->sectnum].visibility, 'v');
|
||||
GLInterface.SetVisibility(globvis2, fviewingrange);
|
||||
GLInterface.SetVisibility(sectorVisibility(tspr->sectnum));
|
||||
|
||||
vec2_t off = { 0, 0 };
|
||||
|
||||
|
@ -4144,11 +4110,7 @@ void polymost_drawsprite(int32_t snum)
|
|||
break;
|
||||
|
||||
case 2: // Floor sprite
|
||||
globvis2 = globalhisibility2;
|
||||
if (sector[tspr->sectnum].visibility != 0)
|
||||
globvis2 = mulscale4(globvis2, (uint8_t)(sector[tspr->sectnum].visibility + 16));
|
||||
PrintVis(sector[tspr->sectnum].visibility, 'h');
|
||||
GLInterface.SetVisibility(globvis2, fviewingrange);
|
||||
GLInterface.SetVisibility(sectorVisibility(tspr->sectnum) * (4.f/5.f)); // No idea why this uses a different visibility setting...
|
||||
|
||||
if ((globalorientation & 64) != 0 && (globalposz > pos.z) == (!(globalorientation & 8)))
|
||||
goto _drawsprite_return;
|
||||
|
|
|
@ -647,6 +647,11 @@ void renderSetViewMatrix(const float* p)
|
|||
else vp.mViewMatrix.loadIdentity();
|
||||
}
|
||||
|
||||
void renderSetVisibility(float vis)
|
||||
{
|
||||
vp.mGlobVis = vis;
|
||||
}
|
||||
|
||||
void renderBeginScene()
|
||||
{
|
||||
if (videoGetRenderMode() < REND_POLYMOST) return;
|
||||
|
|
|
@ -203,9 +203,9 @@ public:
|
|||
renderState.Shade = shade;
|
||||
}
|
||||
|
||||
void SetVisibility(float visibility, float fviewingrange)
|
||||
void SetVisibility(float visibility)
|
||||
{
|
||||
renderState.VisFactor = visibility* fviewingrange* (1.f / (65536.f * 65536.f));
|
||||
renderState.VisFactor = visibility;
|
||||
}
|
||||
|
||||
void EnableBlend(bool on)
|
||||
|
@ -501,6 +501,7 @@ extern GLInstance GLInterface;
|
|||
|
||||
void renderSetProjectionMatrix(const float* p);
|
||||
void renderSetViewMatrix(const float* p);
|
||||
void renderSetVisibility(float v);
|
||||
void renderBeginScene();
|
||||
void renderFinishScene();
|
||||
void DrawRateStuff();
|
||||
|
|
|
@ -175,7 +175,7 @@ void main()
|
|||
// Application of this differs based on render mode because for paletted rendering with palettized shade tables it can only be done after processing the shade table. We only have a palette index before.
|
||||
}
|
||||
|
||||
float visibility = max(u_visFactor * v_distance - ((u_flags & RF_ShadeInterpolate) != 0.0? 0.5 : 0.0), 0.0);
|
||||
float visibility = max(uGlobVis * u_visFactor * v_distance - ((u_flags & RF_ShadeInterpolate) != 0.0? 0.5 : 0.0), 0.0);
|
||||
float numShades = float(uPalLightLevels & 255);
|
||||
float shade = clamp((u_shade + visibility), 0.0, numShades - 1.0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue