mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 11:10:39 +00:00
Do a depth only pass before actual rendering and only occlusion check for map boundary sectors.
git-svn-id: https://svn.eduke32.com/eduke32@1252 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
8d1da3e070
commit
68866d606e
2 changed files with 100 additions and 145 deletions
|
@ -238,6 +238,7 @@ static void polymer_updatewall(int16_t wallnum);
|
||||||
static void polymer_drawwall(int16_t sectnum, int16_t wallnum);
|
static void polymer_drawwall(int16_t sectnum, int16_t wallnum);
|
||||||
// HSR
|
// HSR
|
||||||
static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, int32_t indicecount, GLfloat* plane, GLfloat* t, GLfloat* b, GLfloat* n);
|
static void polymer_buffertoplane(GLfloat* buffer, GLushort* indices, int32_t indicecount, GLfloat* plane, GLfloat* t, GLfloat* b, GLfloat* n);
|
||||||
|
static GLfloat polymer_dotproduct(GLfloat* in_a, GLfloat* in_b);
|
||||||
static void polymer_crossproduct(GLfloat* in_a, GLfloat* in_b, GLfloat* out);
|
static void polymer_crossproduct(GLfloat* in_a, GLfloat* in_b, GLfloat* out);
|
||||||
static void polymer_transformpoint(float* inpos, float* pos, float* matrix);
|
static void polymer_transformpoint(float* inpos, float* pos, float* matrix);
|
||||||
static void polymer_pokesector(int16_t sectnum);
|
static void polymer_pokesector(int16_t sectnum);
|
||||||
|
|
|
@ -370,6 +370,8 @@ _prprogrambit prprogrambits[PR_BIT_COUNT] = {
|
||||||
|
|
||||||
_prprograminfo prprograms[1 << PR_BIT_COUNT];
|
_prprograminfo prprograms[1 << PR_BIT_COUNT];
|
||||||
|
|
||||||
|
int32_t overridematerial;
|
||||||
|
|
||||||
// CONTROL
|
// CONTROL
|
||||||
GLfloat spritemodelview[16];
|
GLfloat spritemodelview[16];
|
||||||
GLfloat rootmodelviewmatrix[16];
|
GLfloat rootmodelviewmatrix[16];
|
||||||
|
@ -432,6 +434,8 @@ int32_t polymer_init(void)
|
||||||
memcpy(spriteplane.buffer, horizsprite, sizeof(GLfloat) * 4 * 5);
|
memcpy(spriteplane.buffer, horizsprite, sizeof(GLfloat) * 4 * 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
overridematerial = 0xFFFFFFFF;
|
||||||
|
|
||||||
if (pr_verbosity >= 1) OSD_Printf("PR : Initialization complete.\n");
|
if (pr_verbosity >= 1) OSD_Printf("PR : Initialization complete.\n");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
@ -885,17 +889,15 @@ void polymer_addlight(_prlight light)
|
||||||
// CORE
|
// CORE
|
||||||
static void polymer_displayrooms(int16_t dacursectnum)
|
static void polymer_displayrooms(int16_t dacursectnum)
|
||||||
{
|
{
|
||||||
sectortype *sec, *nextsec;
|
sectortype *sec;
|
||||||
walltype *wal, *nextwal;
|
int32_t i;
|
||||||
_prwall *w;
|
|
||||||
int32_t i, j;
|
|
||||||
GLint result;
|
GLint result;
|
||||||
|
int16_t doquery;
|
||||||
int32_t front;
|
int32_t front;
|
||||||
int32_t back;
|
int32_t back;
|
||||||
int32_t firstback;
|
|
||||||
int16_t sectorqueue[MAXSECTORS];
|
int16_t sectorqueue[MAXSECTORS];
|
||||||
int16_t querydelay[MAXSECTORS];
|
int16_t querydelay[MAXSECTORS];
|
||||||
GLuint queryid[MAXSECTORS];
|
GLuint queryid[MAXWALLS];
|
||||||
int16_t drawingstate[MAXSECTORS];
|
int16_t drawingstate[MAXSECTORS];
|
||||||
GLfloat localmodelviewmatrix[16];
|
GLfloat localmodelviewmatrix[16];
|
||||||
float frustum[5 * 4];
|
float frustum[5 * 4];
|
||||||
|
@ -914,158 +916,120 @@ static void polymer_displayrooms(int16_t dacursectnum)
|
||||||
polymer_extractfrustum(curmodelviewmatrix, projectionmatrix, frustum);
|
polymer_extractfrustum(curmodelviewmatrix, projectionmatrix, frustum);
|
||||||
|
|
||||||
memset(querydelay, 0, sizeof(int16_t) * MAXSECTORS);
|
memset(querydelay, 0, sizeof(int16_t) * MAXSECTORS);
|
||||||
memset(queryid, 0, sizeof(GLuint) * MAXSECTORS);
|
memset(queryid, 0, sizeof(GLuint) * MAXWALLS);
|
||||||
memset(drawingstate, 0, sizeof(int16_t) * MAXSECTORS);
|
memset(drawingstate, 0, sizeof(int16_t) * MAXSECTORS);
|
||||||
|
|
||||||
front = 0;
|
front = 0;
|
||||||
back = 0;
|
back = 1;
|
||||||
localspritesortcnt = localmaskwallcnt = 0;
|
sectorqueue[0] = dacursectnum;
|
||||||
|
|
||||||
polymer_pokesector(dacursectnum);
|
|
||||||
polymer_drawsector(dacursectnum);
|
|
||||||
polymer_scansprites(dacursectnum, localtsprite, &localspritesortcnt);
|
|
||||||
drawingstate[dacursectnum] = 1;
|
drawingstate[dacursectnum] = 1;
|
||||||
|
|
||||||
sec = §or[dacursectnum];
|
localspritesortcnt = localmaskwallcnt = 0;
|
||||||
wal = &wall[sec->wallptr];
|
|
||||||
|
|
||||||
i = 0;
|
// depth-only occlusion testing pass
|
||||||
while (i < sec->wallnum)
|
overridematerial = 0;
|
||||||
{
|
|
||||||
if (((wallvisible(sec->wallptr + i))) &&
|
|
||||||
(polymer_portalinfrustum(sec->wallptr + i, frustum)))
|
|
||||||
{
|
|
||||||
if (mirrorfrom[depth] != (sec->wallptr + i))
|
|
||||||
polymer_drawwall(dacursectnum, sec->wallptr + i);
|
|
||||||
// mask
|
|
||||||
if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
|
|
||||||
|
|
||||||
if ((wal->nextsector != -1) &&
|
|
||||||
(drawingstate[wal->nextsector] == 0))
|
|
||||||
{
|
|
||||||
sectorqueue[back++] = wal->nextsector;
|
|
||||||
drawingstate[wal->nextsector] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
wal = &wall[sec->wallptr + i];
|
|
||||||
}
|
|
||||||
|
|
||||||
mirrorfrom[depth] = -3;
|
|
||||||
|
|
||||||
firstback = back;
|
|
||||||
|
|
||||||
while (front != back)
|
while (front != back)
|
||||||
{
|
{
|
||||||
if ((front >= firstback) && (pr_occlusionculling))
|
sec = §or[sectorqueue[front]];
|
||||||
{
|
|
||||||
if (querydelay[sectorqueue[front]] == 0)
|
|
||||||
{
|
|
||||||
bglGetQueryObjectivARB(queryid[sectorqueue[front]],
|
|
||||||
GL_QUERY_RESULT_ARB,
|
|
||||||
&result);
|
|
||||||
bglDeleteQueriesARB(1, &queryid[sectorqueue[front]]);
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
front++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
querydelay[sectorqueue[front]] = pr_occlusionculling-1;
|
|
||||||
}
|
|
||||||
else if (querydelay[sectorqueue[front]] == -1)
|
|
||||||
querydelay[sectorqueue[front]] = pr_occlusionculling-1;
|
|
||||||
else if (querydelay[sectorqueue[front]])
|
|
||||||
querydelay[sectorqueue[front]]--;
|
|
||||||
}
|
|
||||||
|
|
||||||
polymer_pokesector(sectorqueue[front]);
|
polymer_pokesector(sectorqueue[front]);
|
||||||
polymer_drawsector(sectorqueue[front]);
|
polymer_drawsector(sectorqueue[front]);
|
||||||
polymer_scansprites(sectorqueue[front], localtsprite, &localspritesortcnt);
|
polymer_scansprites(sectorqueue[front], localtsprite, &localspritesortcnt);
|
||||||
|
|
||||||
// scan sectors
|
doquery = 0;
|
||||||
sec = §or[sectorqueue[front]];
|
|
||||||
wal = &wall[sec->wallptr];
|
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < sec->wallnum)
|
while (i < sec->wallnum)
|
||||||
{
|
|
||||||
if ((wallvisible(sec->wallptr + i)) &&
|
|
||||||
(polymer_portalinfrustum(sec->wallptr + i, frustum)))
|
|
||||||
{
|
{
|
||||||
polymer_drawwall(sectorqueue[front], sec->wallptr + i);
|
polymer_drawwall(sectorqueue[front], sec->wallptr + i);
|
||||||
// mask
|
|
||||||
if ((wal->cstat&48) == 16) localmaskwall[localmaskwallcnt++] = sec->wallptr + i;
|
|
||||||
|
|
||||||
if ((wal->nextsector != -1) &&
|
// if we have a level boundary somewhere in the sector,
|
||||||
(drawingstate[wal->nextsector] == 0))
|
// consider these walls as visportals
|
||||||
{
|
if (wall[sec->wallptr + i].nextsector == -1)
|
||||||
polymer_pokesector(wal->nextsector);
|
doquery = 1;
|
||||||
sectorqueue[back++] = wal->nextsector;
|
|
||||||
drawingstate[wal->nextsector] = 1;
|
|
||||||
|
|
||||||
if (pr_occlusionculling && !querydelay[wal->nextsector])
|
|
||||||
{
|
|
||||||
nextsec = §or[wal->nextsector];
|
|
||||||
nextwal = &wall[nextsec->wallptr];
|
|
||||||
|
|
||||||
if ((nextsec->ceilingstat & 1) &&
|
|
||||||
(nextsec->floorz == nextsec->ceilingz))
|
|
||||||
{
|
|
||||||
querydelay[wal->nextsector] = -1;
|
|
||||||
i++;
|
i++;
|
||||||
wal = &wall[sec->wallptr + i];
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bglDisable(GL_TEXTURE_2D);
|
i = 0;
|
||||||
bglDisable(GL_FOG);
|
while (i < sec->wallnum)
|
||||||
|
{
|
||||||
|
if ((wall[sec->wallptr + i].nextsector != -1) &&
|
||||||
|
(!drawingstate[wall[sec->wallptr + i].nextsector]) &&
|
||||||
|
(wallvisible(sec->wallptr + i)) &&
|
||||||
|
(polymer_portalinfrustum(sec->wallptr + i, frustum)))
|
||||||
|
{
|
||||||
|
if (doquery)
|
||||||
|
{
|
||||||
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
bglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||||
bglDepthMask(GL_FALSE);
|
bglDepthMask(GL_FALSE);
|
||||||
|
|
||||||
bglGenQueriesARB(1, &queryid[wal->nextsector]);
|
bglGenQueriesARB(1, &queryid[sec->wallptr + i]);
|
||||||
bglBeginQueryARB(GL_SAMPLES_PASSED_ARB, queryid[wal->nextsector]);
|
bglBeginQueryARB(GL_SAMPLES_PASSED_ARB, queryid[sec->wallptr + i]);
|
||||||
|
|
||||||
j = 0;
|
polymer_drawplane(-1, -3, &prwalls[sec->wallptr + i]->mask, 0);
|
||||||
while (j < nextsec->wallnum)
|
|
||||||
{
|
|
||||||
if ((nextwal->nextwall == (sec->wallptr + i)) ||
|
|
||||||
((nextwal->nextwall != -1) &&
|
|
||||||
(wallvisible(nextwal->nextwall)) &&
|
|
||||||
(polymer_portalinfrustum(nextwal->nextwall, frustum))))
|
|
||||||
{
|
|
||||||
w = prwalls[nextwal->nextwall];
|
|
||||||
|
|
||||||
if (pr_vbos > 0)
|
|
||||||
{
|
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, w->stuffvbo);
|
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
bglVertexPointer(3, GL_FLOAT, 5 * sizeof(GLfloat), w->bigportal);
|
|
||||||
|
|
||||||
bglDrawArrays(GL_QUADS, 0, 4);
|
|
||||||
|
|
||||||
if (pr_vbos > 0)
|
|
||||||
bglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
j++;
|
|
||||||
nextwal = &wall[nextsec->wallptr + j];
|
|
||||||
}
|
|
||||||
bglEndQueryARB(GL_SAMPLES_PASSED_ARB);
|
bglEndQueryARB(GL_SAMPLES_PASSED_ARB);
|
||||||
|
|
||||||
bglDepthMask(GL_TRUE);
|
bglDepthMask(GL_TRUE);
|
||||||
bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
bglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
|
} else
|
||||||
|
queryid[sec->wallptr + i] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
bglEnable(GL_FOG);
|
|
||||||
bglEnable(GL_TEXTURE_2D);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
i++;
|
i++;
|
||||||
wal = &wall[sec->wallptr + i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (i < sec->wallnum)
|
||||||
|
{
|
||||||
|
if ((queryid[sec->wallptr + i]) &&
|
||||||
|
(!drawingstate[wall[sec->wallptr + i].nextsector]))
|
||||||
|
{
|
||||||
|
// REAP
|
||||||
|
result = 0;
|
||||||
|
if (doquery)
|
||||||
|
{
|
||||||
|
bglGetQueryObjectivARB(queryid[sec->wallptr + i],
|
||||||
|
GL_QUERY_RESULT_ARB,
|
||||||
|
&result);
|
||||||
|
bglDeleteQueriesARB(1, &queryid[sec->wallptr + i]);
|
||||||
|
}
|
||||||
|
queryid[sec->wallptr + i] = 0;
|
||||||
|
|
||||||
|
if (result || !doquery)
|
||||||
|
{
|
||||||
|
sectorqueue[back++] = wall[sec->wallptr + i].nextsector;
|
||||||
|
drawingstate[wall[sec->wallptr + i].nextsector] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
front++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// do the actual shaded drawing
|
||||||
|
overridematerial = 0xFFFFFFFF;
|
||||||
|
|
||||||
|
// go through the sector queue again
|
||||||
|
front = 0;
|
||||||
|
while (front < back)
|
||||||
|
{
|
||||||
|
sec = §or[sectorqueue[front]];
|
||||||
|
|
||||||
|
polymer_drawsector(sectorqueue[front]);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (i < sec->wallnum)
|
||||||
|
{
|
||||||
|
polymer_drawwall(sectorqueue[front], sec->wallptr + i);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
front++;
|
front++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1074,22 +1038,7 @@ static void polymer_displayrooms(int16_t dacursectnum)
|
||||||
maskwallcnt = localmaskwallcnt;
|
maskwallcnt = localmaskwallcnt;
|
||||||
memcpy(maskwall, localmaskwall, sizeof(int16_t) * MAXWALLSB);
|
memcpy(maskwall, localmaskwall, sizeof(int16_t) * MAXWALLSB);
|
||||||
|
|
||||||
if (depth)
|
return;
|
||||||
{
|
|
||||||
cosglobalang = sintable[(viewangle+512)&2047];
|
|
||||||
singlobalang = sintable[viewangle&2047];
|
|
||||||
cosviewingrangeglobalang = mulscale16(cosglobalang,viewingrange);
|
|
||||||
sinviewingrangeglobalang = mulscale16(singlobalang,viewingrange);
|
|
||||||
|
|
||||||
display_mirror = 1;
|
|
||||||
polymer_animatesprites();
|
|
||||||
display_mirror = 0;
|
|
||||||
|
|
||||||
bglDisable(GL_CULL_FACE);
|
|
||||||
drawmasks();
|
|
||||||
bglEnable(GL_CULL_FACE);
|
|
||||||
bglEnable(GL_BLEND);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OMGDRAWSHITVBO \
|
#define OMGDRAWSHITVBO \
|
||||||
|
@ -3034,8 +2983,7 @@ static int32_t polymer_bindmaterial(_prmaterial material, char* lights, int
|
||||||
int32_t programbits;
|
int32_t programbits;
|
||||||
int32_t texunit;
|
int32_t texunit;
|
||||||
|
|
||||||
programbits = prprogrambits[PR_BIT_HEADER].bit;
|
programbits = 0;
|
||||||
programbits |= prprogrambits[PR_BIT_FOOTER].bit;
|
|
||||||
|
|
||||||
// --------- bit validation
|
// --------- bit validation
|
||||||
|
|
||||||
|
@ -3070,6 +3018,12 @@ static int32_t polymer_bindmaterial(_prmaterial material, char* lights, int
|
||||||
if (lightcount)
|
if (lightcount)
|
||||||
programbits |= prprogrambits[PR_BIT_POINT_LIGHT].bit;
|
programbits |= prprogrambits[PR_BIT_POINT_LIGHT].bit;
|
||||||
|
|
||||||
|
// material override
|
||||||
|
programbits &= overridematerial;
|
||||||
|
|
||||||
|
programbits |= prprogrambits[PR_BIT_HEADER].bit;
|
||||||
|
programbits |= prprogrambits[PR_BIT_FOOTER].bit;
|
||||||
|
|
||||||
// --------- program compiling
|
// --------- program compiling
|
||||||
if (!prprograms[programbits].handle)
|
if (!prprograms[programbits].handle)
|
||||||
polymer_compileprogram(programbits);
|
polymer_compileprogram(programbits);
|
||||||
|
|
Loading…
Reference in a new issue