Do not allow fog start to be null

This commit is contained in:
Vincent Lejeune 2014-12-18 01:30:53 +01:00
parent e3879abb5b
commit 6139f43108
4 changed files with 22 additions and 41 deletions

View File

@ -544,32 +544,6 @@ void PostProcessing::renderSSAO()
DrawFullScreenEffect<FullScreenShader::SSAOShader>(irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma());
}
void PostProcessing::renderFog()
{
const Track * const track = World::getWorld()->getTrack();
// This function is only called once per frame - thus no need for setters.
const float start = track->getFogStart();
const SColor tmpcol = track->getFogColor();
core::vector3df col( tmpcol.getRed() / 255.0f,
tmpcol.getGreen() / 255.0f,
tmpcol.getBlue() / 255.0f );
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE);
FullScreenShader::FogShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::FogShader>(1.f / (40.f * start), col);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
}
void PostProcessing::renderMotionBlur(unsigned cam, FrameBuffer &in_fbo, FrameBuffer &out_fbo)
{
MotionBlurProvider * const cb = (MotionBlurProvider *)irr_driver->

View File

@ -77,7 +77,6 @@ public:
void renderSunlight(const core::vector3df &direction, const video::SColorf &col);
void renderShadowedSunlight(const core::vector3df &direction, const video::SColorf &col, const std::vector<core::matrix4> &sun_ortho_matrix, unsigned depthtex);
void renderFog();
void renderSSAO();
void renderEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff, unsigned skycubemap);
void renderRHDebug(unsigned SHR, unsigned SHG, unsigned SHB, const core::matrix4 &rh_matrix, const core::vector3df &rh_extend);

View File

@ -190,35 +190,42 @@ void IrrDriver::renderLightsScatter(unsigned pointlightcount)
getFBO(FBO_HALF1).Bind();
glClearColor(0., 0., 0., 0.);
glClear(GL_COLOR_BUFFER_BIT);
m_post_processing->renderFog();
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
const Track * const track = World::getWorld()->getTrack();
const float start = track->getFogStart();
core::vector3df col(1., 1., 1.);
// This function is only called once per frame - thus no need for setters.
float start = track->getFogStart() + .001;
const video::SColor tmpcol = track->getFogColor();
core::vector3df col(tmpcol.getRed() / 255.0f,
tmpcol.getGreen() / 255.0f,
tmpcol.getBlue() / 255.0f);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE);
FullScreenShader::FogShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
DrawFullScreenEffect<FullScreenShader::FogShader>(1.f / (40.f * start), col);
glEnable(GL_DEPTH_TEST);
core::vector3df col2(1., 1., 1.);
glUseProgram(LightShader::PointLightScatterShader::getInstance()->Program);
glBindVertexArray(LightShader::PointLightScatterShader::getInstance()->vao);
LightShader::PointLightScatterShader::getInstance()->SetTextureUnits(irr_driver->getDepthStencilTexture());
LightShader::PointLightScatterShader::getInstance()->setUniforms(1.f / (40.f * start), col);
LightShader::PointLightScatterShader::getInstance()->setUniforms(1.f / (40.f * start), col2);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, MIN2(pointlightcount, MAXLIGHT));
// ***
// That might be a performance issue but if disabled the quality is severly affected (the picture looks jagged)
// It should be an option if there is a gain in FPS
glDisable(GL_BLEND);
m_post_processing->renderGaussian6Blur(getFBO(FBO_HALF1), getFBO(FBO_HALF2), 5., 5.);
glEnable(GL_BLEND);
// ***
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
getFBO(FBO_COLORS).Bind();
m_post_processing->renderPassThrough(getRenderTargetTexture(RTT_HALF1));

View File

@ -380,6 +380,7 @@ void IrrDriver::renderSkybox(const scene::ICameraSceneNode *camera)
if (SkyboxTextures.empty())
return;
glBindVertexArray(MeshShader::SkyboxShader::getInstance()->cubevao);
glEnable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
assert(SkyboxTextures.size() == 6);