Model View Projection Matrices in OpenGL

preview_player
Показать описание


Thank you to the following Patreon supporters:
- Dominic Pace
- Kevin Gregory Agwaze
- Sébastien Bervoets
- Tobias Humig
- Peter Siegmund
- Kerem Demirer

Gear I use:
-----------------

Рекомендации по теме
Комментарии
Автор

So, basically:
*Model matrix:* defines position, rotation and scale of the vertices of the model in the world.
*View matrix:* defines position and orientation of the "camera".
*Projection matrix:* Maps what the "camera" sees to NDC, taking care of aspect ratio and perspective.

fendoroid
Автор

After 6 years this guy is still making sure I learn OpenGL

aniselezovic
Автор

you da real mvp for making these videos, thanks!

halemm
Автор

Tip about cameras for anyone, You can do regular transformations on a "Camera" object as you would your model. Right before its time to render your scene, you can calc the transformation matrix(trans, scale, rotate) for the camera as you would a model, BUT take the extra step of doing an inverse operation on the matrix, which flips everything for you, left goes right, rotate up goes rotat down, etc. Its good to keep both Matrices around because you need the Original for Mouse Ray casting and you can can pull the Right, Top, Forward Direction vectors straight out of the matrix as each column (or is it row) is a the world direction that your facing. Important information for First Person Movement.

Side note, setting up a Uniform Buffer Object (UBO), you can upload some of that data once and have it accessible in all your shaders. Makes things easier then pushing Projection and View matrices to every shader. There is other good bit of data to pass to a UBO, camera position for lighting calcs, a time value for animations, screen width and height for some effects, to name a few.

The best part of the video is when Cherno said "Its hard to teach opengl"... Boy I can sympathize with that, a pain to explain abstract concepts sometimes.

SketchpunkLabs
Автор

15:35
Roses are red
Violets are blue
Your camera is way too far away from you

miteshsharma
Автор

For real, you are my hero. This content is absolute gold. I'm taking an online course on edX, and it is(to a BONKERS degree) absent the requisite information to do its own homework... You are really making these concepts more palatable for someone learning the ropes. Thanks so much!

AlbertTackie
Автор

dude you just opened my eyes. thanks. I cant really believe that what you explained in this and the last video are what make the whole thing come together. Thank you .And the probable reason why nobody thought you this way is that they never understood it properly in the first place. I came to your videos for a college opengl project and im definitely interested now. Thank you so much.

befikerbiresaw
Автор

Omfg I hate acronyms.
I thought this video was going to be on minimum viable Product but I guess you're the most valuable player in teaching me about model view projection.

GmanGavin
Автор

I just learned it in 2020. I don't know what I did 2 years ago. thanks the cherno.

muhammadmauludinanwar
Автор

I took this as more depth explanation for what is going on in sparky engine. I like the way you explain things. Thank you for the video :)

AxElKo
Автор

I think i have a good example which makes it a bit clearer, what the model matrix is good for. Usually, you define the vertices with the center being at 0, 0, 0 and the coordinates being normalized, this means ranging from 1 to -1. Then you can draw different models at different positions, with different sizes and rotations, but with the same vertex buffer by just changing the model matrix. It is more efficient to multiply the vertices by the matrix in the vertex shader than to change the vertices on cpu side.

JakobRobert
Автор

guys, i had my m*v*p backwards (p * v * m), and couldn't figure out why my math was being weird for DAYS, order MATTERS A TON with matrix multiplication people!!!

Pation
Автор

영어공부 + OpenGL 공부 일석이조군.
Kill two birds with one stone . English + OpenGL.. Also your explanation, makes my head clear of concept of matrics that I 've been ambiguous for a long time, thanks Cherno.

minseokjeong
Автор

If anyone has trouble understand why Model, View and Projection matrices in OpenGL are multiplied in reverse order, consider this:

1. model vertex "v" is multiplied by Model matrix first: v1 = M * v
2. result of previous step is multiplied by View matrix: v2 = V * v1 = V * (M * v)
3. like before, result is multiplied by Projection matrix: v3 = P * v2 = P * (V * (M * v))

we can rearrange parenthesis and concatenate 3 matrices into one: v3 = (P * V * M) * v = MVP * v

MVP = P * V * M

hope this explain why matrices are multiplied in reverse :)

wojciechjaworski
Автор

I like your videos gives good basic idea about the basic constructs of opengl and really look forward for more videos where you get deep in these topics.

vikaskorjani
Автор

You did great job with explaining MVP, I've seen few tutorials about this, but yours is the simplest one! Keep it going!

MK-uomm
Автор

thank you for the series
how can we add zooming (just add a scale !?)
how can we select an object by mouse (click or window selection)
thanks again

engsayed
Автор

If you are not able to see the transformation remember to replace the proj with mvp in the SetUniformMat4f
That was my issue also.

gamelovers
Автор

don' really get why the order of multiplication of mvp should depend on whether row major or col major storage is used, what's just internal storage and should change the result of multiplying matrices

andersr
Автор

I don't understand. Isn't moving the camera to x = -100 moving it to the left? Yet the object did move to the left. It should've moved to the right closer to the center of the window. Unless the camera is at like -480 (half of 960 which is our windows width)

MrStarTraveler