revert smaa interleaving idea since it is horribly broken
parent
02bb8da93c
commit
1ca41cbf78
|
@ -236,7 +236,7 @@ void dofxaa(GLuint outfbo = 0)
|
|||
endtimer(fxaatimer);
|
||||
}
|
||||
|
||||
GLuint smaaareatex = 0, smaasearchtex = 0, smaafbo[5] = { 0, 0, 0, 0 , 0}, smaatex[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
GLuint smaaareatex = 0, smaasearchtex = 0, smaafbo[4] = { 0, 0, 0, 0 }, smaatex[5] = { 0, 0, 0, 0, 0 };
|
||||
int smaasubsampleorder = -1;
|
||||
|
||||
extern int smaaquality, smaagreenluma, smaacoloredge, smaadepthmask, smaastencil;
|
||||
|
@ -549,7 +549,7 @@ void setupsmaa(int w, int h)
|
|||
smaat2x = tqaa ? 1 : 0;
|
||||
smaas2x = split ? 1 : 0;
|
||||
smaa4x = tqaa && split ? 1 : 0;
|
||||
loopi(split ? 5 : 3)
|
||||
loopi(split ? 4 : 3)
|
||||
{
|
||||
if(!smaatex[i]) glGenTextures(1, &smaatex[i]);
|
||||
if(!smaafbo[i]) glGenFramebuffers_(1, &smaafbo[i]);
|
||||
|
@ -558,16 +558,16 @@ void setupsmaa(int w, int h)
|
|||
switch(i)
|
||||
{
|
||||
case 0: format = tqaa || (!smaagreenluma && !smaacoloredge) ? GL_RGBA8 : GL_RGB; break;
|
||||
case 1: case 3: format = hasTRG ? GL_RG8 : GL_RGBA8; break;
|
||||
case 2: case 4: format = GL_RGBA8; break;
|
||||
case 1: format = hasTRG ? GL_RG8 : GL_RGBA8; break;
|
||||
case 2: case 3: format = GL_RGBA8; break;
|
||||
}
|
||||
createtexture(smaatex[i], w, h, NULL, 3, 1, format, GL_TEXTURE_RECTANGLE_ARB);
|
||||
glFramebufferTexture2D_(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, smaatex[i], 0);
|
||||
if(!i && split)
|
||||
{
|
||||
if(!smaatex[5]) glGenTextures(1, &smaatex[5]);
|
||||
createtexture(smaatex[5], w, h, NULL, 3, 1, format, GL_TEXTURE_RECTANGLE_ARB);
|
||||
glFramebufferTexture2D_(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB, smaatex[5], 0);
|
||||
if(!smaatex[4]) glGenTextures(1, &smaatex[4]);
|
||||
createtexture(smaatex[4], w, h, NULL, 3, 1, format, GL_TEXTURE_RECTANGLE_ARB);
|
||||
glFramebufferTexture2D_(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB, smaatex[4], 0);
|
||||
static const GLenum drawbufs[2] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT };
|
||||
glDrawBuffers_(2, drawbufs);
|
||||
}
|
||||
|
@ -584,8 +584,8 @@ void cleanupsmaa()
|
|||
{
|
||||
if(smaaareatex) { glDeleteTextures(1, &smaaareatex); smaaareatex = 0; }
|
||||
if(smaasearchtex) { glDeleteTextures(1, &smaasearchtex); smaasearchtex = 0; }
|
||||
loopi(5) if(smaafbo[i]) { glDeleteFramebuffers_(1, &smaafbo[i]); smaafbo[i] = 0; }
|
||||
loopi(6) if(smaatex[i]) { glDeleteTextures(1, &smaatex[i]); smaatex[i] = 0; }
|
||||
loopi(4) if(smaafbo[i]) { glDeleteFramebuffers_(1, &smaafbo[i]); smaafbo[i] = 0; }
|
||||
loopi(5) if(smaatex[i]) { glDeleteTextures(1, &smaatex[i]); smaatex[i] = 0; }
|
||||
smaasubsampleorder = -1;
|
||||
smaat2x = smaas2x = smaa4x = 0;
|
||||
|
||||
|
@ -599,7 +599,6 @@ 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()
|
||||
|
@ -630,89 +629,63 @@ void dosmaa(GLuint outfbo = 0, bool split = false)
|
|||
|
||||
if(tqaa) packtqaa();
|
||||
|
||||
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)
|
||||
int cleardepth = msaasamples ? GL_DEPTH_BUFFER_BIT | ((gdepthstencil && hasDS) || gstencil ? GL_STENCIL_BUFFER_BIT : 0) : 0;
|
||||
loop(pass, split ? 2 : 1)
|
||||
{
|
||||
glBindFramebuffer_(GL_FRAMEBUFFER_EXT, smaafbo[1]);
|
||||
if(smaadepthmask || smaastencil)
|
||||
{
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | (!pass ? cleardepth : 0));
|
||||
}
|
||||
if(smaadepthmask)
|
||||
{
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
float depthval = cleardepth ? 0.25f*(pass+1) : 1;
|
||||
glDepthRange(depthval, depthval);
|
||||
}
|
||||
else if(smaastencil && hasstencil)
|
||||
else if(smaastencil && ((gdepthstencil && hasDS) || gstencil))
|
||||
{
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glStencilFunc(GL_ALWAYS, 0x10*(pass+1), ~0);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
}
|
||||
if(smaacoloredge) smaacoloredgeshader->set();
|
||||
else smaalumaedgeshader->set();
|
||||
for(int pass = stencilpass; pass < stencilpass + numpasses; pass++)
|
||||
{
|
||||
glBindFramebuffer_(GL_FRAMEBUFFER_EXT, smaafbo[1 + 2*pass]);
|
||||
if(smaadepthmask || smaastencil)
|
||||
{
|
||||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | (!pass ? cleardepth : 0));
|
||||
}
|
||||
if(smaadepthmask)
|
||||
{
|
||||
float depthval = cleardepth ? 0.25f*(pass+1) : 1;
|
||||
glDepthRange(depthval, depthval);
|
||||
}
|
||||
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);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaatex[pass ? 4 : 0]);
|
||||
screenquad(vieww, viewh);
|
||||
|
||||
glBindFramebuffer_(GL_FRAMEBUFFER_EXT, smaafbo[2 + pass]);
|
||||
if(smaadepthmask)
|
||||
{
|
||||
glDepthFunc(GL_EQUAL);
|
||||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
else if(smaastencil && hasstencil)
|
||||
else if(smaastencil && ((gdepthstencil && hasDS) || gstencil))
|
||||
{
|
||||
if(numpasses >= 2) glStencilMask(~0);
|
||||
glStencilFunc(GL_EQUAL, 0x10*(pass+1), ~0);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
}
|
||||
if(smaadepthmask || smaastencil) glClear(GL_COLOR_BUFFER_BIT);
|
||||
smaablendweightshader->set();
|
||||
for(int pass = stencilpass; pass < stencilpass + numpasses; pass++)
|
||||
vec4 subsamples(0, 0, 0, 0);
|
||||
if(tqaa && split) subsamples = tqaaframe&1 ? (pass != smaasubsampleorder ? vec4(6, 4, 2, 4) : vec4(3, 5, 1, 4)) : (pass != smaasubsampleorder ? vec4(4, 6, 2, 3) : vec4(5, 3, 1, 3));
|
||||
else if(tqaa) subsamples = tqaaframe&1 ? vec4(2, 2, 2, 0) : vec4(1, 1, 1, 0);
|
||||
else if(split) subsamples = pass != smaasubsampleorder ? vec4(2, 2, 2, 0) : vec4(1, 1, 1, 0);
|
||||
LOCALPARAM(subsamples, (subsamples));
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaatex[1]);
|
||||
glActiveTexture_(GL_TEXTURE1_ARB);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaaareatex);
|
||||
glActiveTexture_(GL_TEXTURE2_ARB);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaasearchtex);
|
||||
if(tqaa && tqaamovemask)
|
||||
{
|
||||
glBindFramebuffer_(GL_FRAMEBUFFER_EXT, smaafbo[2 + 2*pass]);
|
||||
if(smaadepthmask)
|
||||
{
|
||||
float depthval = cleardepth ? 0.25f*(pass+1) : 1;
|
||||
glDepthRange(depthval, depthval);
|
||||
}
|
||||
else if(smaastencil && hasstencil)
|
||||
{
|
||||
glStencilFunc(GL_EQUAL, 0x10*(pass+1), ~0);
|
||||
}
|
||||
if(smaadepthmask || smaastencil) glClear(GL_COLOR_BUFFER_BIT);
|
||||
vec4 subsamples(0, 0, 0, 0);
|
||||
if(tqaa && split) subsamples = tqaaframe&1 ? (pass != smaasubsampleorder ? vec4(6, 4, 2, 4) : vec4(3, 5, 1, 4)) : (pass != smaasubsampleorder ? vec4(4, 6, 2, 3) : vec4(5, 3, 1, 3));
|
||||
else if(tqaa) subsamples = tqaaframe&1 ? vec4(2, 2, 2, 0) : vec4(1, 1, 1, 0);
|
||||
else if(split) subsamples = pass != smaasubsampleorder ? vec4(2, 2, 2, 0) : vec4(1, 1, 1, 0);
|
||||
LOCALPARAM(subsamples, (subsamples));
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaatex[1 + 2*pass]);
|
||||
glActiveTexture_(GL_TEXTURE1_ARB);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaaareatex);
|
||||
glActiveTexture_(GL_TEXTURE2_ARB);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaasearchtex);
|
||||
if(tqaa && tqaamovemask)
|
||||
{
|
||||
glActiveTexture_(GL_TEXTURE3_ARB);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, tqaamasktex);
|
||||
}
|
||||
glActiveTexture_(GL_TEXTURE0_ARB);
|
||||
screenquadoffset(0, 0, vieww, viewh, -0.5f/(1<<tqaamovemaskreduce), -0.5f/(1<<tqaamovemaskreduce), vieww>>tqaamovemaskreduce, viewh>>tqaamovemaskreduce);
|
||||
}
|
||||
|
||||
glActiveTexture_(GL_TEXTURE3_ARB);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, tqaamasktex);
|
||||
}
|
||||
glActiveTexture_(GL_TEXTURE0_ARB);
|
||||
screenquadoffset(0, 0, vieww, viewh, -0.5f/(1<<tqaamovemaskreduce), -0.5f/(1<<tqaamovemaskreduce), vieww>>tqaamovemaskreduce, viewh>>tqaamovemaskreduce);
|
||||
if(smaadepthmask)
|
||||
{
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
@ -720,9 +693,9 @@ void dosmaa(GLuint outfbo = 0, bool split = false)
|
|||
glDepthFunc(GL_LESS);
|
||||
glDepthRange(0, 1);
|
||||
}
|
||||
else if(smaastencil && hasstencil) glDisable(GL_STENCIL_TEST);
|
||||
else if(smaastencil && ((gdepthstencil && hasDS) || gstencil)) glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
|
||||
glBindFramebuffer_(GL_FRAMEBUFFER_EXT, tqaa ? tqaafbo[0] : outfbo);
|
||||
smaaneighborhoodshader->set();
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaatex[0]);
|
||||
|
@ -731,9 +704,9 @@ void dosmaa(GLuint outfbo = 0, bool split = false)
|
|||
if(split)
|
||||
{
|
||||
glActiveTexture_(GL_TEXTURE2_ARB);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaatex[5]);
|
||||
glActiveTexture_(GL_TEXTURE3_ARB);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaatex[4]);
|
||||
glActiveTexture_(GL_TEXTURE3_ARB);
|
||||
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, smaatex[3]);
|
||||
}
|
||||
glActiveTexture_(GL_TEXTURE0_ARB);
|
||||
screenquad(vieww, viewh);
|
||||
|
|
Loading…
Reference in New Issue