New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with matrices #687
Comments
Your matrix multiplication order is wrong, scaling goes first, then rotation and at the end translation. I don't think there is an issue with the library. |
Because of how matrices are treated in C# and OpenTK, multiplication order is inverted from what you might expect in C/C++ and GLSL. This is an old artefact in the library, and it's too late to change now, unfortunately. |
@Nihlus This might be a worthwhile MAML remark on the math library methods relating to the aforementioned quirk. Ideally, developers shouldn't have to ask us or dig into the source to figure these things out. |
Hi all
I just created a mini-engine clone from an existing one. I had to change the order everywhere. |
So this issue is actually more complicated than it seems. The issue is with column-major or row-major representation of matrices. The easiest way to get consistent results is to transpose the matrices on upload to glsl, that way the multiplication order is preserved. There are valid resons to use row-major columns (this is what directx does). We are thinking of rethinking the matrix library for opentk 5.0 or 6.0 (whenever there is time to do it), and that one will be a lot more consistent, we hope. |
I'm making a simple 3D game using OpenGL 4. I'm loading an .obj file and rotating it horizontally. However, instead of rotating in place, it rotates around the center of the world(starting position of the camera).
Here's how I create the transformation and view matrices:
Am I doing it right?
Also I use the built in method for the view matrix:
And here is the order in which the matrices are applied in the shader:
projectionMatrix * viewMatrix * transformationMatrix
If you want to take a closer look at the code, I've attached it.
TestOpengl.zip
.
The text was updated successfully, but these errors were encountered: