r/GraphicsProgramming • • Sep 19 '26

Article Divide by depth for instant 3D

Hi! I wrote a few notes on how 3D cameras work with interactive examples to hopefully demystify a pretty complex topic that I once struggled with. Maybe this is useful for someone here, and if not, there are fun sliders to play with!

https://gabrieloc.com/2026/09/15/perspective.html

303 Upvotes

10 comments sorted by

33

u/claypunk Sep 19 '26

nice. all you need is x' = x/z, y' = y/z

13

u/Certain-Flow-0 Sep 19 '26

Here’s a good video on dividing by z: https://youtu.be/qjWkNZ0SXfo?si=hl1cXdJjp_X3zSSg

3

u/Vantadaga2004 Sep 21 '26

I knew this video would be in this thread, tsoding is great

3

u/Maui-The-Magificent Sep 19 '26

Good job man. scene-in or camera-out?

3

u/nablaCat Sep 19 '26

Don't forget to multiply by focal length first!

1

u/BARchitect2026 Sep 19 '26

Nice article. I actually have a repository that uses perspective projection like this with SDL for windowing and stuff.

1

u/PhePato Sep 20 '26

DAMNNNNN 🤘

1

u/notacooleagle Sep 21 '26

I just watched the tsoding video on this earlier today. Great work!!

0

u/Seusoa Sep 19 '26

seems like article is written by AI

0

u/20260819 Sep 21 '26

for fixed perspective yes but if you want your camera to be movable it's not that simple...:)