diff --git a/data/shaders/lightblend.frag b/data/shaders/lightblend.frag deleted file mode 100644 index 0cd68fe3b..000000000 --- a/data/shaders/lightblend.frag +++ /dev/null @@ -1,21 +0,0 @@ -#version 130 -uniform sampler2D diffuse; -uniform sampler2D specular; -uniform sampler2D ambient_occlusion; -uniform sampler2D specular_map; -uniform vec3 ambient; - -in vec2 uv; -out vec4 FragColor; - -void main() -{ - vec2 texc = uv; - - vec3 diffuse = texture(diffuse, texc).xyz; - vec3 spec = texture(specular, texc).xyz; - float specmap = texture(specular_map, texc).x; - float ao = texture(ambient_occlusion, texc).x; - - FragColor = vec4(diffuse + spec * specmap + ao * ambient, 1.0); -} diff --git a/src/graphics/post_processing.cpp b/src/graphics/post_processing.cpp index e02352216..5ae5fbe95 100644 --- a/src/graphics/post_processing.cpp +++ b/src/graphics/post_processing.cpp @@ -342,57 +342,6 @@ void PostProcessing::renderSunlight() glBindVertexArray(0); } -void PostProcessing::renderLightbBlend(ITexture *diffuse, ITexture *specular, ITexture *ao, ITexture *specmap, bool debug) -{ - const SColorf s = irr_driver->getSceneManager()->getAmbientLight(); - glStencilFunc(GL_EQUAL, 1, ~0); - glEnable(GL_STENCIL_TEST); - glEnable(GL_BLEND); - glBlendEquation(GL_FUNC_ADD); - if (debug) - glBlendFunc(GL_ONE, GL_ZERO); - else - glBlendFunc(GL_DST_COLOR, GL_ZERO); - glDisable(GL_DEPTH_TEST); - - glUseProgram(FullScreenShader::LightBlendShader::Program); - glBindVertexArray(FullScreenShader::LightBlendShader::vao); - - glUniform3f(FullScreenShader::LightBlendShader::uniform_ambient, s.r, s.g, s.b); - - glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, static_cast(diffuse)->getOpenGLTextureName()); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glUniform1i(FullScreenShader::LightBlendShader::uniform_diffuse, 0); - glActiveTexture(GL_TEXTURE1); - glBindTexture(GL_TEXTURE_2D, static_cast(specular)->getOpenGLTextureName()); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glUniform1i(FullScreenShader::LightBlendShader::uniform_specular, 1); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, static_cast(ao)->getOpenGLTextureName()); - glUniform1i(FullScreenShader::LightBlendShader::uniform_ambient_occlusion, 2); - glActiveTexture(GL_TEXTURE3); - if (!UserConfigParams::m_ssao) - { - GLint swizzleMask[] = {GL_ONE, GL_ONE, GL_ONE, GL_ONE}; - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzleMask); - } - glBindTexture(GL_TEXTURE_2D, static_cast(specmap)->getOpenGLTextureName()); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glUniform1i(FullScreenShader::LightBlendShader::uniform_specular_map, 3); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glBindVertexArray(0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glEnable(GL_DEPTH_TEST); - glDisable(GL_BLEND); - glDisable(GL_STENCIL_TEST); -} - void PostProcessing::renderGaussian3Blur(video::ITexture *in, video::ITexture *temprtt, float inv_width, float inv_height) { diff --git a/src/graphics/post_processing.hpp b/src/graphics/post_processing.hpp index c4b90cac2..19c8df915 100644 --- a/src/graphics/post_processing.hpp +++ b/src/graphics/post_processing.hpp @@ -75,8 +75,6 @@ public: /** Generate diffuse and specular map */ void renderPointlight(const std::vector &positions, const std::vector &colors, const std::vector &energy); void renderSunlight(); - /** Blend all light related map */ - void renderLightbBlend(video::ITexture *diffuse, video::ITexture *specular, video::ITexture *ao, video::ITexture *specmap, bool debug); void renderFog(const core::vector3df &campos, const core::matrix4 &ipvmat); void renderSSAO(const core::matrix4 &invprojm, const core::matrix4 &projm); diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index be5d31c3e..90554048a 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -249,7 +249,6 @@ void Shaders::loadShaders() FullScreenShader::Gaussian6HBlurShader::init(); FullScreenShader::Gaussian6VBlurShader::init(); FullScreenShader::GlowShader::init(); - FullScreenShader::LightBlendShader::init(); FullScreenShader::PassThroughShader::init(); FullScreenShader::PointLightShader::init(); FullScreenShader::PPDisplaceShader::init(); @@ -1192,24 +1191,6 @@ namespace FullScreenShader glUniform1i(uniform_dtex, TU_dtex); } - GLuint LightBlendShader::Program; - GLuint LightBlendShader::uniform_diffuse; - GLuint LightBlendShader::uniform_specular; - GLuint LightBlendShader::uniform_ambient_occlusion; - GLuint LightBlendShader::uniform_specular_map; - GLuint LightBlendShader::uniform_ambient; - GLuint LightBlendShader::vao; - void LightBlendShader::init() - { - Program = LoadProgram(file_manager->getAsset("shaders/screenquad.vert").c_str(), file_manager->getAsset("shaders/lightblend.frag").c_str()); - uniform_diffuse = glGetUniformLocation(Program, "diffuse"); - uniform_specular = glGetUniformLocation(Program, "specular"); - uniform_ambient_occlusion = glGetUniformLocation(Program, "ambient_occlusion"); - uniform_specular_map = glGetUniformLocation(Program, "specular_map"); - uniform_ambient = glGetUniformLocation(Program, "ambient"); - vao = createVAO(Program); - } - GLuint Gaussian6HBlurShader::Program; GLuint Gaussian6HBlurShader::uniform_tex; GLuint Gaussian6HBlurShader::uniform_pixel; diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index f2babad85..d277499a9 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -341,16 +341,6 @@ public: static void setUniforms(const core::vector3df &direction, const core::matrix4 &InvProjMatrix, float r, float g, float b, unsigned TU_ntex, unsigned TU_dtex); }; -class LightBlendShader -{ -public: - static GLuint Program; - static GLuint uniform_diffuse, uniform_specular, uniform_ambient_occlusion, uniform_specular_map, uniform_ambient; - static GLuint vao; - - static void init(); -}; - class Gaussian6HBlurShader { public: diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index 6c76cde31..73bfded14 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -222,6 +222,7 @@ void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjecti void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView) { + glDisable(GL_CULL_FACE); GLenum ptype = mesh.PrimitiveType; GLenum itype = mesh.IndexType; size_t count = mesh.IndexCount; @@ -234,6 +235,7 @@ void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProje glBindVertexArray(mesh.vao_first_pass); glDrawElements(ptype, count, itype, 0); + glEnable(GL_CULL_FACE); } static @@ -387,6 +389,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix) { + glDisable(GL_CULL_FACE); GLenum ptype = mesh.PrimitiveType; GLenum itype = mesh.IndexType; size_t count = mesh.IndexCount; @@ -416,6 +419,7 @@ void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjec glBindVertexArray(mesh.vao_second_pass); glDrawElements(ptype, count, itype, 0); + glEnable(GL_CULL_FACE); } void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir)