GRAPHICS: Transpose view/model matrices correctly

This commit is contained in:
Dries Harnie 2014-01-22 00:32:11 +01:00
parent f618b90d31
commit 6c8a35e53b
2 changed files with 8 additions and 4 deletions

View file

@ -386,6 +386,7 @@ void GfxOpenGLS::positionCamera(const Math::Vector3d &pos, const Math::Vector3d
Math::Matrix4 lookMatrix = makeLookMatrix(pos, interest, up_vec);
_viewMatrix = viewMatrix * lookMatrix;
_viewMatrix.transpose();
}
}
@ -440,6 +441,7 @@ void GfxOpenGLS::startActorDraw(const Actor *actor) {
modelMatrix.transpose();
modelMatrix.setPosition(pos);
modelMatrix.transpose();
_mvpMatrix = _viewMatrix * modelMatrix;
_mvpMatrix.transpose();
@ -536,7 +538,7 @@ void GfxOpenGLS::drawShadowPlanes() {
const ShadowUserData *sud = (ShadowUserData *)_currentShadowArray->userData;
_shadowPlaneProgram->use();
_shadowPlaneProgram->setUniform("projMatrix", _projMatrix);
_shadowPlaneProgram->setUniform("viewMatrix", viewMatrix);
_shadowPlaneProgram->setUniform("viewMatrix", _viewMatrix);
glBindBuffer(GL_ARRAY_BUFFER, sud->_verticesVBO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, sud->_indicesVBO);

View file

@ -12,9 +12,10 @@ in vec2 texcoord;
in vec4 color;
in vec3 normal;
uniform highp mat4 modelMatrix;
uniform highp mat4 viewMatrix;
uniform highp mat4 projMatrix;
uniform highp mat4 extraMatrix;
uniform highp mat4 mvpMatrix;
uniform highp vec2 texScale;
uniform bool textured;
uniform light lights[maxLights];
@ -26,11 +27,12 @@ out vec4 Color;
void main()
{
vec4 pos = vec4(position, 1.0);
pos = mvpMatrix *
pos = modelMatrix *
extraMatrix *
pos;
gl_Position = projMatrix * pos;
gl_Position = projMatrix * viewMatrix * pos;
if (textured) {
Texcoord = vec2(0.0, 1.0) + (texcoord / texScale);