Beispiel #1
0
void DepthOfField::apply
(RenderDevice*                  rd,
 shared_ptr<Texture>            color,
 shared_ptr<Texture>            depth,
 const shared_ptr<Camera>&      camera,
 Vector2int16                   trimBandThickness) {

    if ((camera->depthOfFieldSettings().model() == DepthOfFieldModel::NONE) || ! camera->depthOfFieldSettings().enabled()) {
        const shared_ptr<Framebuffer>& f = rd->framebuffer();
        const shared_ptr<Framebuffer::Attachment>& a = f->get(Framebuffer::COLOR0);

        if (isNull(f) || (a->texture() != color)) {
            Texture::copy(color, a->texture(), 0, 0, Vector2int16(0, 0), CubeFace::POS_X, CubeFace::POS_X, rd, false);
        }

        // Exit abruptly because DoF is disabled
        return;
    }

    alwaysAssertM(color, "Color buffer may not be NULL");
    alwaysAssertM(depth, "Depth buffer may not be NULL");

    if (isNull(m_artistCoCShader)) {
        reloadShaders();
    }
    resizeBuffers(color, trimBandThickness);

    computeCoC(rd, color, depth, camera, trimBandThickness);
    blurPass(rd, m_packedBuffer, m_horizontalFramebuffer, m_horizontalShader, camera);
    blurPass(rd, m_tempBlurBuffer, m_verticalFramebuffer, m_verticalShader, camera);
    composite(rd, m_packedBuffer, m_blurBuffer, trimBandThickness);
}
Beispiel #2
0
void VSMPerPixelRenderer::afterShadowDraw(int L)
{
    if(_shaderDepth)_shaderDepth->end();
    //begin blur
    glDisable(GL_DEPTH_TEST);
    glDepthMask(GL_FALSE);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0.0f,1.0f,0.0f,1.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    //blur horizontally
    blurPass(1.0f/(_w*_shadowRatio),0.0f,_fboTmp,_ctid[L]);
    //blur vertically
    blurPass(0.0f,1.0f/(_h*_shadowRatio),_fboId[L],_ctTmp);
    //end blur
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);
    checkGLError();
}