diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index 5c4d325a4..ae063c734 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -448,6 +448,57 @@ public: } // LinearizeDepthShader }; // LinearizeDepthShader +// ============================================================================ +class GlowShader : public TextureShader < GlowShader, 1 > +{ +public: + GLuint vao; + + GlowShader() + { + loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert", + GL_FRAGMENT_SHADER, "glow.frag"); + assignUniforms(); + + assignSamplerNames(0, "tex", ST_BILINEAR_FILTERED); + vao = createVAO(); + } // GlowShader +}; // GlowShader + +// ============================================================================ +class SSAOShader : public TextureShader +{ +public: + SSAOShader() + { + loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert", + GL_FRAGMENT_SHADER, "utils/decodeNormal.frag", + GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag", + GL_FRAGMENT_SHADER, "ssao.frag"); + + assignUniforms("radius", "k", "sigma"); + assignSamplerNames(0, "dtex", ST_SEMI_TRILINEAR); + } // SSAOShader +}; // SSAOShader + +// ============================================================================ +class MotionBlurShader : public TextureShader +{ +public: + MotionBlurShader() + { + loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert", + GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag", + GL_FRAGMENT_SHADER, "motion_blur.frag"); + assignUniforms("previous_viewproj", "center", "boost_amount", + "mask_radius"); + assignSamplerNames(0, "color_buffer", ST_BILINEAR_CLAMPED_FILTERED, + 1, "dtex", ST_NEAREST_FILTERED); + } // MotionBlurShader +}; // MotionBlurShader + // ============================================================================ PostProcessing::PostProcessing(IVideoDriver* video_driver) @@ -1003,11 +1054,11 @@ void PostProcessing::renderTextureLayer(unsigned tex, unsigned layer) // ---------------------------------------------------------------------------- void PostProcessing::renderGlow(unsigned tex) { - FullScreenShader::GlowShader::getInstance()->use(); - glBindVertexArray(FullScreenShader::GlowShader::getInstance()->vao); + GlowShader::getInstance()->use(); + glBindVertexArray(GlowShader::getInstance()->vao); - FullScreenShader::GlowShader::getInstance()->setTextureUnits(tex); - FullScreenShader::GlowShader::getInstance()->setUniforms(); + GlowShader::getInstance()->setTextureUnits(tex); + GlowShader::getInstance()->setUniforms(); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } // renderGlow @@ -1027,11 +1078,11 @@ void PostProcessing::renderSSAO() irr_driver->getSceneManager()->getActiveCamera()->getFarValue() ); irr_driver->getFBO(FBO_SSAO).Bind(); - FullScreenShader::SSAOShader::getInstance() + SSAOShader::getInstance() ->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_LINEAR_DEPTH)); glGenerateMipmap(GL_TEXTURE_2D); - DrawFullScreenEffect + DrawFullScreenEffect (irr_driver->getSSAORadius(), irr_driver->getSSAOK(), irr_driver->getSSAOSigma() ); } @@ -1064,10 +1115,10 @@ void PostProcessing::renderMotionBlur(unsigned , FrameBuffer &in_fbo, out_fbo.Bind(); glClear(GL_COLOR_BUFFER_BIT); - FullScreenShader::MotionBlurShader::getInstance() + MotionBlurShader::getInstance() ->setTextureUnits(in_fbo.getRTT()[0], irr_driver->getDepthStencilTexture()); - DrawFullScreenEffect + DrawFullScreenEffect (// Todo : use a previousPVMatrix per cam, not global cam->getPreviousPVMatrix(), core::vector2df(0.5, 0.5), diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index e88d7a0f4..1bf4167f2 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -457,29 +457,6 @@ namespace FullScreenShader assignUniforms("direction", "col"); } - GlowShader::GlowShader() - { - loadProgram(OBJECT, - GL_VERTEX_SHADER, "screenquad.vert", - GL_FRAGMENT_SHADER, "glow.frag"); - assignUniforms(); - - assignSamplerNames(0, "tex", ST_BILINEAR_FILTERED); - vao = createVAO(); - } - - SSAOShader::SSAOShader() - { - loadProgram(OBJECT, - GL_VERTEX_SHADER, "screenquad.vert", - GL_FRAGMENT_SHADER, "utils/decodeNormal.frag", - GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag", - GL_FRAGMENT_SHADER, "ssao.frag"); - - assignUniforms("radius", "k", "sigma"); - assignSamplerNames(0, "dtex", ST_SEMI_TRILINEAR); - } - FogShader::FogShader() { loadProgram(OBJECT, @@ -491,17 +468,6 @@ namespace FullScreenShader assignSamplerNames(0, "tex", ST_NEAREST_FILTERED); } - MotionBlurShader::MotionBlurShader() - { - loadProgram(OBJECT, - GL_VERTEX_SHADER, "screenquad.vert", - GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag", - GL_FRAGMENT_SHADER, "motion_blur.frag"); - assignUniforms("previous_viewproj", "center", "boost_amount", "mask_radius"); - assignSamplerNames(0, "color_buffer", ST_BILINEAR_CLAMPED_FILTERED, - 1, "dtex", ST_NEAREST_FILTERED); - } - GodFadeShader::GodFadeShader() { loadProgram(OBJECT, diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 2fed461c8..329bd4929 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -88,32 +88,12 @@ public: SunLightShader(); }; -class GlowShader : public TextureShader -{ -public: - GLuint vao; - - GlowShader(); -}; - -class SSAOShader : public TextureShader -{ -public: - SSAOShader(); -}; - class FogShader : public TextureShader { public: FogShader(); }; -class MotionBlurShader : public TextureShader -{ -public: - MotionBlurShader(); -}; - class GodFadeShader : public TextureShader { public: