mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 23:02:01 +00:00
Fix stencil shadows not drawing if has 500 or more vertexes
Stencil shadow is not drawn if a mesh, or multiple meshes with the same entity and shader, have more than 500 vertexes. The issue is caused by storing the projected positions in the tess vertex buffer. Use a new array instead.
This commit is contained in:
parent
d06deb41c8
commit
c787cf3aef
2 changed files with 16 additions and 24 deletions
|
@ -44,6 +44,7 @@ typedef struct {
|
||||||
static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS];
|
static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS];
|
||||||
static int numEdgeDefs[SHADER_MAX_VERTEXES];
|
static int numEdgeDefs[SHADER_MAX_VERTEXES];
|
||||||
static int facing[SHADER_MAX_INDEXES/3];
|
static int facing[SHADER_MAX_INDEXES/3];
|
||||||
|
static vec3_t shadowXyz[SHADER_MAX_VERTEXES];
|
||||||
|
|
||||||
void R_AddEdgeDef( int i1, int i2, int facing ) {
|
void R_AddEdgeDef( int i1, int i2, int facing ) {
|
||||||
int c;
|
int c;
|
||||||
|
@ -80,13 +81,13 @@ void R_RenderShadowEdges( void ) {
|
||||||
|
|
||||||
qglBegin( GL_TRIANGLE_STRIP );
|
qglBegin( GL_TRIANGLE_STRIP );
|
||||||
qglVertex3fv( tess.xyz[ i1 ] );
|
qglVertex3fv( tess.xyz[ i1 ] );
|
||||||
qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i1 ] );
|
||||||
qglVertex3fv( tess.xyz[ i2 ] );
|
qglVertex3fv( tess.xyz[ i2 ] );
|
||||||
qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i2 ] );
|
||||||
qglVertex3fv( tess.xyz[ i3 ] );
|
qglVertex3fv( tess.xyz[ i3 ] );
|
||||||
qglVertex3fv( tess.xyz[ i3 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i3 ] );
|
||||||
qglVertex3fv( tess.xyz[ i1 ] );
|
qglVertex3fv( tess.xyz[ i1 ] );
|
||||||
qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i1 ] );
|
||||||
qglEnd();
|
qglEnd();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -126,9 +127,9 @@ void R_RenderShadowEdges( void ) {
|
||||||
if ( hit[ 1 ] == 0 ) {
|
if ( hit[ 1 ] == 0 ) {
|
||||||
qglBegin( GL_TRIANGLE_STRIP );
|
qglBegin( GL_TRIANGLE_STRIP );
|
||||||
qglVertex3fv( tess.xyz[ i ] );
|
qglVertex3fv( tess.xyz[ i ] );
|
||||||
qglVertex3fv( tess.xyz[ i + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i ] );
|
||||||
qglVertex3fv( tess.xyz[ i2 ] );
|
qglVertex3fv( tess.xyz[ i2 ] );
|
||||||
qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i2 ] );
|
||||||
qglEnd();
|
qglEnd();
|
||||||
c_edges++;
|
c_edges++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -157,11 +158,6 @@ void RB_ShadowTessEnd( void ) {
|
||||||
vec3_t lightDir;
|
vec3_t lightDir;
|
||||||
GLboolean rgba[4];
|
GLboolean rgba[4];
|
||||||
|
|
||||||
// we can only do this if we have enough space in the vertex buffers
|
|
||||||
if ( tess.numVertexes >= SHADER_MAX_VERTEXES / 2 ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( glConfig.stencilBits < 4 ) {
|
if ( glConfig.stencilBits < 4 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +166,7 @@ void RB_ShadowTessEnd( void ) {
|
||||||
|
|
||||||
// project vertexes away from light direction
|
// project vertexes away from light direction
|
||||||
for ( i = 0 ; i < tess.numVertexes ; i++ ) {
|
for ( i = 0 ; i < tess.numVertexes ; i++ ) {
|
||||||
VectorMA( tess.xyz[i], -512, lightDir, tess.xyz[i+tess.numVertexes] );
|
VectorMA( tess.xyz[i], -512, lightDir, shadowXyz[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// decide which triangles face the light
|
// decide which triangles face the light
|
||||||
|
|
|
@ -44,6 +44,7 @@ typedef struct {
|
||||||
static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS];
|
static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS];
|
||||||
static int numEdgeDefs[SHADER_MAX_VERTEXES];
|
static int numEdgeDefs[SHADER_MAX_VERTEXES];
|
||||||
static int facing[SHADER_MAX_INDEXES/3];
|
static int facing[SHADER_MAX_INDEXES/3];
|
||||||
|
static vec3_t shadowXyz[SHADER_MAX_VERTEXES];
|
||||||
|
|
||||||
void R_AddEdgeDef( int i1, int i2, int facing ) {
|
void R_AddEdgeDef( int i1, int i2, int facing ) {
|
||||||
int c;
|
int c;
|
||||||
|
@ -80,13 +81,13 @@ void R_RenderShadowEdges( void ) {
|
||||||
|
|
||||||
qglBegin( GL_TRIANGLE_STRIP );
|
qglBegin( GL_TRIANGLE_STRIP );
|
||||||
qglVertex3fv( tess.xyz[ i1 ] );
|
qglVertex3fv( tess.xyz[ i1 ] );
|
||||||
qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i1 ] );
|
||||||
qglVertex3fv( tess.xyz[ i2 ] );
|
qglVertex3fv( tess.xyz[ i2 ] );
|
||||||
qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i2 ] );
|
||||||
qglVertex3fv( tess.xyz[ i3 ] );
|
qglVertex3fv( tess.xyz[ i3 ] );
|
||||||
qglVertex3fv( tess.xyz[ i3 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i3 ] );
|
||||||
qglVertex3fv( tess.xyz[ i1 ] );
|
qglVertex3fv( tess.xyz[ i1 ] );
|
||||||
qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i1 ] );
|
||||||
qglEnd();
|
qglEnd();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -126,9 +127,9 @@ void R_RenderShadowEdges( void ) {
|
||||||
if ( hit[ 1 ] == 0 ) {
|
if ( hit[ 1 ] == 0 ) {
|
||||||
qglBegin( GL_TRIANGLE_STRIP );
|
qglBegin( GL_TRIANGLE_STRIP );
|
||||||
qglVertex3fv( tess.xyz[ i ] );
|
qglVertex3fv( tess.xyz[ i ] );
|
||||||
qglVertex3fv( tess.xyz[ i + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i ] );
|
||||||
qglVertex3fv( tess.xyz[ i2 ] );
|
qglVertex3fv( tess.xyz[ i2 ] );
|
||||||
qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );
|
qglVertex3fv( shadowXyz[ i2 ] );
|
||||||
qglEnd();
|
qglEnd();
|
||||||
c_edges++;
|
c_edges++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -157,11 +158,6 @@ void RB_ShadowTessEnd( void ) {
|
||||||
vec3_t lightDir;
|
vec3_t lightDir;
|
||||||
GLboolean rgba[4];
|
GLboolean rgba[4];
|
||||||
|
|
||||||
// we can only do this if we have enough space in the vertex buffers
|
|
||||||
if ( tess.numVertexes >= SHADER_MAX_VERTEXES / 2 ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( glConfig.stencilBits < 4 ) {
|
if ( glConfig.stencilBits < 4 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +166,7 @@ void RB_ShadowTessEnd( void ) {
|
||||||
|
|
||||||
// project vertexes away from light direction
|
// project vertexes away from light direction
|
||||||
for ( i = 0 ; i < tess.numVertexes ; i++ ) {
|
for ( i = 0 ; i < tess.numVertexes ; i++ ) {
|
||||||
VectorMA( tess.xyz[i], -512, lightDir, tess.xyz[i+tess.numVertexes] );
|
VectorMA( tess.xyz[i], -512, lightDir, shadowXyz[i] );
|
||||||
}
|
}
|
||||||
|
|
||||||
// decide which triangles face the light
|
// decide which triangles face the light
|
||||||
|
|
Loading…
Reference in a new issue