3D: Ensure correct fog handling for effects

This commit is contained in:
kaetemi 2014-08-05 02:58:55 +02:00
parent 19209b8028
commit c9762fbef5
2 changed files with 14 additions and 0 deletions

View file

@ -232,6 +232,10 @@ void CBloomEffect::applyBloom()
CDriverUser *dru = static_cast<CDriverUser *>(_Driver); CDriverUser *dru = static_cast<CDriverUser *>(_Driver);
IDriver *drv = dru->getDriver(); IDriver *drv = dru->getDriver();
// backup
bool fogEnabled = _Driver->fogEnabled();
_Driver->enableFog(false);
NL3D::ITexture *renderTarget = drv->getRenderTarget(); NL3D::ITexture *renderTarget = drv->getRenderTarget();
nlassert(renderTarget); nlassert(renderTarget);
nlassert(renderTarget->isBloomTexture()); nlassert(renderTarget->isBloomTexture());
@ -286,6 +290,9 @@ void CBloomEffect::applyBloom()
_BlurMat.getObjectPtr()->setTexture(2, NULL); _BlurMat.getObjectPtr()->setTexture(2, NULL);
_BlurMat.getObjectPtr()->setTexture(3, NULL); _BlurMat.getObjectPtr()->setTexture(3, NULL);
// restore
_Driver->enableFog(fogEnabled);
// recycle render targets // recycle render targets
_Driver->getRenderTargetManager().recycleRenderTarget(_BlurFinalTex); _Driver->getRenderTargetManager().recycleRenderTarget(_BlurFinalTex);
_BlurFinalTex = NULL; _BlurFinalTex = NULL;

View file

@ -199,6 +199,10 @@ void CFXAA::applyEffect()
CDriverUser *dru = static_cast<CDriverUser *>(m_Driver); CDriverUser *dru = static_cast<CDriverUser *>(m_Driver);
IDriver *drv = dru->getDriver(); IDriver *drv = dru->getDriver();
// backup
bool fogEnabled = m_Driver->fogEnabled();
m_Driver->enableFog(false);
NL3D::ITexture *renderTarget = drv->getRenderTarget(); NL3D::ITexture *renderTarget = drv->getRenderTarget();
nlassert(renderTarget); nlassert(renderTarget);
nlassert(renderTarget->isBloomTexture()); nlassert(renderTarget->isBloomTexture());
@ -275,6 +279,9 @@ void CFXAA::applyEffect()
drv->activeVertexProgram(NULL); drv->activeVertexProgram(NULL);
drv->activePixelProgram(NULL); drv->activePixelProgram(NULL);
// restore
m_Driver->enableFog(fogEnabled);
// recycle render target // recycle render target
m_Driver->getRenderTargetManager().recycleRenderTarget(otherRenderTarget); m_Driver->getRenderTargetManager().recycleRenderTarget(otherRenderTarget);
} }