Fix Sara's moving textures.
This commit is contained in:
parent
9941b18d7f
commit
108e82afc2
@ -1,6 +1,7 @@
|
||||
#version 330
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
uniform mat4 TransposeInverseModelView;
|
||||
uniform mat4 TextureMatrix;
|
||||
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
@ -11,6 +12,6 @@ noperspective out vec3 normal;
|
||||
|
||||
void main() {
|
||||
normal = (TransposeInverseModelView * vec4(Normal, 0)).xyz;
|
||||
uv = Texcoord;
|
||||
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
}
|
||||
|
@ -456,6 +456,7 @@ namespace MeshShader
|
||||
GLuint ObjectRimLimitShader::attrib_normal;
|
||||
GLuint ObjectRimLimitShader::uniform_MVP;
|
||||
GLuint ObjectRimLimitShader::uniform_TIMV;
|
||||
GLuint ObjectRimLimitShader::uniform_TM;
|
||||
GLuint ObjectRimLimitShader::uniform_Albedo;
|
||||
GLuint ObjectRimLimitShader::uniform_DiffuseMap;
|
||||
GLuint ObjectRimLimitShader::uniform_SpecularMap;
|
||||
@ -471,6 +472,7 @@ namespace MeshShader
|
||||
attrib_normal = glGetAttribLocation(Program, "Normal");
|
||||
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
|
||||
uniform_TIMV = glGetUniformLocation(Program, "TransposeInverseModelView");
|
||||
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
|
||||
uniform_Albedo = glGetUniformLocation(Program, "Albedo");
|
||||
uniform_DiffuseMap = glGetUniformLocation(Program, "DiffuseMap");
|
||||
uniform_SpecularMap = glGetUniformLocation(Program, "SpecularMap");
|
||||
@ -479,10 +481,11 @@ namespace MeshShader
|
||||
uniform_ambient = glGetUniformLocation(Program, "ambient");
|
||||
}
|
||||
|
||||
void ObjectRimLimitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
||||
void ObjectRimLimitShader::setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO)
|
||||
{
|
||||
glUniformMatrix4fv(uniform_MVP, 1, GL_FALSE, ModelViewProjectionMatrix.pointer());
|
||||
glUniformMatrix4fv(uniform_TIMV, 1, GL_FALSE, TransposeInverseModelView.pointer());
|
||||
glUniformMatrix4fv(uniform_TM, 1, GL_FALSE, TextureMatrix.pointer());
|
||||
glUniform1i(uniform_Albedo, TU_Albedo);
|
||||
glUniform1i(uniform_DiffuseMap, TU_DiffuseMap);
|
||||
glUniform1i(uniform_SpecularMap, TU_SpecularMap);
|
||||
|
@ -75,10 +75,10 @@ class ObjectRimLimitShader
|
||||
public:
|
||||
static GLuint Program;
|
||||
static GLuint attrib_position, attrib_normal, attrib_texcoord;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
||||
static GLuint uniform_MVP, uniform_TIMV, uniform_TM, uniform_Albedo, uniform_DiffuseMap, uniform_SpecularMap, uniform_SSAO, uniform_screen, uniform_ambient;
|
||||
|
||||
static void init();
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
||||
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix, unsigned TU_Albedo, unsigned TU_DiffuseMap, unsigned TU_SpecularMap, unsigned TU_SSAO);
|
||||
};
|
||||
|
||||
class UntexturedObjectShader
|
||||
|
@ -60,7 +60,7 @@ void STKAnimatedMesh::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type)
|
||||
if (type == irr_driver->getShader(ES_OBJECTPASS_REF))
|
||||
drawObjectRefPass2(mesh, ModelViewProjectionMatrix, TextureMatrix);
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
||||
else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
||||
drawObjectUnlit(mesh, ModelViewProjectionMatrix);
|
||||
else if (mesh.textures[1])
|
||||
@ -125,7 +125,6 @@ void STKAnimatedMesh::render()
|
||||
// render original meshes
|
||||
for (u32 i = 0; i<m->getMeshBufferCount(); ++i)
|
||||
{
|
||||
TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
||||
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType);
|
||||
bool transparent = (rnd && rnd->isTransparent());
|
||||
|
||||
@ -134,6 +133,7 @@ void STKAnimatedMesh::render()
|
||||
if (transparent != isTransparentPass)
|
||||
continue;
|
||||
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
||||
TextureMatrix = getMaterial(i).getTextureMatrix(0);
|
||||
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
|
||||
if (RenderFromIdentity)
|
||||
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
|
||||
|
@ -411,7 +411,7 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProj
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
}
|
||||
|
||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView)
|
||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix)
|
||||
{
|
||||
GLenum ptype = mesh.PrimitiveType;
|
||||
GLenum itype = mesh.IndexType;
|
||||
@ -439,7 +439,7 @@ void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
|
||||
}
|
||||
|
||||
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
|
||||
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0, 1, 2, 3);
|
||||
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix, 0, 1, 2, 3);
|
||||
|
||||
glBindVertexArray(mesh.vao_second_pass);
|
||||
glDrawElements(ptype, count, itype, 0);
|
||||
|
@ -44,7 +44,7 @@ void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
|
||||
void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
|
||||
void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
|
||||
void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionMatrix, core::vector3df windDir);
|
||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView);
|
||||
void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TransposeInverseModelView, const core::matrix4 &TextureMatrix);
|
||||
void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatrix);
|
||||
|
||||
// Forward pass (for transparents meshes)
|
||||
|
@ -192,7 +192,7 @@ void STKMeshSceneNode::drawSolid(const GLMesh &mesh, video::E_MATERIAL_TYPE type
|
||||
else if (type == irr_driver->getShader(ES_GRASS) || type == irr_driver->getShader(ES_GRASS_REF))
|
||||
drawGrassPass2(mesh, ModelViewProjectionMatrix, windDir);
|
||||
else if (type == irr_driver->getShader(ES_OBJECTPASS_RIMLIT))
|
||||
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView);
|
||||
drawObjectRimLimit(mesh, ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
|
||||
else if (type == irr_driver->getShader(ES_OBJECT_UNLIT))
|
||||
drawObjectUnlit(mesh, ModelViewProjectionMatrix);
|
||||
else if (mesh.textures[1] && type != irr_driver->getShader(ES_NORMAL_MAP))
|
||||
|
Loading…
Reference in New Issue
Block a user