Reorder post processes effects.

This commit is contained in:
Vincent Lejeune 2014-04-22 20:48:17 +02:00 committed by vlj
parent eb0c948e41
commit 1bb4926ba2

View File

@ -637,6 +637,78 @@ void PostProcessing::render()
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
PROFILER_PUSH_CPU_MARKER("- Godrays", 0xFF, 0x00, 0x00);
if (UserConfigParams::m_light_shaft && m_sunpixels > 30)//World::getWorld()->getTrack()->hasGodRays() && ) // god rays
{
glEnable(GL_DEPTH_TEST);
// Grab the sky
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
glClear(GL_COLOR_BUFFER_BIT);
irr_driver->renderSkybox();
// Set the sun's color
const SColor col = World::getWorld()->getTrack()->getSunColor();
ColorizeProvider * const colcb = (ColorizeProvider *)irr_driver->getCallback(ES_COLORIZE);
colcb->setColor(col.getRed() / 255.0f, col.getGreen() / 255.0f, col.getBlue() / 255.0f);
// The sun interposer
STKMeshSceneNode *sun = irr_driver->getSunInterposer();
irr_driver->getSceneManager()->drawAll(ESNRP_CAMERA);
irr_driver->setPhase(GLOW_PASS);
sun->render();
glDisable(GL_DEPTH_TEST);
// Fade to quarter
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER1));
glViewport(0, 0, UserConfigParams::m_width / 4, UserConfigParams::m_height / 4);
renderGodFade(out_rtt, col);
// Blur
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
UserConfigParams::m_width / 4,
UserConfigParams::m_height / 4);
// Calculate the sun's position in texcoords
const core::vector3df pos = sun->getPosition();
float ndc[4];
core::matrix4 trans = camnode->getProjectionMatrix();
trans *= camnode->getViewMatrix();
trans.transformVect(ndc, pos);
const float texh = m_vertices[cam].v1.TCoords.Y - m_vertices[cam].v0.TCoords.Y;
const float texw = m_vertices[cam].v3.TCoords.X - m_vertices[cam].v0.TCoords.X;
const float sunx = ((ndc[0] / ndc[3]) * 0.5f + 0.5f) * texw;
const float suny = ((ndc[1] / ndc[3]) * 0.5f + 0.5f) * texh;
// Rays please
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER2));
renderGodRay(irr_driver->getRenderTargetTexture(RTT_QUARTER1), core::vector2df(sunx, suny));
// Blur
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
UserConfigParams::m_width / 4,
UserConfigParams::m_height / 4);
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
// Blend
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_ADD);
glBindFramebuffer(GL_FRAMEBUFFER, in_fbo);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_QUARTER2));
glDisable(GL_BLEND);
}
PROFILER_POP_CPU_MARKER();
// Simulate camera defects from there
PROFILER_PUSH_CPU_MARKER("- Bloom", 0xFF, 0x00, 0x00);
if (UserConfigParams::m_bloom)
{
@ -691,7 +763,6 @@ void PostProcessing::render()
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_BLOOM_512));
glDisable(GL_BLEND);
} // end if bloom
PROFILER_POP_CPU_MARKER();
computeLogLuminance(in_rtt);
@ -699,76 +770,6 @@ void PostProcessing::render()
std::swap(in_rtt, out_rtt);
std::swap(in_fbo, out_fbo);
PROFILER_PUSH_CPU_MARKER("- Godrays", 0xFF, 0x00, 0x00);
if (UserConfigParams::m_light_shaft && m_sunpixels > 30)//World::getWorld()->getTrack()->hasGodRays() && ) // god rays
{
glEnable(GL_DEPTH_TEST);
// Grab the sky
glBindFramebuffer(GL_FRAMEBUFFER, out_fbo);
glClear(GL_COLOR_BUFFER_BIT);
irr_driver->renderSkybox();
// Set the sun's color
const SColor col = World::getWorld()->getTrack()->getSunColor();
ColorizeProvider * const colcb = (ColorizeProvider *) irr_driver->getCallback(ES_COLORIZE);
colcb->setColor(col.getRed() / 255.0f, col.getGreen() / 255.0f, col.getBlue() / 255.0f);
// The sun interposer
STKMeshSceneNode *sun = irr_driver->getSunInterposer();
irr_driver->getSceneManager()->drawAll(ESNRP_CAMERA);
irr_driver->setPhase(GLOW_PASS);
sun->render();
glDisable(GL_DEPTH_TEST);
// Fade to quarter
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER1));
glViewport(0, 0, UserConfigParams::m_width / 4, UserConfigParams::m_height / 4);
renderGodFade(out_rtt, col);
// Blur
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
UserConfigParams::m_width / 4,
UserConfigParams::m_height / 4);
// Calculate the sun's position in texcoords
const core::vector3df pos = sun->getPosition();
float ndc[4];
core::matrix4 trans = camnode->getProjectionMatrix();
trans *= camnode->getViewMatrix();
trans.transformVect(ndc, pos);
const float texh = m_vertices[cam].v1.TCoords.Y - m_vertices[cam].v0.TCoords.Y;
const float texw = m_vertices[cam].v3.TCoords.X - m_vertices[cam].v0.TCoords.X;
const float sunx = ((ndc[0] / ndc[3]) * 0.5f + 0.5f) * texw;
const float suny = ((ndc[1] / ndc[3]) * 0.5f + 0.5f) * texh;
// Rays please
glBindFramebuffer(GL_FRAMEBUFFER, irr_driver->getFBO(FBO_QUARTER2));
renderGodRay(irr_driver->getRenderTargetTexture(RTT_QUARTER1), core::vector2df(sunx, suny));
// Blur
renderGaussian3Blur(irr_driver->getFBO(FBO_QUARTER2), irr_driver->getRenderTargetTexture(RTT_QUARTER2),
irr_driver->getFBO(FBO_QUARTER1), irr_driver->getRenderTargetTexture(RTT_QUARTER1),
UserConfigParams::m_width / 4,
UserConfigParams::m_height / 4);
glViewport(0, 0, UserConfigParams::m_width, UserConfigParams::m_height);
// Blend
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
glBlendEquation(GL_FUNC_ADD);
glBindFramebuffer(GL_FRAMEBUFFER, in_fbo);
renderPassThrough(irr_driver->getRenderTargetTexture(RTT_QUARTER2));
glDisable(GL_BLEND);
}
PROFILER_POP_CPU_MARKER();
if (UserConfigParams::m_motionblur && m_any_boost) // motion blur
{
PROFILER_PUSH_CPU_MARKER("- Motion blur", 0xFF, 0x00, 0x00);