I followed Rich Whitehouse's tutorial, and he has it as
but i had to do this to get it to actually work...As I described above, this is reversing the face culling from the standard
method and changing the increment/decerement to when the depth test fails,
and simply keeping the value otherwise. Next go down to the function
GL_StencilShadowing. After this chunk of code:
while (g_numStencilEnts > 0)
{ //go through the list and do all the shadows
g_numStencilEnts--;
GL_StencilShadowModel(g_stencilEnts[g_numStencilEnts]);
}
We want to add:
glCullFace(GL_FRONT);
glDepthFunc(GL_LEQUAL);
And above that same chunk of code (the while (g_numStencil.. etc. line) we
want to add this:
glDepthFunc(GL_LESS);
Code: Select all
glStencilFunc(GL_ALWAYS, 0, 255);
glDepthFunc(GL_LESS);
while (g_numStencilEnts > 0)
{ //go through the list and do all the shadows
g_numStencilEnts--;
GL_StencilShadowModel(g_stencilEnts[g_numStencilEnts]);
}
glCullFace(GL_FRONT);
glDepthFunc(GL_LEQUAL);
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
//draw a full screen rectangle now - wherever we draw
//is where our "shadows" will actually be seen.
glColor4f( 0.0f, 0.0f, 0.0f, 0.6f );
glStencilFunc( GL_NOTEQUAL, 1, 255 );
glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
edit:
even the original version RwW had didnt work....
Code: Select all
if (r_shadows.value == 2)
{ //> 2 is a debug feature to draw the shadows outside of the stencil buffer
glEnable( GL_STENCIL_TEST );
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE );
}
else
{
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
}
glStencilFunc( GL_ALWAYS, 1, 0xFFFFFFFF );
while (g_numStencilEnts > 0)
{ //go through the list and do all the shadows
g_numStencilEnts--;
GL_StencilShadowModel(g_stencilEnts[g_numStencilEnts]);
}
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
//draw a full screen rectangle now - wherever we draw
//is where our "shadows" will actually be seen.
glColor4f( 0.0f, 0.0f, 0.0f, 0.6f );
glStencilFunc( GL_NOTEQUAL, 0, 0xFFFFFFFF );
glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
glEnable (GL_BLEND);
glPushMatrix(); //save the current view matrix