For those of you who have been following the vulkan tutorial series, this video is a slight departure from the normal format. The coding portion for the tutorial will be released separately as soon as I’m finished. Future tutorials will return to the more typical structure, with code and theory interleaved. Enjoy!
I cannot agree more, even though I had studied it before I had forgotten so many details and was struggling to find the derivation. In most books they just magically give you the projection matrix solution and give you two phrases, so hard to get it go from the basic n*(x/z) etc to the final form.
I remember, when first learning programming I tried to get (any level of) 3D rendering to work, and discovering the math of perspective transformation (e.g. x1/z1 = x2/z2, thus x(screen) = x(world) * (z1 / z2) ) was a critical breakthrough. Even if the only thing I could actually code with it was an imitation of the "starfield" Windows screen saver.
Currently doing this with Java, this video is great, especially since all these terms are pretty fresh for me since I’m just finishing up my linear algebra class
After watching 3blue1browns "Essence of Linear Algebra" Playlist, taking the linear algebra module in my university AND watching this video I was finally able to implement these concepts all while deriving the used methods by myself too. Thanks for this awesome video
This is very very very good. I’ve seen too many people code in opengl etc without really understanding what is going on. Sure it works, but this intuition as to what these matrices are doing is good
Thank you for this video!! I don’t code much, but I love art and math and was so curious on the math behind game engines / 3d graphics and wanted to see how close or far off my guesses were. this makes me want to code!
Another master piece of 3d explanation. I really never understood well the black magic of the perspective matrix. It was in somehow just diving by z. Yet, your explanation is so clean and so perfect. It makes it really easy to understand. Please post more tutorials like these. You should definitely write a book about it too.
This, along with Cem Yuksel's 3D Transformation video really explains the subject well. I've reviewed this subject multiple times throughout the years but I gotta say, this 2-step approach (perspective projection = perspective transformation + orthographic projection) is IMHO the most intuitive and easy to remember way of teaching/studying this subject. Most books/resources tend to focus on deriving the perspective projection matrix from the ground up, often times skipping the inherent connection to orthographic projection. Thank you for a job well done. Cheers!
do u mind asking is this the concept of converting 3d images to 2d images that appear on our displays(i just started learning about this subject for a school project)
My friends, search for your life purpose, why are we here?? I advise you to watch this series and this video 👇 as a beginning to know the purpose of your existence in this life th-cam.com/play/PLPqH38Ki1fy3EB-8xmShVqpbQw99Do2B-.html th-cam.com/video/7d16CpWp-ok/w-d-xo.html
Found this, Great explanation this topic was killing me, I was not able to understand it before where they get the values and a visual representation of it. You have everything. Great job!
I’m working on a career change right now, going back to school in the near future for an MS in CS with hopes to be a graphics engineer. I’m reviewing all the prerequisite math right now so having an understanding of what kind of math I’ll need to learn in the future is very helpful. Even though I didn’t really understand 95% of this it was still a great video 😁
Just a question, do you have relevant CS or math experience? Because just going "I want to program 3d space vectors" is not something the average Joe just gets up and does?
@@codejunki567 no I don’t, that’s why I’m going back and taking all the prerequisites before doing the grad program. I have to do calc 1, 2, linear algebra, physics, C++ programming, etc. I’ve done a lot of Python, R and SQL but that’s not really relevant. Believe me, I understand how difficult is and how much I have left to learn. I probably won’t be able to start the grad program for another year and half or so.
@@stef8776honestly if it's something you're interested in it's not very difficult. I think people who complete certain qualification programs try to oversell it's difficulty. As a complete average Joe myself I haven't really had problems with the maths side of 3d graphics. It's actually helped me improve my intuitive understanding of certain concepts. If you enjoy the work, you'll be thinking about it enthusiastically when you're out and about, going on a walk, doing whatever. When things are on your mind out of pure intrigue, you are probably in the right field and will definitely succeed.
I have exactly no background in computer graphics, only linear algebra. Your video is masterful in its explanation. I find the tempo of your speech helps alot!
Even though I thought I had already understood this before I watched, I still learn something from it. Thanks for making this video, I think it's the clearest one about how to get the Perspective Projection
This video on its own is incredible, educational, and just all around superb. I learned so much and tied together so many loose ends I had dangling in my brain because of this video. Thank you.
Ya Ive gotten some good feedback that maybe I went a little fast 😅 but really glad you were able to get it! This has definitely been the hardest video for me to make so far
I don't know why, but every explanation online of how and why the z order is preserved ends up in a shady and not very explanatory way. At 10:35 you literally made me get it instantly! thank you for this great content, keep it up brother!
Thanks again for continuing the series! I have something important (potentially) to add about future 3D animations: the cube demo ran poorly for me, low framerate, creating an ugly jitter. Unusual, since my hardware is fairly fast. Fixed it by disabling the "apidump" layer I had defined in the "VK_INSTANCE_LAYERS" system environment variable. However, this made my framerate skyrocket to above 3000 FPS, making the spinning cube become an imperceivable blur. Your demo implementation is framerate dependent, I have since created a lightweight way to measure timing (delta) and adjust the speed of animations to any system. Just thought I should remind you of this just in case. I can provide my implementation if you'd like to use it. Edit: having apidump enabled will not only slow you down, but also spam the console on every api call. Hope it helps. Sorry for the long post!
Ya this is something I should have mentioned. The easiest way to limit frame rate for now is update the chooseSwapPresentMode function in the swapchain by commenting out the mailbox present mode, and using FIFO (vsync). Your solution is the ultimately correct one, where the game loop needs some timing mechanism. We'll cover the different methods of game loop timing pretty soon.
Thank you very much for making this quality tutorial series, I've been following along slowly for some time and really appreciate the detail and clarity. I will say that, for me personally, the videos which focus more on the mathematical background are less useful, but I may not be representative of the audience; just thought the feedback could be useful. Looking forward to more lessons!
Thank you! And I appreciate the feedback. It's good to know what's working for some people and what isn't. Well, some good news then is this is the most math heavy video for the foreseeable future. Tutorial 14 will have just a bit more and then it's predominantly coding after that point.
@@BrendanGalea Might wanna do a poll, I enjoyed this video! Helps me understand why I put in a matrix, without blindly copy-pasta-ing it :) I personally prefer both!
My friends, search for your life purpose, why are we here?? I advise you to watch this series and this video 👇 as a beginning to know the purpose of your existence in this life th-cam.com/play/PLPqH38Ki1fy3EB-8xmShVqpbQw99Do2B-.html th-cam.com/video/7d16CpWp-ok/w-d-xo.html
homogeneous coordinates swooping in lmao. Great video! I've been meaning to understand this better for about a year now and finally searched it up and I'm thrilled to have found this, perfect for my level.
Hahaha ya exactly. The main problem is that you rarely get useful error messages as feedback. Things will just look wrong. My first school project working on projection matrices I was passing in the matrix in row major order and didn’t realize OpenGL wanted column major… took me hours to figure that one out
@@BrendanGalea any tips for getting my brain to actually work with all these different orderings? It's 99% of what i spend my time debugging in my brain
My friends, search for your life purpose, why are we here?? I advise you to watch this series and this video 👇 as a beginning to know the purpose of your existence in this life th-cam.com/play/PLPqH38Ki1fy3EB-8xmShVqpbQw99Do2B-.html th-cam.com/video/7d16CpWp-ok/w-d-xo.html
My friends, search for your life purpose, why are we here?? I advise you to watch this series and this video 👇 as a beginning to know the purpose of your existence in this life.. th-cam.com/play/PLPqH38Ki1fy3EB-8xmShVqpbQw99Do2B-.html th-cam.com/video/7d16CpWp-ok/w-d-xo.html
I have been searching for a clear explanation of NDC system and the projective transformation. This is such a good video with illustrations that explain the concepts beautifully!
This is actually a general derivation that holds for a skewed view frustrum. The picture shows a regular frustrum. Skewed frustra you need when you want to make a huge picture so that you have to chop up the initial regular frustrum.
Good explanation of the frustrum matrix... but I can imagine total newbies would not take much out of it, unless you show them some code and what effects can be achieved with manipulating the frustrum parameters. One thing which tripped me up is what are n and f values and how they are chooses... but this is probably just me not paying attention.
Ya the drawing isn't exactly clear since I triedtilting things slightly of axis to be more visible. Making 3D drawings isn't easy for me lol +z should point into the screen. So starting from your nose to the screen in front would be the direction. And the -z points from the screen to the viewer
If you use the right-hand rule with X pointing to the right and Y pointing up, positive Z goes into the screen and -Z goes out. If that matches up, it is right-handed. Otherwise it is left.
sorry about the slow response, i missed seeing this. I should have explained this here. A scale matrix consists of 3 value that all are on the main diagonal. The [0][0] value says how much to stretch the x component, [1][1] the y component, and [2[2[] the z component. So in this case we have 2 as the numerator because we want the result to be -1 to +1 for the x and y components (+1 - (-1) = 2). The z component we want to be 0 to 1, so [2][2] has 1 as the numerator. The denominator is sx, sy, sz (the current dimensions of the box that we want to map to the canonical) because by dividing by the current box dimensions you get 1. So for example a box that has a width sx = 5, applying (1/sx), means 5 * (1/sx) = 5 * (1/5) = 1. Then the numerator of 2 doubles the size from 1 to 2, hence we get a box centered at 0, with the x component ranging from -1 to 1, which is what we want for vulkan. And same idea applies for caluclating the y and z components.
Great! I think I'll not watch it though; I've been for a few years just figuring this out mostly on my own, I don't really want to spoil anything for myself! I think I've figured out UV mapping or at least something akin to it, I figured that if you know which triangle a point is being projected from, then you can change the central point, in other words shift every 3d object's coordinates aside from Z position and reproject the point again, if you do this twice making sure that you're projecting to central positions such that the orthographic projection of the de-projected 3d point can't be on a line from the two 2d projected points, then you can now draw a line from the two projected positions to the point that was their central position, find the line intersection and you'll now have the X and Y coordinates of the de-projected point, all that's left is to simply figure the Z coordinate based on X and Y coordinates.
Huh, that triangle stuff at 5:55 doesn't look right. Surely the big triangle has adjacent side of length n+z and not z? Otherwise it would be some other shape
In minute 6:04 you are describing that the sidelines of a triangle are proportional, but you are writing that y_s / n = y / z, when it should be y_s / n = y / (z + n) because the length of the bottom segment is z + n, and not only z, based con the viewer's angle. Wouldn't the calculations change a bit with this in mind?
The z in the diagram is meant to refer to the entire length of the bottom side of the orange triangle (6:02), not just the bit occurring past the near plane. But I can see how that’s confusing based on what I’ve drawn!
This is almost the perfect derivation of perspective projection (especially since it includes both the off-axis and FOV versions!). However, I wish you would have talked more about why applying the first perspective transform gets us into a space that allows for trivially transforming with the orthographic projection matrix. It doesn't seem intuitive to me. Firstly, I think it would have helped to emphasize that multiplying by n and dividing by z actually turns the slanted edge of the frustum into the right-angled straight edge of the desired rectangular prism because everything on that will end up landing at the exact same x value (or y, for the top, respectively). Secondly, however, we should note that what we get after multiplying with our perspective matrix is *not* a 3D rectangular prism, since its components haven't been divided by the w component (i.e. z value) yet. It's a seemingly somewhat arbitrary 4-dimensional entity, and so it's unclear from my limited linear algebra skills why doing the perspective divide and then applying the orthographic projection is equivalent to doing the orthographic projection and then the perspective divide. There seems to be a deeper "truth" to homogeneous coordinate equivalence that is more than just a notational convenience. If you had touched a little on that, this would have been the de-facto, perfect explanation.
Hmm, trying to figure it out more, it seems like the "divide-by-w" can really just be considered to be multiplying the matrix-vector multiplication by the scalar 1/w. And if you have a scalar a and a matrix-vector multiplication M times v, M[av] = a[Mv] (as well as [aM]v). I think that's the last piece of the puzzle.
Except 1 thing that I don't understand: from the final output of perspective projection matrix, do you need to divide x and y by w from the final output of perspective projection matrix to get the correct x and y? Thanks for potential answer 😊
For those of you who have been following the vulkan tutorial series, this video is a slight departure from the normal format. The coding portion for the tutorial will be released separately as soon as I’m finished. Future tutorials will return to the more typical structure, with code and theory interleaved. Enjoy!
i loved the Homogeneous Coordinates Hero 😂
@@yaircambordamorocho4506 hahaha thank you :)
I really like the way you explain the theory behind these computer graphics topics without mudding with the programming part.
Amazing design of video, very accessible and interesting explanation, thanks a lot.
Crystal clear as usual! Now I know what z-fighting really means! Take that wikipedia!
Cleanest description of the math behind view projection I've seen! Nice.
Agreed! I've been reading and watching almost everything I can find on the topic and this is by far the best explanation I've seen to date.
I cannot agree more, even though I had studied it before I had forgotten so many details and was struggling to find the derivation. In most books they just magically give you the projection matrix solution and give you two phrases, so hard to get it go from the basic n*(x/z) etc to the final form.
I’m writing a rendering engine from scratch in C and this was exactly the resource I was looking for. Wonderful visualization and explanation!
I remember, when first learning programming I tried to get (any level of) 3D rendering to work, and discovering the math of perspective transformation (e.g. x1/z1 = x2/z2, thus x(screen) = x(world) * (z1 / z2) ) was a critical breakthrough. Even if the only thing I could actually code with it was an imitation of the "starfield" Windows screen saver.
I’m working on the same project with SDL and quaternions right now and it has been a whole rabbit hole to dive into!
You might also want to check out Sebastian Lague, he does amazing videos on programming graphics rendering!
Currently doing this with Java, this video is great, especially since all these terms are pretty fresh for me since I’m just finishing up my linear algebra class
After watching 3blue1browns "Essence of Linear Algebra" Playlist, taking the linear algebra module in my university AND watching this video I was finally able to implement these concepts all while deriving the used methods by myself too. Thanks for this awesome video
Thank you!! glad you found it helpful!
amazing playlist and this video is great too, i use it to understand layers in neural networks
This is very very very good. I’ve seen too many people code in opengl etc without really understanding what is going on. Sure it works, but this intuition as to what these matrices are doing is good
Thank you!
Thank you for this video!! I don’t code much, but I love art and math and was so curious on the math behind game engines / 3d graphics and wanted to see how close or far off my guesses were. this makes me want to code!
Thank you so much. Comments like this are what keeps me motivated to keep making videos.
12:33 The vertical FOV is actually the angle from the center to the top (or center to the bottom, same thing). It's a half angle. Hence the theta/2.
Also the the height he marks at the illustration should be height/2.
You can define however you like but it is typically from top to bottom.
Another master piece of 3d explanation. I really never understood well the black magic of the perspective matrix. It was in somehow just diving by z. Yet, your explanation is so clean and so perfect. It makes it really easy to understand. Please post more tutorials like these. You should definitely write a book about it too.
Absolutely loved this explanation and would recommend it to anyone trying to understand the nuts and bolts of graphics programming.
My brain clicked into gear at 8:45. I didn't fully understand homogeneous matrices until now. Thank you! 💯
This, along with Cem Yuksel's 3D Transformation video really explains the subject well. I've reviewed this subject multiple times throughout the years but I gotta say, this 2-step approach (perspective projection = perspective transformation + orthographic projection) is IMHO the most intuitive and easy to remember way of teaching/studying this subject.
Most books/resources tend to focus on deriving the perspective projection matrix from the ground up, often times skipping the inherent connection to orthographic projection.
Thank you for a job well done. Cheers!
do u mind asking is this the concept of converting 3d images to 2d images that appear on our displays(i just started learning about this subject for a school project)
@@ChadyLatifi You need to learn about perspective or orthographic projection.
This simultaneously looks easily and neatly explained and not understandable at all without an already pretty advanced level
Man you saved my life. I was cramming my 3D book and completely lost in projection stuff then found your vid. Thank you so much aa
My friends, search for your life purpose, why are we here?? I advise you to watch this series and this video 👇 as a beginning to know the purpose of your existence in this life th-cam.com/play/PLPqH38Ki1fy3EB-8xmShVqpbQw99Do2B-.html
th-cam.com/video/7d16CpWp-ok/w-d-xo.html
Brilliant video. I did a computer graphics course a few years ago and we never actually went into what makes the matrix. Thanks for explaining it!
Wow, these drawings are so cool, they have a 2000's vibe. Nice.
The best mathematical explanation. In most cases, the equations come out of the blue like from the magician's hat. Thank you very much
Thanks a lot! I've never heard these concepts explained so well!
Time to drop everything for the new Brendan Galea video, love your stuff man!
Found this, Great explanation this topic was killing me, I was not able to understand it before where they get the values and a visual representation of it. You have everything. Great job!
I’m working on a career change right now, going back to school in the near future for an MS in CS with hopes to be a graphics engineer. I’m reviewing all the prerequisite math right now so having an understanding of what kind of math I’ll need to learn in the future is very helpful. Even though I didn’t really understand 95% of this it was still a great video 😁
Thanks and best of luck with your studies!!
Just a question, do you have relevant CS or math experience? Because just going "I want to program 3d space vectors" is not something the average Joe just gets up and does?
@@codejunki567 no I don’t, that’s why I’m going back and taking all the prerequisites before doing the grad program. I have to do calc 1, 2, linear algebra, physics, C++ programming, etc. I’ve done a lot of Python, R and SQL but that’s not really relevant. Believe me, I understand how difficult is and how much I have left to learn. I probably won’t be able to start the grad program for another year and half or so.
@@stef8776honestly if it's something you're interested in it's not very difficult. I think people who complete certain qualification programs try to oversell it's difficulty.
As a complete average Joe myself I haven't really had problems with the maths side of 3d graphics. It's actually helped me improve my intuitive understanding of certain concepts.
If you enjoy the work, you'll be thinking about it enthusiastically when you're out and about, going on a walk, doing whatever. When things are on your mind out of pure intrigue, you are probably in the right field and will definitely succeed.
Probably the best in depth tutorial i have ever seen on TH-cam for graphics rendering. Even better than Cherno IMO
Beautiful, right to the point. Not a lot of extra theory. Easy to follow and understand. Keep them coming 🙏
Two videos in a week! So glad you're making this series, I was struggling a lot with the vulkan documentation before I found your videos!
I have exactly no background in computer graphics, only linear algebra. Your video is masterful in its explanation. I find the tempo of your speech helps alot!
Even though I thought I had already understood this before I watched, I still learn something from it. Thanks for making this video, I think it's the clearest one about how to get the Perspective Projection
never knew there is even so much more math beyond the math that my simulation itself needs, but it finally explains a lot
Brendan, you're a gem.
thank you :)
This video on its own is incredible, educational, and just all around superb. I learned so much and tied together so many loose ends I had dangling in my brain because of this video. Thank you.
The best explanation of perspective projection. Thank you
Honestly I've probably watched this video around 4 times. Best explanation on the topic and a super good reference to hold on to. Thanks a lot!
Wow, thanks!
Thank you very much! I needed to rewind parts of the video to fully digest the idea, but finally i did. :) Please, keep up the quality work!
Ya Ive gotten some good feedback that maybe I went a little fast 😅 but really glad you were able to get it! This has definitely been the hardest video for me to make so far
I don't know why, but every explanation online of how and why the z order is preserved ends up in a shady and not very explanatory way. At 10:35 you literally made me get it instantly! thank you for this great content, keep it up brother!
This is amazing!! I always wondered what was behind it, great Job!
great explanation. i love the visuals; it makes it so much easier to understand.
Thank you!! this was definitely the hardest video I've yet to make.
Just wow. Fantastic explanation!
Very well explained!! Good work!! Look forward to your game engine and computer graphics series!!
I think that both OpenGL and Vulkan use right-handed coordinate axis. The coordinates just differ by rotation by 180 degrees around x axis.
This channel is just awesome! Thank you so much.
Nice Explanation video !!! Somehow I had to watch in 2x to not get distracted and understand better
Thanks again for continuing the series! I have something important (potentially) to add about future 3D animations:
the cube demo ran poorly for me, low framerate, creating an ugly jitter. Unusual, since my hardware is fairly fast. Fixed it by disabling the "apidump" layer I had defined in the "VK_INSTANCE_LAYERS" system environment variable. However, this made my framerate skyrocket to above 3000 FPS, making the spinning cube become an imperceivable blur. Your demo implementation is framerate dependent, I have since created a lightweight way to measure timing (delta) and adjust the speed of animations to any system. Just thought I should remind you of this just in case. I can provide my implementation if you'd like to use it.
Edit: having apidump enabled will not only slow you down, but also spam the console on every api call. Hope it helps. Sorry for the long post!
Ya this is something I should have mentioned. The easiest way to limit frame rate for now is update the chooseSwapPresentMode function in the swapchain by commenting out the mailbox present mode, and using FIFO (vsync).
Your solution is the ultimately correct one, where the game loop needs some timing mechanism. We'll cover the different methods of game loop timing pretty soon.
If you know perspective projection already, this video is useful.
Thank you very much for making this quality tutorial series, I've been following along slowly for some time and really appreciate the detail and clarity. I will say that, for me personally, the videos which focus more on the mathematical background are less useful, but I may not be representative of the audience; just thought the feedback could be useful.
Looking forward to more lessons!
Thank you! And I appreciate the feedback. It's good to know what's working for some people and what isn't. Well, some good news then is this is the most math heavy video for the foreseeable future. Tutorial 14 will have just a bit more and then it's predominantly coding after that point.
@@BrendanGalea Might wanna do a poll, I enjoyed this video! Helps me understand why I put in a matrix, without blindly copy-pasta-ing it :) I personally prefer both!
@@dexterman6361 - ya that's a good idea. Something I'll have to think about
My friends, search for your life purpose, why are we here?? I advise you to watch this series and this video 👇 as a beginning to know the purpose of your existence in this life th-cam.com/play/PLPqH38Ki1fy3EB-8xmShVqpbQw99Do2B-.html
th-cam.com/video/7d16CpWp-ok/w-d-xo.html
That intro omfg 🔥🔥🔥🔥
so clear and crisp. Thanks for this video
Glad you liked it!
finally a tutorial that actual explains the maths
homogeneous coordinates swooping in lmao. Great video! I've been meaning to understand this better for about a year now and finally searched it up and I'm thrilled to have found this, perfect for my level.
Currently learning basic math, but I watched this whole video for some reason and I really hope that someday I can understand it.
Thank you so much for this video! Finally made me understand the perspective projection matrix
It's very useful and eay to understand, thank you for your work.
This is a Beautiful Explanation
Wow, thank you so much for explaining these topics so well!
Very nice and detailed explanation. Thank you for the video.👏
Glad it was helpful! Thanks!
thank you so much for the explanation. thanks to you I also understood new things about z-fighting.
Awesome video! Thanks a lot for this!
this is the type of stuff you understand when you're learning it, but when you're programming it makes you wanna die
Hahaha ya exactly. The main problem is that you rarely get useful error messages as feedback. Things will just look wrong.
My first school project working on projection matrices I was passing in the matrix in row major order and didn’t realize OpenGL wanted column major… took me hours to figure that one out
@@BrendanGalea any tips for getting my brain to actually work with all these different orderings? It's 99% of what i spend my time debugging in my brain
THIS WAS SO AWESOME! Keep up the great work!
Thank you! Amazingly helpful video!!!
Amazing again, was nice to get to some theory.
My friends, search for your life purpose, why are we here?? I advise you to watch this series and this video 👇 as a beginning to know the purpose of your existence in this life th-cam.com/play/PLPqH38Ki1fy3EB-8xmShVqpbQw99Do2B-.html
th-cam.com/video/7d16CpWp-ok/w-d-xo.html
Excellent video! Can't thank you enough!
Love your explanations man, you make the documentation easy S/o
Amazing video to learn 3d projection!!
I think i finally get it! Thank you for this video
Thanks! Very good explenation.
New video, Awesome!
This is what I was looking for...thank you.♥♥
I really really needed this video. Thank you !!!!!
wow this is amazing thank you very much
My friends, search for your life purpose, why are we here?? I advise you to watch this series and this video 👇 as a beginning to know the purpose of your existence in this life.. th-cam.com/play/PLPqH38Ki1fy3EB-8xmShVqpbQw99Do2B-.html
th-cam.com/video/7d16CpWp-ok/w-d-xo.html
Amazing video but the "homogeneous coordinates to the rescue" part was what got me to click the button Like XD
I have been searching for a clear explanation of NDC system and the projective transformation. This is such a good video with illustrations that explain the concepts beautifully!
I cant wait to learn all the theory in college and finally be able to understand and recreate it
Great video, making LA way more interesting to me personally
Thank you so much!
This is a masterpiece. Thx!
This is actually a general derivation that holds for a skewed view frustrum. The picture shows a regular frustrum. Skewed frustra you need when you want to make a huge picture so that you have to chop up the initial regular frustrum.
Nice explanation, thank you.
Good explanation of the frustrum matrix... but I can imagine total newbies would not take much out of it, unless you show them some code and what effects can be achieved with manipulating the frustrum parameters. One thing which tripped me up is what are n and f values and how they are chooses... but this is probably just me not paying attention.
i really just watched this entire video even though it felt like someone was rambling into my ear while i was daydreaming 😂
3:09
If it points into the screen, then shouldn’t it be pointing the other way?
Ya the drawing isn't exactly clear since I triedtilting things slightly of axis to be more visible. Making 3D drawings isn't easy for me lol
+z should point into the screen. So starting from your nose to the screen in front would be the direction.
And the -z points from the screen to the viewer
Era exatamente esse tipo de vídeo que eu tava procurando. Muito obrigado!! 👏😁 ➕1 subscriber!
But what's that?! It's homogeneous coordinates to the rescue!
Love it!
thanks for great explaination
thank you so much for this
Shouldn't Scale by Y axis be 2 / (t - b) instead of 2 / (b - t) at 4:45? Otherwise it will get negated.
E.g. t = 5, b = 0 => 2 / (0 - 5) = - 0.4
this is the video I wanted when i was in high school! unfortunately now i find this as a (qualified?) mathematician :P
What type of mathematics to study to understand it
If you use the right-hand rule with X pointing to the right and Y pointing up, positive Z goes into the screen and -Z goes out. If that matches up, it is right-handed. Otherwise it is left.
Just wow, thank you so much!!
Can someone explain 4:21 , why the scale calculated? thx
sorry about the slow response, i missed seeing this.
I should have explained this here. A scale matrix consists of 3 value that all are on the main diagonal. The [0][0] value says how much to stretch the x component, [1][1] the y component, and [2[2[] the z component.
So in this case we have 2 as the numerator because we want the result to be -1 to +1 for the x and y components (+1 - (-1) = 2). The z component we want to be 0 to 1, so [2][2] has 1 as the numerator.
The denominator is sx, sy, sz (the current dimensions of the box that we want to map to the canonical) because by dividing by the current box dimensions you get 1.
So for example a box that has a width sx = 5, applying (1/sx), means 5 * (1/sx) = 5 * (1/5) = 1.
Then the numerator of 2 doubles the size from 1 to 2, hence we get a box centered at 0, with the x component ranging from -1 to 1, which is what we want for vulkan.
And same idea applies for caluclating the y and z components.
Great! I think I'll not watch it though; I've been for a few years just figuring this out mostly on my own, I don't really want to spoil anything for myself! I think I've figured out UV mapping or at least something akin to it, I figured that if you know which triangle a point is being projected from, then you can change the central point, in other words shift every 3d object's coordinates aside from Z position and reproject the point again, if you do this twice making sure that you're projecting to central positions such that the orthographic projection of the de-projected 3d point can't be on a line from the two 2d projected points, then you can now draw a line from the two projected positions to the point that was their central position, find the line intersection and you'll now have the X and Y coordinates of the de-projected point, all that's left is to simply figure the Z coordinate based on X and Y coordinates.
awesome video!
Amazing
omg, you are awesome!
Huh, that triangle stuff at 5:55 doesn't look right. Surely the big triangle has adjacent side of length n+z and not z? Otherwise it would be some other shape
Ya sorry it’s not a very clear diagram. The z is for the entire side length of the triangle not just the one part
6:30 seems that there is mistake
ys/n = y/(n+z)
Or
ys/n = (y-ys)/z
But NOT
ys/n = y/z as in video
Ya bad diagram on my part. I meant z as the total distance but the diagram as it is implies that z is just the shorter distance. Sorry about that
In minute 6:04 you are describing that the sidelines of a triangle are proportional, but you are writing that y_s / n = y / z, when it should be y_s / n = y / (z + n) because the length of the bottom segment is z + n, and not only z, based con the viewer's angle. Wouldn't the calculations change a bit with this in mind?
The z in the diagram is meant to refer to the entire length of the bottom side of the orange triangle (6:02), not just the bit occurring past the near plane.
But I can see how that’s confusing based on what I’ve drawn!
This is amazing!! I always wondered what was behind it, great Job!. Love your explanations man, you make the documentation easy S/o.
This is almost the perfect derivation of perspective projection (especially since it includes both the off-axis and FOV versions!). However, I wish you would have talked more about why applying the first perspective transform gets us into a space that allows for trivially transforming with the orthographic projection matrix. It doesn't seem intuitive to me. Firstly, I think it would have helped to emphasize that multiplying by n and dividing by z actually turns the slanted edge of the frustum into the right-angled straight edge of the desired rectangular prism because everything on that will end up landing at the exact same x value (or y, for the top, respectively). Secondly, however, we should note that what we get after multiplying with our perspective matrix is *not* a 3D rectangular prism, since its components haven't been divided by the w component (i.e. z value) yet. It's a seemingly somewhat arbitrary 4-dimensional entity, and so it's unclear from my limited linear algebra skills why doing the perspective divide and then applying the orthographic projection is equivalent to doing the orthographic projection and then the perspective divide. There seems to be a deeper "truth" to homogeneous coordinate equivalence that is more than just a notational convenience. If you had touched a little on that, this would have been the de-facto, perfect explanation.
Hmm, trying to figure it out more, it seems like the "divide-by-w" can really just be considered to be multiplying the matrix-vector multiplication by the scalar 1/w. And if you have a scalar a and a matrix-vector multiplication M times v, M[av] = a[Mv] (as well as [aM]v). I think that's the last piece of the puzzle.
nice video really
Except 1 thing that I don't understand: from the final output of perspective projection matrix, do you need to divide x and y by w from the final output of perspective projection matrix to get the correct x and y? Thanks for potential answer 😊
No, in the shader when you set gl_position it will automatically divide by the w component.
0:13 It depends, I know someone who for some reason can't see the 3d illusion.
Valuable videos.