Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void initReduction()
- {
- reductionEffect->Bind();
- reductionEffect->Uniform("Mode", 0);
- sourceTexture->Bind(GL_TEXTURE0);
- GetWriteBuffer().BindWrite();
- drawQuad(0, 0, sourceTexture->Width(), sourceTexture->Height());
- SwapBuffers();
- }
- void Apply()
- {
- using namespace std;
- glPushAttrib(GL_ENABLE_BIT);
- glDisable(GL_STENCIL_TEST);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- glDisable(GL_CULL_FACE);
- initReduction();
- reductionEffect->Bind();
- reductionEffect->Uniform("KernelSize", kernelSize);
- reductionEffect->Uniform("Mode", 1);
- unsigned cWidth, cHeight;
- cWidth = sourceTexture->Width() / kernelSize;
- cHeight = sourceTexture->Height() / kernelSize;
- int iter = 2;
- while(cWidth > 1 || cHeight > 1)
- {
- GetReadBuffer().BindRead(GL_TEXTURE0);
- GetWriteBuffer().BindWrite();
- reductionEffect->Uniform("Iteration", iter);
- reductionEffect->Uniform("CWidth", cWidth);
- reductionEffect->Uniform("CHeight", cHeight);
- reductionEffect->Uniform("TexelSize", fvec2( 1.0f / cWidth, 1.0f / cHeight));
- drawQuad(0, 0, cWidth, cHeight);
- cWidth = max<unsigned>(cWidth / kernelSize, 1);
- cHeight = max<unsigned>(cHeight / kernelSize, 1);
- iter *= iter;
- SwapBuffers();
- }
- glPopAttrib();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement