The Deep Magic Of 3D Graphics Perspective

Many of us of a certain age will have had their first true, good 3D video game experience with Super Mario 64. Unlike previous 3D games, the camera was an object controllable by the player, rather than a first-person-ony mode or one where the game tries to guess the best placement for the camera. We might take this mechanic for granted today, but 3D was a new technology at the time that took experimentation before settling on the norms we have today. From a programming perspective, 3D graphics can be a bit of a head-scratcher but [Gabriel] shows that perspective and the camera can be as simple as a few lines of math.

When starting out as a programmer, [Gabriel] used various tools that provided a camera somewhat automatically. But after reaching the limits of these types of frameworks, the next step is to learn how that works from scratch. It turns out that it’s a bit of matrix math, with values for foreground and background clipping planes as well as aspect, field of view, and position. This basically replicates a trapezoidal prism which can be thought of as a viewer looking at a scene from the perspective of a camera. To provide the depth effect, the X and Y coordinates are divided by the Z coordinate within this matrix system, making far-away objects smaller and generating the 3D effect.

On [Gabriel]’s site which explains this method, there are a few sliders in several examples that demonstrate how changing values of each of these variables changes the perspective and the object being displayed. For a math lesson it is very interactive and helps intuit these concepts. Cameras aside, the generation of 3D objects has its own unique set of math equations to learn about that are “equally” interesting.

8 thoughts on “The Deep Magic Of 3D Graphics Perspective”

    1. I have books from that era when I was programming on a 386SX. VGA, no libraries, no hardware assists. I spent so long trying to understand matrix operations that some of the pages are yellowed from the sun. That wireframe donut was worth it though.

  1. Up through the 90s, those of us that went into graphics endured yet another computing gauntlet (some liked to call it “a gauntlet for all gauntlets” which might have been better ignored). The gauntlet was understanding graphics to a level required to do graphical things, from the history to the math through to phosphor, and only by doing it yourself from the ground up in any mix of hw/sw you could manage to make.

    One fear some people had was that as tech advanced we’d forget and others would never feel compelled to learn. And…here we are. For ex. that’s an entire blog post by someone having used camera support for years without understanding the math, and the post outlines a few basics of perspective (while still missing context). Yes it’s actually not voodoo. And no, faking it by not knowing is not usually going to lead to making it, unless you’re ok with things like missing opportunities or random voodoo occurring with no mental tools to diagnose. Graphics is a tough one to be fully effective in with little or fragmented first hand experience and knowledge. IMO there’s no reasonable substitute.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.