diff --git a/data/shaders/transparent.vert b/data/shaders/transparent.vert deleted file mode 100644 index e6c6b13fe..000000000 --- a/data/shaders/transparent.vert +++ /dev/null @@ -1,22 +0,0 @@ -uniform mat4 ModelViewProjectionMatrix; -uniform mat4 TextureMatrix; - -#if __VERSION__ >= 130 -in vec3 Position; -in vec2 Texcoord; -in vec4 Color; -out vec2 uv; -out vec4 color; -#else -attribute vec3 Position; -attribute vec2 Texcoord; -varying vec2 uv; -#endif - - -void main() -{ - uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy; - gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.); - color = Color; -} diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index 1d8bf1eb3..27f04e3de 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -1360,19 +1360,24 @@ namespace MeshShader void TransparentShader::init() { Program = LoadProgram( - GL_VERTEX_SHADER, file_manager->getAsset("shaders/transparent.vert").c_str(), + GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparent.frag").c_str()); attrib_position = glGetAttribLocation(Program, "Position"); attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); attrib_color = glGetAttribLocation(Program, "Color"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_MVP = glGetUniformLocation(Program, "ModelMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); uniform_tex = glGetUniformLocation(Program, "tex"); + if (!UserConfigParams::m_ubo_disabled) + { + GLuint uniform_ViewProjectionMatrixesUBO = glGetUniformBlockIndex(Program, "MatrixesData"); + glUniformBlockBinding(Program, uniform_ViewProjectionMatrixesUBO, 0); + } } - void TransparentShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex) + void TransparentShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex) { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer()); glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer()); glUniform1i(uniform_tex, TU_tex); } @@ -1394,12 +1399,12 @@ namespace MeshShader void TransparentFogShader::init() { Program = LoadProgram( - GL_VERTEX_SHADER, file_manager->getAsset("shaders/transparent.vert").c_str(), + GL_VERTEX_SHADER, file_manager->getAsset("shaders/object_pass.vert").c_str(), GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/transparentfog.frag").c_str()); attrib_position = glGetAttribLocation(Program, "Position"); attrib_texcoord = glGetAttribLocation(Program, "Texcoord"); attrib_color = glGetAttribLocation(Program, "Color"); - uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix"); + uniform_MVP = glGetUniformLocation(Program, "ModelMatrix"); uniform_TM = glGetUniformLocation(Program, "TextureMatrix"); uniform_tex = glGetUniformLocation(Program, "tex"); uniform_fogmax = glGetUniformLocation(Program, "fogmax"); @@ -1415,9 +1420,9 @@ namespace MeshShader } } - void TransparentFogShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex) + void TransparentFogShader::setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex) { - glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer()); + glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelMatrix.pointer()); glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer()); glUniform1f(uniform_fogmax, fogmax); glUniform1f(uniform_startH, startH); diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index e1f3ae6ea..2bbf1eb02 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -288,7 +288,7 @@ public: static GLuint uniform_MVP, uniform_TM, uniform_tex; static void init(); - static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex); + static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, unsigned TU_tex); }; class TransparentFogShader @@ -299,7 +299,7 @@ public: static GLuint uniform_MVP, uniform_TM, uniform_tex, uniform_fogmax, uniform_startH, uniform_endH, uniform_start, uniform_end, uniform_col; static void init(); - static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex); + static void setUniforms(const core::matrix4 &ModelMatrix, const core::matrix4 &TextureMatrix, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex); }; class BillboardShader diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index b4464a46c..cc85017bf 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -230,13 +230,13 @@ void STKAnimatedMesh::render() for_in(mesh, TransparentMesh[TM_DEFAULT]) { TransparentMeshes::MeshSet.push_back(mesh); - TransparentMeshes::MVPSet.push_back(ModelViewProjectionMatrix); + TransparentMeshes::MVPSet.push_back(AbsoluteTransformation); } for_in(mesh, TransparentMesh[TM_ADDITIVE]) { TransparentMeshes::MeshSet.push_back(mesh); - TransparentMeshes::MVPSet.push_back(ModelViewProjectionMatrix); + TransparentMeshes::MVPSet.push_back(AbsoluteTransformation); } return; } diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index 4f97ed8c7..a24ac18be 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -420,13 +420,13 @@ void STKMeshSceneNode::render() for_in(mesh, TransparentMesh[TM_DEFAULT]) { TransparentMeshes::MeshSet.push_back(mesh); - TransparentMeshes::MVPSet.push_back(ModelViewProjectionMatrix); + TransparentMeshes::MVPSet.push_back(AbsoluteTransformation); } for_in(mesh, TransparentMesh[TM_ADDITIVE]) { TransparentMeshes::MeshSet.push_back(mesh); - TransparentMeshes::MVPSet.push_back(ModelViewProjectionMatrix); + TransparentMeshes::MVPSet.push_back(AbsoluteTransformation); } if (!TransparentMesh[TM_BUBBLE].empty())