From e07d7fbadb149ec00d88c7a3b814287467320163 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 16 Nov 2014 21:21:15 -0600 Subject: 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. --- src/renderergl1/tr_shadows.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/renderergl1') 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 -- cgit