One Formula That Demystifies 3D Graphics

(youtube.com)

85 points | by msephton 5 days ago ago

30 comments

  • smokel 18 hours ago ago

    The formula is f(x, y, z) = [x/z, y/z], which does perspective projection of a 3D coordinate onto a 2D plane.

    I can't really say that this formula demystifies things, but the video is nice if you're eager to learn about this.

    • ndepoel 15 hours ago ago

      The real "a-ha" demystifying moment for me was not so much learning about the elementary rotation, translation or even perspective projection operations. It was understanding how all of those operations can be composed together into a single transformation and that all that 3D graphics really is, is transforming coordinates from one relative space to another.

      One important revelation in that regard for instance, was that moving a camera within a world is mathematically exactly the same as moving the world in the opposite direction relative to the camera. Once you get a feel for how transformations and coordinate spaces work, you can start playing around with them and a whole new world of possibilities opens up to you.

      • rabf 14 hours ago ago

        I've always walked to the shops by pulling the earth around beneath my feet!

        • fifilura 13 hours ago ago

          Once, an angry guy tried to explain that the world does not revolve around me.

          I had to walk him away.

    • sebular 17 hours ago ago

      The way he animated points with an increasing z value made it click for me. Now, when I look at the formula it makes sense. The larger the value of z, the smaller your projected x and y will be. This checks out because things get smaller as they move farther away. Something that’s twice as far away will seem half as big.

      The rotation formula eludes me.

      • smokel 16 hours ago ago

        > The rotation formula eludes me.

        Interestingly, in a way, rotation is less mystical than the perspective projection. The rotation is linear: x' = Rx, but the perspective projection is non-linear.

        This is where things become fun. Next up are homogeneous coordinates or quaternions. Takes a few years of your life to actually enjoy this though :)

        • chuckadams 15 hours ago ago

          I get how quaternions beat Euler angles, but I still can't visualize the damn things 8-/

          • aleph_minus_one 14 hours ago ago

            > I get how quaternions beat Euler angles, but I still can't visualize the damn things 8-/

            And spin groups beat quaternions since they work in every (finite) dimension. :-)

        • corysama 16 hours ago ago

          I recently appreciated this vid explaining that 3D translation using the traditional 4x4 transform matrix is performing a shear operation in 4D.

          https://youtu.be/x1F4eFN_cos

      • 16 hours ago ago
        [deleted]
    • storus 17 hours ago ago

      This formula also leads to weird geometric perceptual distortions like when one stands in front of a tall building, looks up and down and the shape of the building changes depending on the angle of the view. VR got rid of that.

    • d-lisp 17 hours ago ago

      To me the formula mystifies things. It should be made clear that it is a simple application of pythagore's theorem,

      (i didn't see the video except the beginning to check what was the "mysterious formula".)

  • dustbunny 16 hours ago ago

    I've been watching a ton of Tsoding lately. I really like nob.h his build system and I've been using it in my projects. Why we ever used a different language to build C/C++ seems so insane. Using the same language for the build system is just far simpler

    • rabf 14 hours ago ago

      His application `boomer` is the best desktop zoom app for X11! Bound to a keyboard shortcut its very useful for debugging graphics layout errors during development.

  • diabllicseagull 18 hours ago ago

    if you are a little bit familiar with graphics you go: duh, things appear smaller with increasing distance. if you are not tho, it's a great intro to perspective projection. I love how accessibly educative his videos are.

    • qingcharles 8 hours ago ago

      When I was a little kid trying to do 3D graphics on my Spectrum I couldn't find any books with the algorithm for how it worked. I remember my artistic friend and I sitting down with reams of graph paper trying to figure out how to do it. It's so simple and obvious after you learn, but until you do I felt like a caveman.

    • macintux 18 hours ago ago

      I always found it odd that perspective had to be "discovered" by artists, but a little digging online turned up this interesting, detailed look at its history.

      https://www.essentialvermeer.com/technique/perspective/histo...

      • gmiller123456 16 hours ago ago

        It's a lot less about being discovered, or invented, and a lot more about the idea of using it at all. The Renaissance was a massive change in culture. Before that, art was a tool used in rituals or storytelling rather than something to be enjoyed on its own. There was more emphasis on reproducing things as they actually were than how they looked from a particular vantage point.

      • 18 hours ago ago
        [deleted]
      • smokel 17 hours ago ago

        Artists are still struggling with the fact that human perception arises from binocular vision. Two distinct retinal inputs are integrated by distributed neural processes into a single, coherent 3D experience. This integration is neither a simple planar stitching nor a direct representation of the world, but an active construction shaped by neural computation and subjective awareness.

        It is quite likely that artists in earlier periods struggled with this as well, and were less concerned with adhering strictly to a photographic or geometrically exact perspective, as we are. The adoption of the camera obscura probably influenced things a lot.

        • fenwick67 16 hours ago ago

          Even ignoring binocular vision it's very unintuitive to "draw what you see" because of this. Our brain usually interprets our environment as objects, 3d shapes, and things. Turning that off and trying to grab a literal image from it is difficult

        • Demiurge 17 hours ago ago

          Is “neural computation” a thing, or a poetic metaphor?

  • 0xfaded 17 hours ago ago

    The world of homogeneous coordinates (https://en.wikipedia.org/wiki/Homogeneous_coordinates) is magical and extends beyond just points and lines to conics.

    The Multiview Geometry Book begins with a great deep dive on the topic.

    https://www.cambridge.org/us/universitypress/subjects/comput...

    • boslo-km 16 hours ago ago

      Jim Blinn's Corner (1996) also has a good chapter/article, "The Homogenous Perspective Transform."

  • pengaru 5 hours ago ago

    Nothing demystifies 3D graphics more than learning the relevant rudimentary parts of linear algebra.

    Casey Muratori's Handmade Hero series has several excellent explainers aimed at aspiring game developers, there's even a math playlist:

    https://www.youtube.com/playlist?list=PLEMXAbCVnmY7lyKDlQbdb...

    Learning that perspective happens via /z is nowhere near sufficiently demystifying IMO

  • cocodill 18 hours ago ago

    [flagged]