Divide by depth for instant 3D
Thread
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
Divide by depth for instant 3D
Loading the complete thread in the background. This saved snapshot is available now. Refresh
Unofficial Hacker News client; not affiliated with Y Combinator.
gabrieloc · · focus · HN ↗
dyarosla · · focus · HN ↗
Maybe consider clipping the ball properly on the edges of the sides of the view frustum ?
anitil · · focus · HN ↗
aappleby · · focus · HN ↗
I've used that when teaching short "Graphics 101" (not in the first session though) and the math comes out more intuitive than the usual "here's how to calculate a perspective matrix, don't ask where these numbers come from" version.
psvv · · focus · HN ↗
A lot of 3D graphics can be derived pretty easily just from knowing a few basics like divide by depth. I think knowing how to construct a transformation matrix from a coordinate system basis is another one -- that would remove the need to look up how to construct a perspective matrix, for example.
A few things like that will get you pretty far and you can kind of take the same journey of discovery as early 3D pioneers. That's one of the best ways to learn because you're much more likely to remember something you figured out compared to something you just read about.
It gets tricky with perspective-correct textures, but running into issues like that on your own (even if not solved on your own) is part of the fun of learning, I think.
Lerc · · focus · HN ↗
Students can easily imagine the pyramid from an eye to the window frame, and that it keeps going.
Then I point to an object outside the window and say imagine strings going from the corners of the object to your eye. To do this they would have to go through the window, where do they do that. 3d graphics is finding out where on the window the strings go through so you can stick a picture of thing outside onto the window and it looks exactly the same.
xcafebabe · · focus · HN ↗
[dead]
TN1ck · · focus · HN ↗
skzv · · focus · HN ↗
tmoertel · · focus · HN ↗
globalnode · · focus · HN ↗
sheept · · focus · HN ↗
[0]: Here’s a visual: <a href="https://gunn-gatm.github.io/textbook/gatm.pdf#page=28" rel="nofollow">https://gunn-gatm.github.io/textbook/gatm.pdf#page=28
tmoertel · · focus · HN ↗
globalnode · · focus · HN ↗
globalnode · · focus · HN ↗
so as the other 2 helpful commenters also just said: 3d shears using linear algebra degenerate to 2d affine transformations when z=1 (or w in 4d)
globalnode · · focus · HN ↗
ggambetta · · focus · HN ↗
What this lets you do is composing multiple transforms into one matrix multiplication instead of a sequence of multiplications and additions; that's what dramatically increases performance, on modern computing devices but most especially on ancient ones, where we were fighting for every MUL.
More details: <a href="https://gabrielgambetta.com/computer-graphics-from-scratch/10-describing-and-rendering-a-scene.html#the-transform-matrix" rel="nofollow">https://gabrielgambetta.com/computer-graphics-from-scratch/1...
gcr · · focus · HN ↗
tmoertel · · focus · HN ↗
But you do need homogenous coordinates if you want to include translations (fixed distance shifts) in the set of operations you can represent as linear transformations and thereby gain all the benefits of linear algebra, including the benefit of being able to include them in a series of operations that you can represent with a single transformation matrix.
yeoyeo42 · · focus · HN ↗
LPisGood · · focus · HN ↗
yunruse · · focus · HN ↗
The killer feature is that you can put the two together for a rotation axis (~ vector) and angle (~ scalar).
With just three gimbals (rotating circles), if gimbals A and B are aligned, you only have two degrees of freedom (rotating A is the same as rotating B). Because of this, interpolating angles is unwieldy in vector space. 'Gimbal lock' confounds animation (in hilarious but unrealistic ways) but also aerospace (four hours before 'one small step for man', just after landing, Collins joked he would like a fourth gimbal for Christmas).
JKCalhoun · · focus · HN ↗
Demo: <a href="https://engineersneedart.com/Phosphor3DTest/" rel="nofollow">https://engineersneedart.com/Phosphor3DTest/
(cursor keys drive the sand crawler, square-brackets change FOV)
Sources: <a href="https://github.com/EngineersNeedArt/Phosphor3D" rel="nofollow">https://github.com/EngineersNeedArt/Phosphor3D
throwaway219450 · · focus · HN ↗
throwaway219450 · · focus · HN ↗
doubletwoyou · · focus · HN ↗
Really loved the examples of the math being put into action with those lovely little sliders
rhyperior · · focus · HN ↗
socalgal2 · · focus · HN ↗
Now-a-days maybe you can ask an LLM for something exactly at your level and anything you don’t get you can ask it that too. That wasn’t the case until recently and many still don’t use them
fsloth · · focus · HN ↗
fsloth · · focus · HN ↗
nik282000 · · focus · HN ↗
lucicditee · · focus · HN ↗
[dead]
IvanK_net · · focus · HN ↗
And 54 lines of javascript: <a href="https://jsfiddle.net/06L845jx/127/" rel="nofollow">https://jsfiddle.net/06L845jx/127/
Original discussion: <a href="https://www.reddit.com/r/javascript/comments/9nihtw/a_simple_3d_engine_in_47_lines_of_js/" rel="nofollow">https://www.reddit.com/r/javascript/comments/9nihtw/a_simple...
lelanthran · · focus · HN ↗
Now I want to write a game that does all 3d projections using x' and y' only.
vincentmathis · · focus · HN ↗
Great writeup.
lolakutty · · focus · HN ↗
I still remember the rush that I got when I got the rotating cube in my QBasic IDE in my 14inch monochrome monitor. The intuition I used was derived from how light casted shadows of 3d objects in a 2d wall..From there, this x' = x/z y' = y/z, follows naturally..
rjrodger · · focus · HN ↗
lolakutty · · focus · HN ↗
jmiskovic · · focus · HN ↗
You can have a convincing 3D with just the occlusion and fog (or even just the fog), without simulating the perspective. It's just another artistic direction.
account42 · · focus · HN ↗
Without them even pictures of the real world can look flat: <a href="https://en.wikipedia.org/wiki/File:Lahaina_Noon.jpg" rel="nofollow">https://en.wikipedia.org/wiki/File:Lahaina_Noon.jpg
jmiskovic · · focus · HN ↗
rjrodger · · focus · HN ↗
massimodeluisa · · focus · HN ↗
[dead]