summaryrefslogtreecommitdiff
path: root/src/renderergl1
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2014-11-16 21:21:15 -0600
committerTim Angus <tim@ngus.net>2015-03-17 11:39:01 +0000
commite07d7fbadb149ec00d88c7a3b814287467320163 (patch)
tree21c9fe0ac3c2aabf14e8ea4a24776aefbbef0529 /src/renderergl1
parent8e6b10ebe12fe53ae543df3af7a730218e40662d (diff)
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.
Diffstat (limited to 'src/renderergl1')
-rw-r--r--src/renderergl1/tr_shadows.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/renderergl1/tr_shadows.c b/src/renderergl1/tr_shadows.c
index 670b41d8..285a8d24 100644
--- a/src/renderergl1/tr_shadows.c
+++ b/src/renderergl1/tr_shadows.c
@@ -45,6 +45,7 @@ typedef struct {
static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS];
static int numEdgeDefs[SHADER_MAX_VERTEXES];
static int facing[SHADER_MAX_INDEXES/3];
+static vec3_t shadowXyz[SHADER_MAX_VERTEXES];
void R_AddEdgeDef( int i1, int i2, int facing ) {
int c;
@@ -81,13 +82,13 @@ void R_RenderShadowEdges( void ) {
qglBegin( GL_TRIANGLE_STRIP );
qglVertex3fv( tess.xyz[ i1 ] );
- qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );
+ qglVertex3fv( shadowXyz[ i1 ] );
qglVertex3fv( tess.xyz[ i2 ] );
- qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );
+ qglVertex3fv( shadowXyz[ i2 ] );
qglVertex3fv( tess.xyz[ i3 ] );
- qglVertex3fv( tess.xyz[ i3 + tess.numVertexes ] );
+ qglVertex3fv( shadowXyz[ i3 ] );
qglVertex3fv( tess.xyz[ i1 ] );
- qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] );
+ qglVertex3fv( shadowXyz[ i1 ] );
qglEnd();
}
#else
@@ -127,9 +128,9 @@ void R_RenderShadowEdges( void ) {
if ( hit[ 1 ] == 0 ) {
qglBegin( GL_TRIANGLE_STRIP );
qglVertex3fv( tess.xyz[ i ] );
- qglVertex3fv( tess.xyz[ i + tess.numVertexes ] );
+ qglVertex3fv( shadowXyz[ i ] );
qglVertex3fv( tess.xyz[ i2 ] );
- qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] );
+ qglVertex3fv( shadowXyz[ i2 ] );
qglEnd();
c_edges++;
} else {
@@ -158,11 +159,6 @@ void RB_ShadowTessEnd( void ) {
vec3_t lightDir;
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 ) {
return;
}
@@ -171,7 +167,7 @@ void RB_ShadowTessEnd( void ) {
// project vertexes away from light direction
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