@@ -1143,6 +1143,8 @@ static void RB_T_Shadow( const drawSurf_t *surf ) {
11431143 return ;
11441144 }
11451145
1146+ #if 0 // LEITH: the original patent free "preload" code
1147+
11461148 // patent-free work around
11471149 if ( !external ) {
11481150 // "preload" the stencil buffer with the number of volumes
@@ -1163,6 +1165,30 @@ static void RB_T_Shadow( const drawSurf_t *surf ) {
11631165 qglStencilOp( GL_KEEP, GL_KEEP, tr.stencilDecr );
11641166 GL_Cull( CT_BACK_SIDED );
11651167 RB_DrawShadowElementsWithCounters( tri, numIndexes );
1168+
1169+ #else // LEITH: the patented "Carmack's Reverse" code
1170+
1171+ // patented depth-fail stencil shadows
1172+ if ( !external ) {
1173+ qglStencilOp ( GL_KEEP, tr.stencilDecr , GL_KEEP );
1174+ GL_Cull ( CT_FRONT_SIDED );
1175+ RB_DrawShadowElementsWithCounters ( tri, numIndexes );
1176+ qglStencilOp ( GL_KEEP, tr.stencilIncr , GL_KEEP );
1177+ GL_Cull ( CT_BACK_SIDED );
1178+ RB_DrawShadowElementsWithCounters ( tri, numIndexes );
1179+ }
1180+ // traditional depth-pass stencil shadows
1181+ else {
1182+ qglStencilOp ( GL_KEEP, GL_KEEP, tr.stencilIncr );
1183+ GL_Cull ( CT_FRONT_SIDED );
1184+ RB_DrawShadowElementsWithCounters ( tri, numIndexes );
1185+
1186+ qglStencilOp ( GL_KEEP, GL_KEEP, tr.stencilDecr );
1187+ GL_Cull ( CT_BACK_SIDED );
1188+ RB_DrawShadowElementsWithCounters ( tri, numIndexes );
1189+ }
1190+
1191+ #endif
11661192}
11671193
11681194/*
0 commit comments