Skip to content
0:00 / 0:00

#perspectiveprojection#projectionmatrix#vulkan

The Math behind (most) 3D games - Perspective Projection

Brendan Galea

31K subscribers • 2 videos on Hallway

YouTube
  • Recommended by 3 people: 3 in engineering communities.
  • A classic. People kept recommending it from 2021 to 2026.
  • Presented by Brendan Galea

Intermediate. Assumes working knowledge.

570K views5 years ago3 recommendations

Graphics and audioComputer scienceRenderingMath for programmers

Brendan Galea provides an animated derivation of orthographic and perspective projection matrices, focusing on the Vulkan API.

Perspective matrices have been used behind the scenes since the inception of 3D gaming, and the majority of vector libraries will have built-in helper functions to construct them for you. But what if you wanted to know the reasoning behind how these matrices are constructed. I start off with a brief introduction of computer graphics and the key ideas behind 3D rendering. I differentiate between Image Order Rasterization typically used by Ray tracers, and object order rasterization as used in most video games. I then present an animated walkthrough showing the full derivation of both the orthographic and perspective projection matrices. My derivation here is focused on the Vulkan API, but the reasoning applies just as well to other API's such as OpenGL or direct X, with the only notable differences being the size of the canonical viewing volumes, and the handedness and conventions of the xyz coordinate systems. How does 3D graphics work? Image versus object order rendering The Orthographic Projection matrix The perspective transformation Homogeneous Coordinate division Constructing the perspective matrix Non-linear z depths and z fighting The perspective projection transformation ** Resources ** Fundamentals of Computer Graphics by Peter Shirley & Steve Marschner songho.ca/opengl/gl_projectionmatrix.html matthewwellings.com/blog/the-new-vulkan-coordinate-system/ insider.com/pixars-animation-evolved-toy-story-2019-6 ** Attributions** Ray tracing graphics cards - Photo by Nana Dua from Pexels Rubiks cube - Photo by Mathias P.R. Reding from Pexels Ray tracing in video games - digitaltrends.com/gaming/battlefield-v-dxr-ray-tracing-teste… en.wikipedia.org/wiki/Line%E2%80%93plane_intersection

Why it's here

3 people recommend this

What people say. Engineers recommend this video as one of the clearest and most accessible explanations of how projection matrices are mathematically constructed.

u/palapapa0201in r/GraphicsProgramming • Recommends

On “Help me understand the projection matrix”

This video also explains it very clearly link to this video

u/therpgmasterin r/GraphicsProgramming • Recommends

On “The projection matrix in vulkan”

This is one of the best explanations, but after hours of debugging I can't get the projection to work. I've also tried this implementation. But whatever I do, the object intersects either the near or far plane, and disappears. Is there another matrix multiplication that is critical for a working result? Only using a simple transform combined with this method always seems to fail.

u/shakinMyShakein r/GraphicsProgramming • Recommends

On “Trouble Understanding a Critical Step in Perspective Projection”

This video explains the math behind perspective projection in an accessible manner and should help a lot as to what each coordinate means and what the result of the projection is. The Math behind (most) 3D games - Perspective Projection (youtube.com) I'd advise against using wikipedia for math, it's super obfuscated with formal mathematical notation which is very often unclear and assumes you know about this stuff already. I use it only when I want a refresher of something. A good resource is LearnOpenGL - Coordinate Systems but it doesn't actually go into the math of the perspective projection, although gives a link to an article that doeslink to this video