diff --git a/data/shaders/displace.frag b/data/shaders/displace.frag index 748909f82..d76be70a6 100644 --- a/data/shaders/displace.frag +++ b/data/shaders/displace.frag @@ -6,7 +6,6 @@ uniform vec2 dir; uniform vec2 dir2; in vec2 uv; -in vec2 uv_bis; in float camdist; out vec4 FragColor; diff --git a/data/shaders/displace.vert b/data/shaders/displace.vert deleted file mode 100644 index e5acc43b5..000000000 --- a/data/shaders/displace.vert +++ /dev/null @@ -1,22 +0,0 @@ -uniform mat4 ModelMatrix; - -#ifdef Explicit_Attrib_Location_Usable -layout(location = 0) in vec3 Position; -layout(location = 3) in vec2 Texcoord; -layout(location = 4) in vec2 SecondTexcoord; -#else -in vec3 Position; -in vec2 Texcoord; -in vec2 SecondTexcoord; -#endif - -out vec2 uv; -out vec2 uv_bis; -out float camdist; - -void main() { - gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.); - uv = Texcoord; - uv_bis = SecondTexcoord; - camdist = length(ViewMatrix * ModelMatrix * vec4(Position, 1.)); -} diff --git a/data/shaders/object_pass.vert b/data/shaders/object_pass.vert index 124e8c26e..ed9b2838e 100644 --- a/data/shaders/object_pass.vert +++ b/data/shaders/object_pass.vert @@ -41,7 +41,7 @@ out vec3 bitangent; out vec2 uv; out vec2 uv_bis; out vec4 color; - +out float camdist; void main(void) { @@ -56,4 +56,5 @@ void main(void) bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz; uv = vec2(Texcoord.x + texture_trans.x, Texcoord.y + texture_trans.y); uv_bis = SecondTexcoord; + camdist = length(ViewMatrix * ModelMatrix * vec4(Position, 1.)); } diff --git a/src/graphics/geometry_passes.cpp b/src/graphics/geometry_passes.cpp index ae807470b..7100e4319 100644 --- a/src/graphics/geometry_passes.cpp +++ b/src/graphics/geometry_passes.cpp @@ -384,6 +384,7 @@ void AbstractGeometryPasses::renderTransparent(const DrawCalls& draw_calls, mesh.textures[0]->getOpenGLTextureName()); DisplaceShader::getInstance()->use(); DisplaceShader::getInstance()->setUniforms(AbsoluteTransformation, + mesh.texture_trans, core::vector2df(cb->getDirX(), cb->getDirY()), core::vector2df(cb->getDir2X(), cb->getDir2Y())); diff --git a/src/graphics/materials.cpp b/src/graphics/materials.cpp index 681f43b76..e8ed79880 100644 --- a/src/graphics/materials.cpp +++ b/src/graphics/materials.cpp @@ -329,7 +329,7 @@ InstancedRefShadowShader::InstancedRefShadowShader() // ============================================================================ DisplaceMaskShader::DisplaceMaskShader() { - loadProgram(OBJECT, GL_VERTEX_SHADER, "displace.vert", + loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", GL_FRAGMENT_SHADER, "white.frag"); assignUniforms("ModelMatrix"); } // DisplaceMaskShader @@ -337,9 +337,9 @@ DisplaceMaskShader::DisplaceMaskShader() // ============================================================================ DisplaceShader::DisplaceShader() { - loadProgram(OBJECT, GL_VERTEX_SHADER, "displace.vert", + loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", GL_FRAGMENT_SHADER, "displace.frag"); - assignUniforms("ModelMatrix", "dir", "dir2"); + assignUniforms("ModelMatrix", "texture_trans", "dir", "dir2"); assignSamplerNames(0, "displacement_tex", ST_BILINEAR_FILTERED, 1, "color_tex", ST_BILINEAR_FILTERED, 2, "mask_tex", ST_BILINEAR_FILTERED, diff --git a/src/graphics/materials.hpp b/src/graphics/materials.hpp index 8cce5a087..61ce7f847 100644 --- a/src/graphics/materials.hpp +++ b/src/graphics/materials.hpp @@ -212,7 +212,8 @@ public: // ============================================================================ class DisplaceShader : public TextureShader + core::vector2df, core::vector2df, + core::vector2df> { public: DisplaceShader();