fixed smaa stencil interleaving

master
Lee Salzman 2013-02-19 21:37:25 +02:00
parent 4b82d3bb59
commit 02bb8da93c
1 changed files with 78 additions and 69 deletions

View File

@ -599,6 +599,7 @@ VARFP(smaacoloredge, 0, 0, 1, cleanupsmaa());
VARFP(smaagreenluma, 0, 0, 1, cleanupsmaa());
VARF(smaadepthmask, 0, 1, 1, cleanupsmaa());
VARF(smaastencil, 0, 1, 1, cleanupsmaa());
VARF(smaainterleave, 0, 2, 2, cleanupsmaa());
VAR(debugsmaa, 0, 0, 5);
void viewsmaa()
@ -629,20 +630,25 @@ void dosmaa(GLuint outfbo = 0, bool split = false)
if(tqaa) packtqaa();
int cleardepth = msaasamples ? GL_DEPTH_BUFFER_BIT | ((gdepthstencil && hasDS) || gstencil ? GL_STENCIL_BUFFER_BIT : 0) : 0;
bool hasstencil = (gdepthstencil && hasDS) || gstencil;
int cleardepth = msaasamples ? GL_DEPTH_BUFFER_BIT | (hasstencil ? GL_STENCIL_BUFFER_BIT : 0) : 0,
stencilpasses = split && (!smaainterleave || (!smaadepthmask && smaastencil && hasstencil && smaainterleave < 2)) ? 2 : 1,
numpasses = split && stencilpasses <= 1 ? 2 : 1;
loop(stencilpass, stencilpasses)
{
if(smaadepthmask)
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
}
else if(smaastencil && ((gdepthstencil && hasDS) || gstencil))
else if(smaastencil && hasstencil)
{
glEnable(GL_STENCIL_TEST);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
}
if(smaacoloredge) smaacoloredgeshader->set();
else smaalumaedgeshader->set();
loop(pass, split ? 2 : 1)
for(int pass = stencilpass; pass < stencilpass + numpasses; pass++)
{
glBindFramebuffer_(GL_FRAMEBUFFER_EXT, smaafbo[1 + 2*pass]);
if(smaadepthmask || smaastencil)
@ -655,9 +661,10 @@ void dosmaa(GLuint outfbo = 0, bool split = false)
float depthval = cleardepth ? 0.25f*(pass+1) : 1;
glDepthRange(depthval, depthval);
}
else if(smaastencil && ((gdepthstencil && hasDS) || gstencil))
else if(smaastencil && hasstencil)
{
glStencilFunc(GL_ALWAYS, 0x10*(pass+1), ~0);
if(numpasses >= 2 && pass) glStencilMask(0x10*(pass+1));
}
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaatex[pass ? 5 : 0]);
screenquad(vieww, viewh);
@ -668,12 +675,13 @@ void dosmaa(GLuint outfbo = 0, bool split = false)
glDepthFunc(GL_EQUAL);
glDepthMask(GL_FALSE);
}
else if(smaastencil && ((gdepthstencil && hasDS) || gstencil))
else if(smaastencil && hasstencil)
{
if(numpasses >= 2) glStencilMask(~0);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
}
smaablendweightshader->set();
loop(pass, split ? 2 : 1)
for(int pass = stencilpass; pass < stencilpass + numpasses; pass++)
{
glBindFramebuffer_(GL_FRAMEBUFFER_EXT, smaafbo[2 + 2*pass]);
if(smaadepthmask)
@ -681,7 +689,7 @@ void dosmaa(GLuint outfbo = 0, bool split = false)
float depthval = cleardepth ? 0.25f*(pass+1) : 1;
glDepthRange(depthval, depthval);
}
else if(smaastencil && ((gdepthstencil && hasDS) || gstencil))
else if(smaastencil && hasstencil)
{
glStencilFunc(GL_EQUAL, 0x10*(pass+1), ~0);
}
@ -712,7 +720,8 @@ void dosmaa(GLuint outfbo = 0, bool split = false)
glDepthFunc(GL_LESS);
glDepthRange(0, 1);
}
else if(smaastencil && ((gdepthstencil && hasDS) || gstencil)) glDisable(GL_STENCIL_TEST);
else if(smaastencil && hasstencil) glDisable(GL_STENCIL_TEST);
}
glBindFramebuffer_(GL_FRAMEBUFFER_EXT, tqaa ? tqaafbo[0] : outfbo);
smaaneighborhoodshader->set();