A possible other alternative exists. This is fully depth-pass for both cases and seems to work in my (admittedly limited) testing so far.
Code: Select all
if (external)
{
glDepthFunc (GL_LEQUAL);
// view outside the shadow volume
GL_TwoSidedStencil (backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, GL_KEEP, tr.stencilIncr);
GL_TwoSidedStencil (backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, GL_KEEP, tr.stencilDecr);
RB_DrawShadowElementsWithCounters (tri, numIndexes);
}
else
{
glDepthFunc (GL_GEQUAL);
// view inside the shadow volume
GL_TwoSidedStencil (backEnd.viewDef->isMirror ? GL_FRONT : GL_BACK, GL_KEEP, GL_KEEP, tr.stencilDecr);
GL_TwoSidedStencil (backEnd.viewDef->isMirror ? GL_BACK : GL_FRONT, GL_KEEP, GL_KEEP, tr.stencilIncr);
RB_DrawShadowElementsWithCounters (tri, numIndexes);
}
"GL_TwoSidedStencil" just selects the appropriate two-sided stencil algorithm to use (EXT, ATI or core GL 2.0); on GL 2.0 or better hardware you'd just replace it with a call to glStencilOpSeparate.
If this does turn out to be a robust replacement that doesn't violate the patent, it just shows even more clearly how utterly nuts the patent was to begin with.