Try to use vec2 for texture translation only

In stk, only setTextureTranslate is used which modify 8,9 of
matrix array. Also don't update it when it is identity.
This commit is contained in:
Benau 2016-11-28 10:41:27 +08:00
parent 3e938a79be
commit 60908c3e1d
10 changed files with 98 additions and 82 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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<scene::IMeshBuffer*, RenderInfo*> 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);

View File

@ -56,14 +56,14 @@ public:
// ============================================================================
class ObjectRefPass2Shader : public TextureShader<ObjectRefPass2Shader, 5,
core::matrix4, core::matrix4>
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<CRSMShader, 1, core::matrix4, core::matrix4,
class CRSMShader : public TextureShader<CRSMShader, 1, core::matrix4, core::vector2df,
core::matrix4>
{
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<ObjectRefPass1Shader, 2, core::matrix4,
core::matrix4, core::matrix4>
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<ObjectUnlitShader, 4, core::matrix4,
core::matrix4>
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,

View File

@ -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

View File

@ -120,7 +120,7 @@ public:
// ========================================================================
class TransparentShader : public TextureShader<TransparentShader, 1,
core::matrix4, core::matrix4,
core::matrix4, core::vector2df,
float >
{
public:
@ -129,7 +129,7 @@ public:
// ========================================================================
class TransparentFogShader : public TextureShader<TransparentFogShader, 1,
core::matrix4, core::matrix4, float, float,
core::matrix4, core::vector2df, float, float,
float, float, float, video::SColorf >
{
public:
@ -145,7 +145,7 @@ public:
// ========================================================================
class ObjectPass2Shader : public TextureShader < ObjectPass2Shader, 6,
core::matrix4, core::matrix4,
core::matrix4, core::vector2df,
core::vector2df >
{
public:

View File

@ -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];
}
}
}
}

View File

@ -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

View File

@ -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<ListMatDefault, GLMesh *, core::matrix4,
core::matrix4, core::matrix4,
core::matrix4, core::vector2df,
core::vector2df>
{};
// ----------------------------------------------------------------------------
class ListMatAlphaRef : public MeshList<ListMatAlphaRef, GLMesh *, core::matrix4,
core::matrix4, core::matrix4>
core::matrix4, core::vector2df>
{};
// ----------------------------------------------------------------------------
class ListMatNormalMap : public MeshList<ListMatNormalMap, GLMesh *, core::matrix4,
core::matrix4, core::matrix4,
core::matrix4, core::vector2df,
core::vector2df>
{};
@ -135,7 +135,7 @@ class ListMatGrass : public MeshList<ListMatGrass, GLMesh *, core::matrix4,
// ----------------------------------------------------------------------------
class ListMatSphereMap : public MeshList<ListMatSphereMap, GLMesh *,
core::matrix4, core::matrix4,
core::matrix4>
core::vector2df>
{};
// ----------------------------------------------------------------------------
@ -145,12 +145,12 @@ class ListMatSplatting : public MeshList<ListMatSplatting, GLMesh *,
// ----------------------------------------------------------------------------
class ListMatUnlit : public MeshList<ListMatUnlit, GLMesh *, core::matrix4,
core::matrix4, core::matrix4>
core::matrix4, core::vector2df>
{};
// ----------------------------------------------------------------------------
class ListMatDetails : public MeshList<ListMatDetails, GLMesh *, core::matrix4,
core::matrix4, core::matrix4>
core::matrix4, core::vector2df>
{};
// ----------------------------------------------------------------------------
@ -161,38 +161,38 @@ class MiscList : public Singleton<T>, public std::vector<STK::Tuple<Args...> >
// ----------------------------------------------------------------------------
class ListBlendTransparent : public MiscList<ListBlendTransparent, GLMesh *,
core::matrix4, core::matrix4,
core::matrix4, core::vector2df,
float>
{};
// ----------------------------------------------------------------------------
class ListAdditiveTransparent : public MiscList<ListAdditiveTransparent,
GLMesh *, core::matrix4,
core::matrix4, float>
core::vector2df, float>
{};
// ----------------------------------------------------------------------------
class ListTranslucentStandard : public MiscList<ListTranslucentStandard,
GLMesh *, core::matrix4,
core::matrix4, float>
core::vector2df, float>
{};
// ----------------------------------------------------------------------------
class ListTranslucentTangents : public MiscList<ListTranslucentTangents,
GLMesh *, core::matrix4,
core::matrix4, float>
core::vector2df, float>
{};
// ----------------------------------------------------------------------------
class ListTranslucent2TCoords : public MiscList<ListTranslucent2TCoords,
GLMesh *, core::matrix4,
core::matrix4, float>
core::vector2df, float>
{};
// ----------------------------------------------------------------------------
class ListBlendTransparentFog : public MiscList<ListBlendTransparentFog,
GLMesh *, core::matrix4,
core::matrix4, float, float,
core::vector2df, float, float,
float, float, float,
video::SColorf>
{};
@ -200,7 +200,7 @@ class ListBlendTransparentFog : public MiscList<ListBlendTransparentFog,
// ----------------------------------------------------------------------------
class ListAdditiveTransparentFog : public MiscList<ListAdditiveTransparentFog,
GLMesh *, core::matrix4,
core::matrix4, float, float,
core::vector2df, float, float,
float, float, float,
video::SColorf>
{};

View File

@ -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);