Factorize FullScreen shaders invocations.
This commit is contained in:
parent
955e0d3259
commit
292aa0cbc4
@ -1,14 +1,15 @@
|
||||
#if __VERSION__ >= 330
|
||||
layout(location = 0) in vec2 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
in vec2 Position;
|
||||
in vec2 Texcoord;
|
||||
|
||||
#if __VERSION__ >= 130
|
||||
out vec2 uv;
|
||||
#else
|
||||
varying vec2 uv;
|
||||
#endif
|
||||
|
||||
out vec2 uv;
|
||||
|
||||
void main() {
|
||||
uv = Texcoord;
|
||||
gl_Position = vec4(Position, 0., 1.);
|
||||
void main()
|
||||
{
|
||||
uv = Texcoord;
|
||||
gl_Position = vec4(Position, 0., 1.);
|
||||
}
|
||||
|
@ -204,16 +204,20 @@ void PostProcessing::update(float dt)
|
||||
}
|
||||
} // update
|
||||
|
||||
template<typename T,typename... Args>
|
||||
static void DrawFullScreenEffect(Args...args)
|
||||
{
|
||||
glUseProgram(T::getInstance()->Program);
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
T::getInstance()->setUniforms(args...);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
||||
static
|
||||
void renderBloom(GLuint in)
|
||||
{
|
||||
glUseProgram(FullScreenShader::BloomShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::BloomShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::BloomShader::getInstance()->TU_tex, in, GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::BloomShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::BloomShader>();
|
||||
}
|
||||
|
||||
void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSHCoeff, const float *rSHCoeff)
|
||||
@ -224,7 +228,7 @@ void PostProcessing::renderDiffuseEnvMap(const float *bSHCoeff, const float *gSH
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
|
||||
glUseProgram(FullScreenShader::DiffuseEnvMapShader::Program);
|
||||
glBindVertexArray(FullScreenShader::DiffuseEnvMapShader::vao);
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
|
||||
setTexture(0, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
core::matrix4 TVM = irr_driver->getViewMatrix().getTransposed();
|
||||
@ -259,8 +263,6 @@ void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3
|
||||
core::matrix4 InvRHMatrix;
|
||||
RHMatrix.getInverse(InvRHMatrix);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glUseProgram(FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->vao);
|
||||
glActiveTexture(GL_TEXTURE0 + FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->TU_SHR);
|
||||
glBindTexture(GL_TEXTURE_3D, shr);
|
||||
{
|
||||
@ -281,8 +283,7 @@ void PostProcessing::renderGI(const core::matrix4 &RHMatrix, const core::vector3
|
||||
}
|
||||
setTexture(FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->TU_ntex, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::GlobalIlluminationReconstructionShader::getInstance()->setUniforms(RHMatrix, InvRHMatrix, rh_extend);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::GlobalIlluminationReconstructionShader>(RHMatrix, InvRHMatrix, rh_extend);
|
||||
}
|
||||
|
||||
void PostProcessing::renderSunlight()
|
||||
@ -294,13 +295,9 @@ void PostProcessing::renderSunlight()
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
|
||||
glUseProgram(FullScreenShader::SunLightShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::SunLightShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::SunLightShader::getInstance()->TU_ntex, irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), GL_NEAREST, GL_NEAREST);
|
||||
setTexture(FullScreenShader::SunLightShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::SunLightShader::getInstance()->setUniforms(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
DrawFullScreenEffect<FullScreenShader::SunLightShader>(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
}
|
||||
|
||||
void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &sun_ortho_matrix, GLuint depthtex)
|
||||
@ -323,12 +320,7 @@ void PostProcessing::renderShadowedSunlight(const std::vector<core::matrix4> &su
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
|
||||
glTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
|
||||
|
||||
glUseProgram(FullScreenShader::ShadowedSunLightShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::ShadowedSunLightShader::getInstance()->vao);
|
||||
FullScreenShader::ShadowedSunLightShader::getInstance()->setUniforms(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
DrawFullScreenEffect<FullScreenShader::ShadowedSunLightShader>(cb->getPosition(), video::SColorf(cb->getRed(), cb->getGreen(), cb->getBlue()));
|
||||
}
|
||||
|
||||
|
||||
@ -338,26 +330,19 @@ void PostProcessing::renderGaussian3Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
|
||||
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
|
||||
{
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian3VBlurShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3VBlurShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::Gaussian3VBlurShader::getInstance()->TU_tex, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
FullScreenShader::Gaussian3VBlurShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian3VBlurShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
{
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian3HBlurShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian3HBlurShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::Gaussian3HBlurShader::getInstance()->TU_tex, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
FullScreenShader::Gaussian3HBlurShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian3HBlurShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,27 +352,19 @@ void PostProcessing::renderGaussian6Blur(FrameBuffer &in_fbo, FrameBuffer &auxil
|
||||
float inv_width = 1.0f / in_fbo.getWidth(), inv_height = 1.0f / in_fbo.getHeight();
|
||||
{
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian6VBlurShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6VBlurShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::Gaussian6VBlurShader::getInstance()->TU_tex, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
FullScreenShader::Gaussian6VBlurShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian6VBlurShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
{
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian6HBlurShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian6HBlurShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::Gaussian6HBlurShader::getInstance()->TU_tex, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
FullScreenShader::Gaussian6HBlurShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian6HBlurShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,8 +378,6 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
|
||||
#endif
|
||||
{
|
||||
auxiliary.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian17TapHShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian17TapHShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::Gaussian17TapHShader::getInstance()->TU_tex, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
@ -410,9 +385,7 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
|
||||
setTexture(FullScreenShader::Gaussian17TapHShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
FullScreenShader::Gaussian17TapHShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian17TapHShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
#if WIN32
|
||||
else
|
||||
@ -433,8 +406,6 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
|
||||
#endif
|
||||
{
|
||||
in_fbo.Bind();
|
||||
glUseProgram(FullScreenShader::Gaussian17TapVShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::Gaussian17TapVShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::Gaussian17TapVShader::getInstance()->TU_tex, auxiliary.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
@ -442,9 +413,7 @@ void PostProcessing::renderGaussian17TapBlur(FrameBuffer &in_fbo, FrameBuffer &a
|
||||
setTexture(FullScreenShader::Gaussian17TapVShader::getInstance()->TU_depth, irr_driver->getFBO(FBO_LINEAR_DEPTH).getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
FullScreenShader::Gaussian17TapVShader::getInstance()->setUniforms(core::vector2df(inv_width, inv_height));
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::Gaussian17TapVShader>(core::vector2df(inv_width, inv_height));
|
||||
}
|
||||
#if WIN32
|
||||
else
|
||||
@ -504,22 +473,14 @@ void PostProcessing::renderSSAO()
|
||||
|
||||
// Generate linear depth buffer
|
||||
irr_driver->getFBO(FBO_LINEAR_DEPTH).Bind();
|
||||
glUseProgram(FullScreenShader::LinearizeDepthShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::LinearizeDepthShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::LinearizeDepthShader::getInstance()->TU_tex, irr_driver->getDepthStencilTexture(), GL_LINEAR, GL_LINEAR);
|
||||
FullScreenShader::LinearizeDepthShader::getInstance()->setUniforms(irr_driver->getSceneManager()->getActiveCamera()->getNearValue(), irr_driver->getSceneManager()->getActiveCamera()->getFarValue());
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::LinearizeDepthShader>(irr_driver->getSceneManager()->getActiveCamera()->getNearValue(), irr_driver->getSceneManager()->getActiveCamera()->getFarValue());
|
||||
irr_driver->getFBO(FBO_SSAO).Bind();
|
||||
|
||||
glUseProgram(FullScreenShader::SSAOShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::SSAOShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::SSAOShader::getInstance()->TU_dtex, irr_driver->getRenderTargetTexture(RTT_LINEAR_DEPTH), GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST);
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
|
||||
FullScreenShader::SSAOShader::getInstance()->setUniforms(irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma());
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::SSAOShader>(irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma());
|
||||
}
|
||||
|
||||
void PostProcessing::renderFog()
|
||||
@ -543,16 +504,10 @@ void PostProcessing::renderFog()
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glUseProgram(FullScreenShader::FogShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::FogShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::FogShader::getInstance()->TU_tex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::FogShader::getInstance()->setUniforms(fogmax, startH, endH, start, end, col);
|
||||
DrawFullScreenEffect<FullScreenShader::FogShader>(fogmax, startH, endH, start, end, col);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
@ -578,22 +533,16 @@ void PostProcessing::renderMotionBlur(unsigned cam, FrameBuffer &in_fbo, FrameBu
|
||||
out_fbo.Bind();
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glUseProgram(FullScreenShader::MotionBlurShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::MotionBlurShader::getInstance()->vao);
|
||||
|
||||
setTexture(FullScreenShader::MotionBlurShader::getInstance()->TU_cb, in_fbo.getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
setTexture(FullScreenShader::MotionBlurShader::getInstance()->TU_dtex, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::MotionBlurShader
|
||||
::getInstance()->setUniforms(
|
||||
DrawFullScreenEffect<FullScreenShader::MotionBlurShader>(
|
||||
// Todo : use a previousPVMatrix per cam, not global
|
||||
irr_driver->getPreviousPVMatrix(),
|
||||
cb->getCenter(cam),
|
||||
cb->getBoostTime(0) * 10, // Todo : should be framerate dependent
|
||||
0.15f);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
}
|
||||
|
||||
static void renderGodFade(GLuint tex, const SColor &col)
|
||||
@ -619,24 +568,16 @@ static void renderGodRay(GLuint tex, const core::vector2df &sunpos)
|
||||
static void toneMap(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
fbo.Bind();
|
||||
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);
|
||||
DrawFullScreenEffect<FullScreenShader::ToneMapShader>();
|
||||
}
|
||||
|
||||
static void renderDoF(FrameBuffer &fbo, GLuint rtt)
|
||||
{
|
||||
fbo.Bind();
|
||||
glUseProgram(FullScreenShader::DepthOfFieldShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::DepthOfFieldShader::getInstance()->vao);
|
||||
setTexture(FullScreenShader::DepthOfFieldShader::getInstance()->TU_tex, rtt, GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::DepthOfFieldShader::getInstance()->TU_depth, irr_driver->getDepthStencilTexture(), GL_NEAREST, GL_NEAREST);
|
||||
FullScreenShader::DepthOfFieldShader::getInstance()->setUniforms();
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::DepthOfFieldShader>();
|
||||
}
|
||||
|
||||
void PostProcessing::applyMLAA()
|
||||
@ -815,10 +756,7 @@ FrameBuffer *PostProcessing::render(scene::ICameraSceneNode * const camnode, boo
|
||||
setTexture(FullScreenShader::BloomBlendShader::getInstance()->TU_tex_128, irr_driver->getRenderTargetTexture(RTT_BLOOM_128), GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::BloomBlendShader::getInstance()->TU_tex_256, irr_driver->getRenderTargetTexture(RTT_BLOOM_256), GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::BloomBlendShader::getInstance()->TU_tex_512, irr_driver->getRenderTargetTexture(RTT_BLOOM_512), GL_LINEAR, GL_LINEAR);
|
||||
glUseProgram(FullScreenShader::BloomBlendShader::getInstance()->Program);
|
||||
FullScreenShader::BloomBlendShader::getInstance()->setUniforms();
|
||||
glBindVertexArray(FullScreenShader::BloomBlendShader::getInstance()->vao);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
DrawFullScreenEffect<FullScreenShader::BloomBlendShader>();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
@ -137,7 +137,7 @@ void IrrDriver::renderLights(unsigned pointlightcount)
|
||||
glDisable(GL_BLEND);
|
||||
m_rtts->getRH().Bind();
|
||||
glUseProgram(FullScreenShader::RadianceHintsConstructionShader::getInstance()->Program);
|
||||
glBindVertexArray(FullScreenShader::RadianceHintsConstructionShader::getInstance()->vao);
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
setTexture(FullScreenShader::RadianceHintsConstructionShader::getInstance()->TU_ctex, m_rtts->getRSM().getRTT()[0], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::RadianceHintsConstructionShader::getInstance()->TU_ntex, m_rtts->getRSM().getRTT()[1], GL_LINEAR, GL_LINEAR);
|
||||
setTexture(FullScreenShader::RadianceHintsConstructionShader::getInstance()->TU_dtex, m_rtts->getRSM().getDepthTexture(), GL_LINEAR, GL_LINEAR);
|
||||
|
@ -132,6 +132,8 @@ Shaders::Shaders()
|
||||
|
||||
GLuint quad_vbo, tri_vbo;
|
||||
|
||||
GLuint SharedObject::FullScreenQuadVAO = 0;
|
||||
|
||||
static void initQuadVBO()
|
||||
{
|
||||
const float quad_vertex[] = {
|
||||
@ -154,6 +156,13 @@ static void initQuadVBO()
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tri_vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), tri_vertex, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
glGenVertexArrays(1, &SharedObject::FullScreenQuadVAO);
|
||||
glBindVertexArray(SharedObject::FullScreenQuadVAO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tri_vbo);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0);
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
// It should be possible to merge it with previous one...
|
||||
@ -1514,19 +1523,6 @@ namespace ParticleShader
|
||||
}
|
||||
}
|
||||
|
||||
static GLuint createFullScreenVAO(GLuint Program)
|
||||
{
|
||||
GLuint vao;
|
||||
glGenVertexArrays(1, &vao);
|
||||
glBindVertexArray(vao);
|
||||
GLuint attrib_position = glGetAttribLocation(Program, "Position");
|
||||
glBindBuffer(GL_ARRAY_BUFFER, tri_vbo);
|
||||
glEnableVertexAttribArray(attrib_position);
|
||||
glVertexAttribPointer(attrib_position, 2, GL_FLOAT, GL_FALSE, 2 * sizeof(float), 0);
|
||||
glBindVertexArray(0);
|
||||
return vao;
|
||||
}
|
||||
|
||||
static GLuint createVAO(GLuint Program)
|
||||
{
|
||||
GLuint vao;
|
||||
@ -1554,7 +1550,6 @@ namespace FullScreenShader
|
||||
AssignUniforms();
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
BloomBlendShader::BloomBlendShader()
|
||||
@ -1567,7 +1562,6 @@ namespace FullScreenShader
|
||||
TU_tex_256 = 1;
|
||||
TU_tex_512 = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex_128, "tex_128"), TexUnit(TU_tex_256, "tex_256"), TexUnit(TU_tex_512, "tex_512"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
ToneMapShader::ToneMapShader()
|
||||
@ -1580,7 +1574,6 @@ namespace FullScreenShader
|
||||
AssignUniforms();
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "text"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
DepthOfFieldShader::DepthOfFieldShader()
|
||||
@ -1592,7 +1585,7 @@ namespace FullScreenShader
|
||||
TU_depth = 1;
|
||||
AssignUniforms();
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_depth, "dtex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
@ -1609,7 +1602,6 @@ namespace FullScreenShader
|
||||
TU_dtex = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"));
|
||||
AssignUniforms("direction", "col");
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -1621,7 +1613,6 @@ namespace FullScreenShader
|
||||
GLuint DiffuseEnvMapShader::uniform_greenLmn;
|
||||
GLuint DiffuseEnvMapShader::uniform_redLmn;
|
||||
GLuint DiffuseEnvMapShader::uniform_TVM;
|
||||
GLuint DiffuseEnvMapShader::vao;
|
||||
|
||||
void DiffuseEnvMapShader::init()
|
||||
{
|
||||
@ -1634,7 +1625,6 @@ namespace FullScreenShader
|
||||
uniform_greenLmn = glGetUniformLocation(Program, "greenLmn[0]");
|
||||
uniform_redLmn = glGetUniformLocation(Program, "redLmn[0]");
|
||||
uniform_TVM = glGetUniformLocation(Program, "TransposeViewMatrix");
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
void DiffuseEnvMapShader::setUniforms(const core::matrix4 &TransposeViewMatrix, const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex)
|
||||
@ -1659,7 +1649,6 @@ namespace FullScreenShader
|
||||
TU_shadowtex = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"), TexUnit(TU_shadowtex, "shadowtex"));
|
||||
AssignUniforms("direction", "col");
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -1688,7 +1677,6 @@ namespace FullScreenShader
|
||||
TU_ntex = 1;
|
||||
TU_dtex = 2;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ctex, "ctex"), TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
RHDebug::RHDebug()
|
||||
@ -1720,7 +1708,6 @@ namespace FullScreenShader
|
||||
TU_SHG = 3;
|
||||
TU_SHB = 4;
|
||||
AssignTextureUnit(Program, TexUnit(TU_ntex, "ntex"), TexUnit(TU_dtex, "dtex"), TexUnit(TU_SHR, "SHR"), TexUnit(TU_SHG, "SHG"), TexUnit(TU_SHB, "SHB"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
}
|
||||
@ -1734,7 +1721,6 @@ namespace FullScreenShader
|
||||
TU_tex = 0;
|
||||
TU_depth = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_depth, "depth"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
ComputeGaussian17TapHShader::ComputeGaussian17TapHShader()
|
||||
@ -1760,7 +1746,6 @@ namespace FullScreenShader
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
Gaussian3HBlurShader::Gaussian3HBlurShader()
|
||||
@ -1771,7 +1756,6 @@ namespace FullScreenShader
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
Gaussian17TapVShader::Gaussian17TapVShader()
|
||||
@ -1783,7 +1767,6 @@ namespace FullScreenShader
|
||||
TU_tex = 0;
|
||||
TU_depth = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"), TexUnit(TU_depth, "depth"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
ComputeGaussian17TapVShader::ComputeGaussian17TapVShader()
|
||||
@ -1808,7 +1791,6 @@ namespace FullScreenShader
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
Gaussian3VBlurShader::Gaussian3VBlurShader()
|
||||
@ -1819,7 +1801,6 @@ namespace FullScreenShader
|
||||
AssignUniforms("pixel");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
PassThroughShader::PassThroughShader()
|
||||
@ -1852,7 +1833,6 @@ namespace FullScreenShader
|
||||
AssignUniforms("zn", "zf");
|
||||
TU_tex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "texture"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
GlowShader::GlowShader()
|
||||
@ -1876,7 +1856,6 @@ namespace FullScreenShader
|
||||
TU_dtex = 0;
|
||||
AssignTextureUnit(Program, TexUnit(TU_dtex, "dtex"));
|
||||
AssignUniforms("radius", "k", "sigma");
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -1891,7 +1870,6 @@ namespace FullScreenShader
|
||||
TU_tex = 0;
|
||||
AssignUniforms("fogmax", "startH", "endH", "start", "end", "col");
|
||||
AssignTextureUnit(Program, TexUnit(TU_tex, "tex"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
|
||||
GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData");
|
||||
glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0);
|
||||
@ -1907,7 +1885,6 @@ namespace FullScreenShader
|
||||
TU_cb = 0;
|
||||
TU_dtex = 1;
|
||||
AssignTextureUnit(Program, TexUnit(TU_dtex, "dtex"), TexUnit(TU_cb, "color_buffer"));
|
||||
vao = createFullScreenVAO(Program);
|
||||
}
|
||||
|
||||
GodFadeShader::GodFadeShader()
|
||||
|
@ -33,6 +33,7 @@ public:
|
||||
static GLuint billboardvbo;
|
||||
static GLuint cubevbo, cubeindexes, frustrumvbo, frustrumindexes;
|
||||
static GLuint ViewProjectionMatrixesUBO;
|
||||
static GLuint FullScreenQuadVAO;
|
||||
};
|
||||
|
||||
namespace UtilShader
|
||||
@ -531,7 +532,6 @@ class BloomShader : public ShaderHelperSingleton<BloomShader>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
BloomShader();
|
||||
};
|
||||
@ -540,7 +540,6 @@ class BloomBlendShader : public ShaderHelperSingleton<BloomBlendShader>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex_128, TU_tex_256, TU_tex_512;
|
||||
GLuint vao;
|
||||
|
||||
BloomBlendShader();
|
||||
};
|
||||
@ -549,7 +548,6 @@ class ToneMapShader : public ShaderHelperSingleton<ToneMapShader>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
ToneMapShader();
|
||||
};
|
||||
@ -558,7 +556,6 @@ class DepthOfFieldShader : public ShaderHelperSingleton<DepthOfFieldShader>
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex, TU_depth;
|
||||
GLuint vao;
|
||||
|
||||
DepthOfFieldShader();
|
||||
};
|
||||
@ -567,7 +564,6 @@ class SunLightShader : public ShaderHelperSingleton<SunLightShader, core::vector
|
||||
{
|
||||
public:
|
||||
GLuint TU_ntex, TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
SunLightShader();
|
||||
};
|
||||
@ -577,7 +573,6 @@ class DiffuseEnvMapShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint uniform_ntex, uniform_TVM, uniform_blueLmn, uniform_greenLmn, uniform_redLmn;
|
||||
static GLuint vao;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &TransposeViewMatrix, const float *blueSHCoeff, const float *greenSHCoeff, const float *redSHCoeff, unsigned TU_ntex);
|
||||
@ -587,7 +582,6 @@ class ShadowedSunLightShader : public ShaderHelperSingleton<ShadowedSunLightShad
|
||||
{
|
||||
public:
|
||||
GLuint TU_ntex, TU_dtex, TU_shadowtex;
|
||||
GLuint vao;
|
||||
|
||||
ShadowedSunLightShader();
|
||||
};
|
||||
@ -596,7 +590,6 @@ class RadianceHintsConstructionShader : public ShaderHelperSingleton<RadianceHin
|
||||
{
|
||||
public:
|
||||
GLuint TU_ctex, TU_ntex, TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
RadianceHintsConstructionShader();
|
||||
};
|
||||
@ -613,7 +606,6 @@ class GlobalIlluminationReconstructionShader : public ShaderHelperSingleton<Glob
|
||||
{
|
||||
public:
|
||||
GLuint TU_ntex, TU_dtex, TU_SHR, TU_SHG, TU_SHB, uniform_RHMatrix;
|
||||
GLuint vao;
|
||||
|
||||
GlobalIlluminationReconstructionShader();
|
||||
};
|
||||
@ -622,7 +614,6 @@ class Gaussian17TapHShader : public ShaderHelperSingleton<Gaussian17TapHShader,
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex, TU_depth;
|
||||
GLuint vao;
|
||||
|
||||
Gaussian17TapHShader();
|
||||
};
|
||||
@ -638,7 +629,6 @@ class Gaussian6HBlurShader : public ShaderHelperSingleton<Gaussian6HBlurShader,
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
Gaussian6HBlurShader();
|
||||
};
|
||||
@ -647,7 +637,6 @@ class Gaussian3HBlurShader : public ShaderHelperSingleton<Gaussian3HBlurShader,
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
Gaussian3HBlurShader();
|
||||
};
|
||||
@ -656,7 +645,6 @@ class Gaussian17TapVShader : public ShaderHelperSingleton<Gaussian17TapVShader,
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex, TU_depth;
|
||||
GLuint vao;
|
||||
|
||||
Gaussian17TapVShader();
|
||||
};
|
||||
@ -674,7 +662,6 @@ class Gaussian6VBlurShader : public ShaderHelperSingleton<Gaussian6VBlurShader,
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
Gaussian6VBlurShader();
|
||||
};
|
||||
@ -683,7 +670,6 @@ class Gaussian3VBlurShader : public ShaderHelperSingleton<Gaussian3VBlurShader,
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
Gaussian3VBlurShader();
|
||||
};
|
||||
@ -710,7 +696,6 @@ class LinearizeDepthShader : public ShaderHelperSingleton<LinearizeDepthShader,
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
LinearizeDepthShader();
|
||||
};
|
||||
@ -728,7 +713,6 @@ class SSAOShader : public ShaderHelperSingleton<SSAOShader, float, float, float>
|
||||
{
|
||||
public:
|
||||
GLuint TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
SSAOShader();
|
||||
};
|
||||
@ -737,7 +721,6 @@ class FogShader : public ShaderHelperSingleton<FogShader, float, float, float, f
|
||||
{
|
||||
public:
|
||||
GLuint TU_tex;
|
||||
GLuint vao;
|
||||
|
||||
FogShader();
|
||||
};
|
||||
@ -746,7 +729,6 @@ class MotionBlurShader : public ShaderHelperSingleton<MotionBlurShader, core::ma
|
||||
{
|
||||
public:
|
||||
GLuint TU_cb, TU_dtex;
|
||||
GLuint vao;
|
||||
|
||||
MotionBlurShader();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user