Port Tonemap shader to singleton
Should fix kart selection screen without UBO support.
This commit is contained in:
parent
4faa7cf2b7
commit
160d061e84
@ -645,11 +645,10 @@ static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
|
||||
static void toneMap(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
fbo.Bind();
|
||||
glUseProgram(FullScreenShader::ToneMapShader::Program);
|
||||
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(irr_driver->getExposure(), irr_driver->getLwhite(), 0, 1);
|
||||
glUseProgram(FullScreenShader::ToneMapShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::ToneMapShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::ToneMapShader::getInstance()->TU_tex, rtt, GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::ToneMapShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
@ -400,7 +400,6 @@ void Shaders::loadShaders()
|
||||
FullScreenShader::MotionBlurShader::init();
|
||||
FullScreenShader::GodFadeShader::init();
|
||||
FullScreenShader::GodRayShader::init();
|
||||
FullScreenShader::ToneMapShader::init();
|
||||
FullScreenShader::MLAAColorEdgeDetectionSHader::init();
|
||||
FullScreenShader::MLAABlendWeightSHader::init();
|
||||
FullScreenShader::MLAAGatherSHader::init();
|
||||
@ -1588,35 +1587,19 @@ namespace FullScreenShader
|
||||
glUniform1i(uniform_tex_512, TU_tex_512);
|
||||
}
|
||||
|
||||
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()
|
||||
ToneMapShader::ToneMapShader()
|
||||
{
|
||||
Program = LoadProgram(
|
||||
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getRGBfromCIEXxy.frag").c_str(),
|
||||
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/utils/getCIEXYZ.frag").c_str(),
|
||||
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");
|
||||
AssignUniforms();
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "text"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
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;
|
||||
GLuint DepthOfFieldShader::uniform_tex;
|
||||
GLuint DepthOfFieldShader::uniform_depth;
|
||||
|
@ -523,15 +523,13 @@ public:
|
||||
static void setUniforms(unsigned TU_tex_128, unsigned TU_tex_256, unsigned TU_tex_512);
|
||||
};
|
||||
|
||||
class ToneMapShader
|
||||
class ToneMapShader : public ShaderHelperSingleton<ToneMapShader>
|
||||
{
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_tex, uniform_logluminancetex, uniform_exposure, uniform_lwhite;
|
||||
static GLuint vao;
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(float exposure, float Lwhite, unsigned TU_tex, unsigned TU_logluminance);
|
||||
ToneMapShader();
|
||||
};
|
||||
|
||||
class DepthOfFieldShader
|
||||
|
Loading…
Reference in New Issue
Block a user