-1

I have a cube in my world that i am translating by 0.0f, 0.01f, 0.0f every frame however this causes the cube to become very distorted

I am 99% sure that this is an issue with MVP, being how I set it up, multiply the variables or so other factor relating to it. This is how I have set up each variable, The Model matrix is sent to the shader every frame update and the Camera and Projection matrix are sent once when the window loads.

Source: http://pastebin.com/FsY0GS6K

Camera, Projection & Model matrix

m_cube_matrix = Matrix4.Identity;

m_camera = Matrix4.LookAt(new Vector3(2.0f, 2.0f, -1.5f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f));
int _u_camera = GL.GetUniformLocation(m_shader.m_shader_program_id, "uCamera");
GL.UniformMatrix4(_u_camera, false, ref m_camera);

m_projection = Matrix4.CreatePerspectiveFieldOfView(1.5f, 800.0f / 600.0f, 0.1f, 10.0f);
int _u_projection = GL.GetUniformLocation(m_shader.m_shader_program_id, "uProjection");
GL.UniformMatrix4(_u_projection, false, ref m_projection);

Vertex Shader

#version 330

uniform mat4 uModel;
uniform mat4 uCamera;
uniform mat4 uProjection;

in vec3 vPosition; 
in vec3 vNormal;

out vec3 oNormal;
out vec3 oPosition;

void main(void)
{
   gl_Position = uProjection * uCamera * uModel * vec4(vPosition, 1);

   oNormal = normalize(gl_NormalMatrix * vNormal);
   oPosition = vPosition;
}  
dandan78
  • 13,328
  • 13
  • 64
  • 78
Tom Gothorp
  • 93
  • 1
  • 8
  • I answered your question, but you should still edit the question to provide the relevant code parts, and maybe directly inline some some still image from the video. – derhass Nov 18 '15 at 13:34

1 Answers1

0

Your transformation matrix is transposed.

You use the same matrix functions for all of your matrices, but send the m_cube_matrix as transposed to the GL, while you don't do that for all others.

From your code:

GL.UniformMatrix4(_u_model, true, ref m_cube_matrix);
//                          ^^^^ you are transposing your matrix here
derhass
  • 43,833
  • 2
  • 57
  • 78