Make possible to tweak exposure/lwhite in adm

This commit is contained in:
vlj 2014-04-24 17:47:17 +02:00
parent 84a1e32ade
commit ef07b25202
6 changed files with 40 additions and 6 deletions

View File

@ -2,6 +2,8 @@
uniform sampler2D tex;
uniform sampler2D logluminancetex;
uniform float exposure = .09;
uniform float Lwhite = 1.;
in vec2 uv;
out vec4 FragColor;
@ -9,8 +11,7 @@ out vec4 FragColor;
vec3 getCIEYxy(vec3 rgbColor);
vec3 getRGBFromCIEXxy(vec3 YxyColor);
float exposure = .09;
float Lwhite = 1.;
float delta = .0001;
float saturation = 1.;

View File

@ -99,6 +99,8 @@ private:
Shaders *m_shaders;
/** Wind. */
Wind *m_wind;
float m_exposure;
float m_lwhite;
/** RTTs. */
RTT *m_rtts;
/** Shadow importance. */
@ -160,6 +162,26 @@ public:
return 120;
}
float getExposure() const
{
return m_exposure;
}
void setExposure(float v)
{
m_exposure = v;
}
float getLwhite() const
{
return m_lwhite;
}
void setLwhite(float v)
{
m_lwhite = v;
}
private:
std::vector<VideoMode> m_modes;

View File

@ -530,7 +530,7 @@ static void toneMap(GLuint fbo, GLuint rtt)
glBindVertexArray(FullScreenShader::ToneMapShader::vao);
setTexture(0, rtt, GL_NEAREST, GL_NEAREST);
setTexture(1, irr_driver->getRenderTargetTexture(RTT_LOG_LUMINANCE), GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST);
FullScreenShader::ToneMapShader::setUniforms(0, 1);
FullScreenShader::ToneMapShader::setUniforms(irr_driver->getExposure(), irr_driver->getLwhite(), 0, 1);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}

View File

@ -2069,6 +2069,8 @@ namespace FullScreenShader
GLuint ToneMapShader::Program;
GLuint ToneMapShader::uniform_tex;
GLuint ToneMapShader::uniform_logluminancetex;
GLuint ToneMapShader::uniform_exposure;
GLuint ToneMapShader::uniform_lwhite;
GLuint ToneMapShader::vao;
void ToneMapShader::init()
@ -2080,13 +2082,17 @@ namespace FullScreenShader
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/tonemap.frag").c_str());
uniform_tex = glGetUniformLocation(Program, "tex");
uniform_logluminancetex = glGetUniformLocation(Program, "logluminancetex");
uniform_exposure = glGetUniformLocation(Program, "exposure");
uniform_lwhite = glGetUniformLocation(Program, "Lwhite");
vao = createVAO(Program);
}
void ToneMapShader::setUniforms(unsigned TU_tex, unsigned TU_loglum)
void ToneMapShader::setUniforms(float exposure, float Lwhite, unsigned TU_tex, unsigned TU_loglum)
{
glUniform1i(uniform_tex, TU_tex);
glUniform1i(uniform_logluminancetex, TU_loglum);
glUniform1f(uniform_exposure, exposure);
glUniform1f(uniform_lwhite, Lwhite);
}
GLuint DepthOfFieldShader::Program;

View File

@ -524,11 +524,11 @@ class ToneMapShader
{
public:
static GLuint Program;
static GLuint uniform_tex, uniform_logluminancetex;
static GLuint uniform_tex, uniform_logluminancetex, uniform_exposure, uniform_lwhite;
static GLuint vao;
static void init();
static void setUniforms(unsigned TU_tex, unsigned TU_logluminance);
static void setUniforms(float exposure, float Lwhite, unsigned TU_tex, unsigned TU_logluminance);
};
class DepthOfFieldShader

View File

@ -26,6 +26,7 @@
#include "modes/world.hpp"
#include "states_screens/state_manager.hpp"
#include "utils/translation.hpp"
#include "graphics/irr_driver.hpp"
using namespace GUIEngine;
@ -73,6 +74,10 @@ GUIEngine::EventPropagation DebugSliderDialog::processEvent(const std::string& e
{
int value = getWidget<SpinnerWidget>("value_slider")->getValue();
Log::info("DebugSlider", "Value for <%s> : %i", m_id.c_str(), value);
if (m_id == "lwhite")
irr_driver->setLwhite(value / 10.);
if (m_id == "exposure")
irr_driver->setExposure(value / 100.);
return GUIEngine::EVENT_BLOCK;
}