diff --git a/data/shaders/object_pass.vert b/data/shaders/object_pass.vert index 62f8c8dcd..17c48e8fb 100644 --- a/data/shaders/object_pass.vert +++ b/data/shaders/object_pass.vert @@ -1,7 +1,7 @@ #ifdef GL_ES uniform mat4 ModelMatrix; uniform mat4 InverseModelMatrix; -uniform mat4 TextureMatrix; +uniform vec2 texture_trans; #else uniform mat4 ModelMatrix = mat4(1., 0., 0., 0., @@ -14,11 +14,7 @@ uniform mat4 InverseModelMatrix = 0., 0., 1., 0., 0., 0., 0., 1.); -uniform mat4 TextureMatrix = - mat4(1., 0., 0., 0., - 0., 1., 0., 0., - 0., 0., 1., 0., - 0., 0., 0., 1.); +uniform vec2 texture_trans = vec2(0., 0.); #endif #if __VERSION__ >= 330 @@ -58,6 +54,10 @@ void main(void) // Keep direction tangent = (ViewMatrix * ModelMatrix * vec4(Tangent, 0.)).xyz; bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz; - uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy; + uv = (mat4(1., 0., 0., 0., + 0., 1., 0., 0., + texture_trans.x, texture_trans.y, 1., 0., + 0., 0., 0., 1.) + * vec4(Texcoord, 1., 1.)).xy; uv_bis = SecondTexcoord; } diff --git a/data/shaders/rsm.vert b/data/shaders/rsm.vert index 68da61338..7419c59c0 100644 --- a/data/shaders/rsm.vert +++ b/data/shaders/rsm.vert @@ -1,11 +1,6 @@ uniform mat4 ModelMatrix; uniform mat4 RSMMatrix; - -uniform mat4 TextureMatrix = - mat4(1., 0., 0., 0., - 0., 1., 0., 0., - 0., 0., 1., 0., - 0., 0., 0., 1.); +uniform vec2 texture_trans = vec2(0., 0.); #if __VERSION__ >= 330 layout(location = 0) in vec3 Position; @@ -33,7 +28,11 @@ void main(void) mat4 TransposeInverseModel = transpose(inverse(ModelMatrix)); gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.); nor = (TransposeInverseModel * vec4(Normal, 0.)).xyz; - uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy; + uv = (mat4(1., 0., 0., 0., + 0., 1., 0., 0., + texture_trans.x, texture_trans.y, 1., 0., + 0., 0., 0., 1.) + * vec4(Texcoord, 1., 1.)).xy; uv_bis = SecondTexcoord; color = Color.zyxw; } diff --git a/src/graphics/draw_calls.cpp b/src/graphics/draw_calls.cpp index c6a52db7d..0a4c561b3 100644 --- a/src/graphics/draw_calls.cpp +++ b/src/graphics/draw_calls.cpp @@ -211,18 +211,18 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node, tmpcol.getBlue() / 255.0f); for (GLMesh *mesh : node->TransparentMesh[TM_DEFAULT]) - pushVector(ListBlendTransparentFog::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, + pushVector(ListBlendTransparentFog::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->texture_trans, fogmax, startH, endH, start, end, col); for (GLMesh *mesh : node->TransparentMesh[TM_ADDITIVE]) - pushVector(ListAdditiveTransparentFog::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, + pushVector(ListAdditiveTransparentFog::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->texture_trans, fogmax, startH, endH, start, end, col); } else { for (GLMesh *mesh : node->TransparentMesh[TM_DEFAULT]) - pushVector(ListBlendTransparent::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, 1.0f); + pushVector(ListBlendTransparent::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->texture_trans, 1.0f); for (GLMesh *mesh : node->TransparentMesh[TM_ADDITIVE]) - pushVector(ListAdditiveTransparent::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, 1.0f); + pushVector(ListAdditiveTransparent::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->texture_trans, 1.0f); } // Use sun color to determine custom alpha for ghost karts @@ -235,11 +235,11 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node, } for (GLMesh *mesh : node->TransparentMesh[TM_TRANSLUCENT_STD]) - pushVector(ListTranslucentStandard::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, custom_alpha); + pushVector(ListTranslucentStandard::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->texture_trans, custom_alpha); for (GLMesh *mesh : node->TransparentMesh[TM_TRANSLUCENT_TAN]) - pushVector(ListTranslucentTangents::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, custom_alpha); + pushVector(ListTranslucentTangents::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->texture_trans, custom_alpha); for (GLMesh *mesh : node->TransparentMesh[TM_TRANSLUCENT_2TC]) - pushVector(ListTranslucent2TCoords::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->TextureMatrix, custom_alpha); + pushVector(ListTranslucent2TCoords::getInstance(), mesh, Node->getAbsoluteTransformation(), mesh->texture_trans, custom_alpha); for (GLMesh *mesh : node->TransparentMesh[TM_DISPLACEMENT]) pushVector(ListDisplacement::getInstance(), mesh, Node->getAbsoluteTransformation()); @@ -257,7 +257,7 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node, m_glow_pass_mesh[mesh->mb].m_scene_nodes.emplace_back(Node); } - if (Mat != Material::SHADERTYPE_SPLATTING && mesh->TextureMatrix.isIdentity()) + if (Mat != Material::SHADERTYPE_SPLATTING && mesh->texture_trans.getLength() == 0.0f) { std::pair meshRenderInfo(mesh->mb, mesh->m_render_info); m_solid_pass_mesh[Mat][meshRenderInfo].m_mesh = mesh; @@ -270,16 +270,16 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node, switch (Mat) { case Material::SHADERTYPE_SOLID: - ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, + ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans, (mesh->m_render_info && mesh->m_material ? core::vector2df(mesh->m_render_info->getHue(), mesh->m_material->getColorizationFactor()) : core::vector2df(0.0f, 0.0f))); break; case Material::SHADERTYPE_ALPHA_TEST: - ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SOLID_UNLIT: - ListMatUnlit::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatUnlit::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SPLATTING: ListMatSplatting::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix); @@ -314,28 +314,28 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node, switch (Mat) { case Material::SHADERTYPE_SOLID: - ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, + ListMatDefault::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans, (mesh->m_render_info && mesh->m_material ? core::vector2df(mesh->m_render_info->getHue(), mesh->m_material->getColorizationFactor()) : core::vector2df(0.0f, 0.0f))); break; case Material::SHADERTYPE_ALPHA_TEST: - ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatAlphaRef::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_NORMAL_MAP: - ListMatNormalMap::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, + ListMatNormalMap::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans, (mesh->m_render_info && mesh->m_material ? core::vector2df(mesh->m_render_info->getHue(), mesh->m_material->getColorizationFactor()) : core::vector2df(0.0f, 0.0f))); break; case Material::SHADERTYPE_DETAIL_MAP: - ListMatDetails::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatDetails::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SOLID_UNLIT: - ListMatUnlit::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatUnlit::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SPHERE_MAP: - ListMatSphereMap::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatSphereMap::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SPLATTING: ListMatSplatting::getInstance()->SolidPass.emplace_back(mesh, ModelMatrix, InvModelMatrix); @@ -382,22 +382,22 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node, switch (Mat) { case Material::SHADERTYPE_SOLID: - ListMatDefault::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, core::vector2df(0.0f, 0.0f)); + ListMatDefault::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans, core::vector2df(0.0f, 0.0f)); break; case Material::SHADERTYPE_ALPHA_TEST: - ListMatAlphaRef::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatAlphaRef::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_NORMAL_MAP: - ListMatNormalMap::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, core::vector2df(0.0f, 0.0f)); + ListMatNormalMap::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans, core::vector2df(0.0f, 0.0f)); break; case Material::SHADERTYPE_DETAIL_MAP: - ListMatDetails::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatDetails::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SOLID_UNLIT: - ListMatUnlit::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatUnlit::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SPHERE_MAP: - ListMatSphereMap::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatSphereMap::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SPLATTING: ListMatSplatting::getInstance()->Shadows[cascade].emplace_back(mesh, ModelMatrix, InvModelMatrix); @@ -453,22 +453,22 @@ void DrawCalls::handleSTKCommon(scene::ISceneNode *Node, switch (Mat) { case Material::SHADERTYPE_SOLID: - ListMatDefault::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, core::vector2df(0.0f, 0.0f)); + ListMatDefault::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans, core::vector2df(0.0f, 0.0f)); break; case Material::SHADERTYPE_ALPHA_TEST: - ListMatAlphaRef::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatAlphaRef::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_NORMAL_MAP: - ListMatNormalMap::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix, core::vector2df(0.0f, 0.0f)); + ListMatNormalMap::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans, core::vector2df(0.0f, 0.0f)); break; case Material::SHADERTYPE_DETAIL_MAP: - ListMatDetails::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatDetails::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SOLID_UNLIT: - ListMatUnlit::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatUnlit::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SPHERE_MAP: - ListMatSphereMap::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->TextureMatrix); + ListMatSphereMap::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix, mesh->texture_trans); break; case Material::SHADERTYPE_SPLATTING: ListMatSplatting::getInstance()->RSM.emplace_back(mesh, ModelMatrix, InvModelMatrix); diff --git a/src/graphics/materials.hpp b/src/graphics/materials.hpp index 9f34a01f2..5d030c0d7 100644 --- a/src/graphics/materials.hpp +++ b/src/graphics/materials.hpp @@ -56,14 +56,14 @@ public: // ============================================================================ class ObjectRefPass2Shader : public TextureShader + core::matrix4, core::vector2df> { public: ObjectRefPass2Shader() { loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", GL_FRAGMENT_SHADER, "objectref_pass2.frag"); - assignUniforms("ModelMatrix", "TextureMatrix"); + assignUniforms("ModelMatrix", "texture_trans"); assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED, 1, "SpecularMap", ST_NEAREST_FILTERED, 2, "SSAO", ST_BILINEAR_FILTERED, @@ -172,7 +172,7 @@ public: }; // InstancedShadowShader // ============================================================================ -class CRSMShader : public TextureShader { public: @@ -181,7 +181,7 @@ public: loadProgram(OBJECT, GL_VERTEX_SHADER, "rsm.vert", GL_FRAGMENT_SHADER, "rsm.frag"); - assignUniforms("ModelMatrix", "TextureMatrix", "RSMMatrix"); + assignUniforms("ModelMatrix", "texture_trans", "RSMMatrix"); assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED); } // CRSMShader }; // CRSMShader @@ -278,14 +278,14 @@ public: // ============================================================================ class ObjectRefPass1Shader : public TextureShader + core::matrix4, core::vector2df> { public: ObjectRefPass1Shader() { loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", GL_FRAGMENT_SHADER, "objectref_pass1.frag"); - assignUniforms("ModelMatrix", "InverseModelMatrix", "TextureMatrix"); + assignUniforms("ModelMatrix", "InverseModelMatrix", "texture_trans"); assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED, 1, "glosstex", ST_TRILINEAR_ANISOTROPIC_FILTERED); } // ObjectRefPass1Shader @@ -324,14 +324,14 @@ public: // ============================================================================ class ObjectUnlitShader : public TextureShader + core::vector2df> { public: ObjectUnlitShader() { loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", GL_FRAGMENT_SHADER, "object_unlit.frag"); - assignUniforms("ModelMatrix", "TextureMatrix"); + assignUniforms("ModelMatrix", "texture_trans"); assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED, 1, "SpecularMap", ST_NEAREST_FILTERED, 2, "SSAO", ST_BILINEAR_FILTERED, diff --git a/src/graphics/shaders.cpp b/src/graphics/shaders.cpp index beab50c00..a531c5cd9 100644 --- a/src/graphics/shaders.cpp +++ b/src/graphics/shaders.cpp @@ -350,7 +350,7 @@ Shaders::ObjectPass2Shader::ObjectPass2Shader() { loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", GL_FRAGMENT_SHADER, "object_pass2.frag"); - assignUniforms("ModelMatrix", "TextureMatrix", "color_change"); + assignUniforms("ModelMatrix", "texture_trans", "color_change"); assignSamplerNames(0, "DiffuseMap", ST_NEAREST_FILTERED, 1, "SpecularMap", ST_NEAREST_FILTERED, 2, "SSAO", ST_BILINEAR_FILTERED, @@ -364,7 +364,7 @@ Shaders::TransparentShader::TransparentShader() { loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", GL_FRAGMENT_SHADER, "transparent.frag"); - assignUniforms("ModelMatrix", "TextureMatrix", "custom_alpha"); + assignUniforms("ModelMatrix", "texture_trans", "custom_alpha"); assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED); } // TransparentShader @@ -373,7 +373,7 @@ Shaders::TransparentFogShader::TransparentFogShader() { loadProgram(OBJECT, GL_VERTEX_SHADER, "object_pass.vert", GL_FRAGMENT_SHADER, "transparentfog.frag"); - assignUniforms("ModelMatrix", "TextureMatrix", "fogmax", "startH", + assignUniforms("ModelMatrix", "texture_trans", "fogmax", "startH", "endH", "start", "end", "col"); assignSamplerNames(0, "tex", ST_TRILINEAR_ANISOTROPIC_FILTERED); } // TransparentFogShader diff --git a/src/graphics/shaders.hpp b/src/graphics/shaders.hpp index 242d602db..33a0094c2 100644 --- a/src/graphics/shaders.hpp +++ b/src/graphics/shaders.hpp @@ -120,7 +120,7 @@ public: // ======================================================================== class TransparentShader : public TextureShader { public: @@ -129,7 +129,7 @@ public: // ======================================================================== class TransparentFogShader : public TextureShader { public: @@ -145,7 +145,7 @@ public: // ======================================================================== class ObjectPass2Shader : public TextureShader < ObjectPass2Shader, 6, - core::matrix4, core::matrix4, + core::matrix4, core::vector2df, core::vector2df > { public: diff --git a/src/graphics/stk_animated_mesh.cpp b/src/graphics/stk_animated_mesh.cpp index 1697acf18..d51bd8698 100644 --- a/src/graphics/stk_animated_mesh.cpp +++ b/src/graphics/stk_animated_mesh.cpp @@ -186,10 +186,18 @@ void STKAnimatedMesh::updateNoGL() for (u32 i = 0; i < m->getMeshBufferCount(); ++i) { scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); - if (!mb) - continue; - if (mb) - GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0); + if (mb != NULL) + { + // Test if texture matrix needs to be updated every frame + const core::matrix4& mat = getMaterial(i).getTextureMatrix(0); + if (mat.isIdentity()) + continue; + else + { + GLmeshes[i].texture_trans.X = mat[8]; + GLmeshes[i].texture_trans.Y = mat[9]; + } + } } } diff --git a/src/graphics/stk_mesh.cpp b/src/graphics/stk_mesh.cpp index 35dd33fa9..2f0a1ecbe 100644 --- a/src/graphics/stk_mesh.cpp +++ b/src/graphics/stk_mesh.cpp @@ -233,7 +233,7 @@ GLMesh allocateMeshBuffer(scene::IMeshBuffer* mb, const std::string& debug_name, } for (unsigned i = 0; i < 8; i++) result.textures[i] = mb->getMaterial().getTexture(i); - result.TextureMatrix = 0; + result.texture_trans = core::vector2df(0.0f, 0.0f); result.VAOType = mb->getVertexType(); return result; } // allocateMeshBuffer diff --git a/src/graphics/stk_mesh.hpp b/src/graphics/stk_mesh.hpp index 5d72f6b0b..857accfe4 100644 --- a/src/graphics/stk_mesh.hpp +++ b/src/graphics/stk_mesh.hpp @@ -53,7 +53,7 @@ struct GLMesh GLenum IndexType; size_t IndexCount; size_t Stride; - core::matrix4 TextureMatrix; + core::vector2df texture_trans; size_t vaoBaseVertex; size_t vaoOffset; video::E_VERTEX_TYPE VAOType; @@ -112,18 +112,18 @@ public: // ---------------------------------------------------------------------------- class ListMatDefault : public MeshList {}; // ---------------------------------------------------------------------------- class ListMatAlphaRef : public MeshList + core::matrix4, core::vector2df> {}; // ---------------------------------------------------------------------------- class ListMatNormalMap : public MeshList {}; @@ -135,7 +135,7 @@ class ListMatGrass : public MeshList + core::vector2df> {}; // ---------------------------------------------------------------------------- @@ -145,12 +145,12 @@ class ListMatSplatting : public MeshList + core::matrix4, core::vector2df> {}; // ---------------------------------------------------------------------------- class ListMatDetails : public MeshList + core::matrix4, core::vector2df> {}; // ---------------------------------------------------------------------------- @@ -161,38 +161,38 @@ class MiscList : public Singleton, public std::vector > // ---------------------------------------------------------------------------- class ListBlendTransparent : public MiscList {}; // ---------------------------------------------------------------------------- class ListAdditiveTransparent : public MiscList + core::vector2df, float> {}; // ---------------------------------------------------------------------------- class ListTranslucentStandard : public MiscList + core::vector2df, float> {}; // ---------------------------------------------------------------------------- class ListTranslucentTangents : public MiscList + core::vector2df, float> {}; // ---------------------------------------------------------------------------- class ListTranslucent2TCoords : public MiscList + core::vector2df, float> {}; // ---------------------------------------------------------------------------- class ListBlendTransparentFog : public MiscList {}; @@ -200,7 +200,7 @@ class ListBlendTransparentFog : public MiscList {}; diff --git a/src/graphics/stk_mesh_scene_node.cpp b/src/graphics/stk_mesh_scene_node.cpp index 718b01c36..d09f3e3ee 100644 --- a/src/graphics/stk_mesh_scene_node.cpp +++ b/src/graphics/stk_mesh_scene_node.cpp @@ -238,9 +238,18 @@ void STKMeshSceneNode::updateNoGL() for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i) { scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i); - if (!mb) - continue; - GLmeshes[i].TextureMatrix = getMaterial(i).getTextureMatrix(0); + if (mb != NULL) + { + // Test if texture matrix needs to be updated every frame + const core::matrix4& mat = getMaterial(i).getTextureMatrix(0); + if (mat.isIdentity()) + continue; + else + { + GLmeshes[i].texture_trans.X = mat[8]; + GLmeshes[i].texture_trans.Y = mat[9]; + } + } } } @@ -449,7 +458,7 @@ void STKMeshSceneNode::render() getTextureGLuint(mesh.textures[1]), getTextureGLuint(mesh.textures[7])); Shaders::ObjectPass2Shader::getInstance()->setUniforms(AbsoluteTransformation, - mesh.TextureMatrix, + mesh.texture_trans, core::vector2df(0.0f, 0.0f)); assert(mesh.vao); glBindVertexArray(mesh.vao); @@ -534,7 +543,7 @@ void STKMeshSceneNode::render() ->setTextureUnits(getTextureGLuint(mesh.textures[0])); } Shaders::TransparentFogShader::getInstance() - ->setUniforms(AbsoluteTransformation, mesh.TextureMatrix, + ->setUniforms(AbsoluteTransformation, mesh.texture_trans, fogmax, startH, endH, start, end, col); assert(mesh.vao); @@ -570,7 +579,7 @@ void STKMeshSceneNode::render() #endif Shaders::TransparentShader::getInstance()->setTextureUnits(getTextureGLuint(mesh.textures[0])); - Shaders::TransparentShader::getInstance()->setUniforms(AbsoluteTransformation, mesh.TextureMatrix, 1.0f); + Shaders::TransparentShader::getInstance()->setUniforms(AbsoluteTransformation, mesh.texture_trans, 1.0f); assert(mesh.vao); glBindVertexArray(mesh.vao); glDrawElements(ptype, count, itype, 0);