1

I'm using a Model Matrix alone to transport the model I loaded (a monkey face from Blender) into a vbo from model space to world space. However, the model is incredibly distorted (Stretching to infinity), and I'm baffled as to why this is happening.

This video shows the model rotating constantly around the y-axis as an attempt to display my issue clearly. I am certain that the OBJ model I loaded is valid. A lava texture was bound to the model to make it easier to see.

The video also shows the console displaying the current matrix that I'm sending to my vertex shader. In memory, the matrix is expressed in row-major order, so the following matrix:

|1 0 0 0 |
|0 1 0 0 |
|0 0 1 10|
|0 0 0 1 |

is sent to my vertex shader as the following array of C++ floats:

{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 10, 0, 0, 0, 1}

I believe that I am making a novice error in my mathematics. Is there any obvious error that can be noticed just from seeing the model alone? In my vertex shader (GLSL), I use the following line of code:

gl_Position = mvp * vec4(position, 1.0);

Where 'mvp' is the resultant matrix seen in the video and position contains the position of the current vertex of the model being processed (In model space). I don't understand why these distortions are occurring, could it be an error in another aspect of my program (i.e I'm not showing enough code)?

5
  • Do you use the traspose flag when sending your row-wise matrix? Commented May 31, 2016 at 15:32
  • I do not, I tried doing so and the model became invisible because the value of '10' in my example would be in the fourth row and not the fourth column, which is against OpenGL's order if I remember correctly. Commented May 31, 2016 at 15:34
  • no, it simply means that your data is not within the unit cube in clip space and gets clipped Commented May 31, 2016 at 15:35
  • Now that I think of it, my function which generates a Translation Matrix returns the correct matrix in column-major format, I experimented with transposition many times, although it may still be the error I'm making. Edit: Without a perspective projection, do you know of the default far-clip, in terms of world space? Commented May 31, 2016 at 15:36
  • 1
    I just reduced the float from 10 to 0.5, and shrank the model. It now renders correctly, thank you very much Beyeler! Commented May 31, 2016 at 15:38

1 Answer 1

1

Required transposition of the resultant matrix. Previously did not solve the issue because the position exceeded the default far-clip so the model got clipped.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.