From d64428db34a9555d856442ba8cc734160e2e470e Mon Sep 17 00:00:00 2001 From: hiker Date: Tue, 19 May 2015 23:01:36 +1000 Subject: [PATCH] Moved more shaders, cleaned up unused code and other left-over bits. --- src/graphics/post_processing.cpp | 25 +++++++++++- src/graphics/render_lighting.cpp | 18 ++++++++- src/graphics/shaders.cpp | 67 -------------------------------- src/graphics/shaders.hpp | 17 -------- 4 files changed, 39 insertions(+), 88 deletions(-) diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index 34708d4ca..48eddac25 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -571,6 +571,27 @@ public: } // MLAAGatherSHader }; // MLAAGatherSHader +// ============================================================================ +class SunLightShader : public TextureShader +{ +public: + SunLightShader() + { + loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert", + GL_FRAGMENT_SHADER, "utils/decodeNormal.frag", + GL_FRAGMENT_SHADER, "utils/SpecularBRDF.frag", + GL_FRAGMENT_SHADER, "utils/DiffuseBRDF.frag", + GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag", + GL_FRAGMENT_SHADER, "utils/SunMRP.frag", + GL_FRAGMENT_SHADER, "sunlight.frag"); + + assignSamplerNames(0, "ntex", ST_NEAREST_FILTERED, + 1, "dtex", ST_NEAREST_FILTERED); + assignUniforms("direction", "col"); + } // SunLightShader +}; // SunLightShader + // ============================================================================ PostProcessing::PostProcessing(IVideoDriver* video_driver) @@ -827,10 +848,10 @@ void PostProcessing::renderSunlight(const core::vector3df &direction, glBlendFunc(GL_ONE, GL_ONE); glBlendEquation(GL_FUNC_ADD); - FullScreenShader::SunLightShader::getInstance() + SunLightShader::getInstance() ->setTextureUnits(irr_driver->getRenderTargetTexture(RTT_NORMAL_AND_DEPTH), irr_driver->getDepthStencilTexture()); - DrawFullScreenEffect(direction, col); + DrawFullScreenEffect(direction, col); } // renderSunlight // ---------------------------------------------------------------------------- diff --git a/src/graphics/render_lighting.cpp b/src/graphics/render_lighting.cpp index 49f5ed0da..9397d3c9e 100644 --- a/src/graphics/render_lighting.cpp +++ b/src/graphics/render_lighting.cpp @@ -259,6 +259,20 @@ public: } // NVWorkaroundRadianceHintsConstructionShader }; // NVWorkaroundRadianceHintsConstructionShader +// ============================================================================ +class FogShader : public TextureShader +{ +public: + FogShader() + { + loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert", + GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag", + GL_FRAGMENT_SHADER, "fog.frag"); + assignUniforms("density", "col"); + assignSamplerNames(0, "tex", ST_NEAREST_FILTERED); + } // FogShader +}; // FogShader + // ============================================================================ static void renderPointLights(unsigned count) { @@ -529,9 +543,9 @@ void IrrDriver::renderAmbientScatter() glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_ONE, GL_ONE); - FullScreenShader::FogShader::getInstance() + FogShader::getInstance() ->setTextureUnits(irr_driver->getDepthStencilTexture()); - DrawFullScreenEffect(1.f / (40.f * start), col); + DrawFullScreenEffect(1.f / (40.f * start), col); } // renderAmbientScatter // ---------------------------------------------------------------------------- diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 4ac0eb0dc..fff958c4e 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -344,42 +344,6 @@ void Shaders::check(const int num) } } // check -// ---------------------------------------------------------------------------- -void bypassUBO(GLuint Program) -{ - GLint VM = glGetUniformLocation(Program, "ViewMatrix"); - glUniformMatrix4fv(VM, 1, GL_FALSE, irr_driver->getViewMatrix().pointer()); - GLint PM = glGetUniformLocation(Program, "ProjectionMatrix"); - glUniformMatrix4fv(PM, 1, GL_FALSE, irr_driver->getProjMatrix().pointer()); - GLint IVM = glGetUniformLocation(Program, "InverseViewMatrix"); - glUniformMatrix4fv(IVM, 1, GL_FALSE, irr_driver->getInvViewMatrix().pointer()); - GLint IPM = glGetUniformLocation(Program, "InverseProjectionMatrix"); - glUniformMatrix4fv(IPM, 1, GL_FALSE, irr_driver->getInvProjMatrix().pointer()); - GLint Screen = glGetUniformLocation(Program, "screen"); - glUniform2f(Screen, irr_driver->getCurrentScreenSize().X, irr_driver->getCurrentScreenSize().Y); - GLint bLmn = glGetUniformLocation(Program, "blueLmn[0]"); - glUniform1fv(bLmn, 9, irr_driver->blueSHCoeff); - GLint gLmn = glGetUniformLocation(Program, "greenLmn[0]"); - glUniform1fv(gLmn, 9, irr_driver->greenSHCoeff); - GLint rLmn = glGetUniformLocation(Program, "redLmn[0]"); - glUniform1fv(rLmn, 9, irr_driver->redSHCoeff); - GLint sundir = glGetUniformLocation(Program, "sun_direction"); - glUniform3f(sundir, irr_driver->getSunDirection().X, irr_driver->getSunDirection().Y, irr_driver->getSunDirection().Z); - GLint suncol = glGetUniformLocation(Program, "sun_col"); - glUniform3f(suncol, irr_driver->getSunColor().getRed(), irr_driver->getSunColor().getGreen(), irr_driver->getSunColor().getBlue()); - GLint sunangle = glGetUniformLocation(Program, "sun_angle"); - glUniform1f(sunangle, 0.54f); -} - -namespace UtilShader -{ -} - - -using namespace UtilShader; - - - unsigned getGLSLVersion() { @@ -438,34 +402,3 @@ namespace MeshShader } -namespace FullScreenShader -{ - - SunLightShader::SunLightShader() - { - loadProgram(OBJECT, - GL_VERTEX_SHADER, "screenquad.vert", - GL_FRAGMENT_SHADER, "utils/decodeNormal.frag", - GL_FRAGMENT_SHADER, "utils/SpecularBRDF.frag", - GL_FRAGMENT_SHADER, "utils/DiffuseBRDF.frag", - GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag", - GL_FRAGMENT_SHADER, "utils/SunMRP.frag", - GL_FRAGMENT_SHADER, "sunlight.frag"); - - assignSamplerNames(0, "ntex", ST_NEAREST_FILTERED, - 1, "dtex", ST_NEAREST_FILTERED); - assignUniforms("direction", "col"); - } - - FogShader::FogShader() - { - loadProgram(OBJECT, - GL_VERTEX_SHADER, "screenquad.vert", - GL_FRAGMENT_SHADER, "utils/getPosFromUVDepth.frag", - GL_FRAGMENT_SHADER, "fog.frag"); - - assignUniforms("density", "col"); - assignSamplerNames(0, "tex", ST_NEAREST_FILTERED); - } - -} diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 2653600be..6cd255306 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -78,23 +78,6 @@ static void DrawFullScreenEffect(Args...args) glDrawArrays(GL_TRIANGLES, 0, 3); } -namespace FullScreenShader -{ - - -class SunLightShader : public TextureShader -{ -public: - SunLightShader(); -}; - -class FogShader : public TextureShader -{ -public: - FogShader(); -}; - -} #define FOREACH_SHADER(ACT) \ ACT(ES_NORMAL_MAP) \