Added exposure pass calculating the bloom/tonemap exposure based on what the eye is seeing

This commit is contained in:
Magnus Norddahl 2016-09-18 15:57:22 +02:00 committed by Christoph Oelckers
commit f7b6b1433c
17 changed files with 358 additions and 40 deletions

View file

@ -45,7 +45,7 @@ FGLPostProcessState::FGLPostProcessState()
{
glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTex);
glActiveTexture(GL_TEXTURE0);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[0]);
glBindTexture(GL_TEXTURE_2D, 0);
if (gl.flags & RFL_SAMPLER_OBJECTS)
{
@ -75,6 +75,15 @@ FGLPostProcessState::FGLPostProcessState()
glDisable(GL_BLEND);
}
void FGLPostProcessState::SaveTextureBinding1()
{
glActiveTexture(GL_TEXTURE1);
glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding[1]);
glBindTexture(GL_TEXTURE_2D, 0);
textureBinding1Saved = true;
glActiveTexture(GL_TEXTURE0);
}
//-----------------------------------------------------------------------------
//
// Restores state at the end of post processing
@ -108,6 +117,12 @@ FGLPostProcessState::~FGLPostProcessState()
glUseProgram(currentProgram);
if (textureBinding1Saved)
{
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0);
}
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
if (gl.flags & RFL_SAMPLER_OBJECTS)
@ -115,6 +130,13 @@ FGLPostProcessState::~FGLPostProcessState()
glBindSampler(0, samplerBinding[0]);
glBindSampler(1, samplerBinding[1]);
}
glBindTexture(GL_TEXTURE_2D, textureBinding);
glBindTexture(GL_TEXTURE_2D, textureBinding[0]);
if (textureBinding1Saved)
{
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, textureBinding[1]);
}
glActiveTexture(activeTex);
}