[HN Gopher] Implementing strict three-point perspective
___________________________________________________________________
Implementing strict three-point perspective
Author : TheRealPomax
Score : 74 points
Date : 2021-06-05 19:04 UTC (3 hours ago)
(HTM) web link (pomax.github.io)
(TXT) w3m dump (pomax.github.io)
| [deleted]
| whatshisface wrote:
| That last image is not how artists draw rotated cubes in three-
| point perspective. So, I have to conclude that the author's
| formalization only works for lines parallel to the axes.
| saltcured wrote:
| Indeed. As you stated, mutual vanishing points, as used in
| illustration, are when parallel lines of the scene are extended
| to infinity and converge. Animation of a rotating object
| requires animation of a set of vanishing points for each frame.
|
| This is nearly deja vu for me, as a conversation that I've seen
| several times at the intersection of arts and computer
| graphics. I can only conclude that a sub-population have
| received instruction on "vanishing points" that were overly
| specific and missed the footnote on how it generalizes.
| Specifically: the artist and draftsman idioms of 2 or 3-point
| perspective or vanishing points are short cuts for perspective
| rendering of subjects which have cartesian layouts, such as
| rectilinear buildings and street scenes built on a cartesian
| grid, with lots of parallel or perpendicular edges. The missing
| footnote is that this does not work for arbitrary subjects.
|
| Real perspective rendering has infinite potential vanishing
| points in one scene. Each point represents nothing more than
| the infinite continuation of any line segment in the scene, as
| it would be rendered by a true perspective rendering. The
| vanishing point of any one line is when the viewing ray
| converges with that line, to the limit of angular resolution in
| your rendering. All more distant segments project into the same
| small picture element, whether formed by raster graphics or
| your finest pencil, pen, brush, or engraving tool.
|
| For a complex scene, the skilled artist would choose [edited to
| delete typo "three"] different vanishing points appropriate for
| each set of parallel lines. E.g. a vineyard with parallel rows
| of plantings might use different points than a road passing by
| at an odd angle, and a set of high-tension powerlines crossing
| the scene would have its own vanishing points as well. If the
| power lines follow a ragged course, each segment between two
| towers would need its own vanishing points. Furthermore, the
| artist would have to approximate the parabolic sag of the wire
| below these projected line segments, perhaps using parallel
| lines to locate the envelope within which the line sags.
| egypturnash wrote:
| Artist is my day job and this is a decent approximation of
| what a complex perspective drawing entails. And, really, it
| probably entails a lot of eyeballing it, too - sketch in
| something that feels roughly right against whatever
| guidelines you may have constructed, and leave it at that.
|
| "Two-point perspective" and "three-point perspective" are
| good enough approximations for the common problem of "drawing
| a scene set within a place built around a lot of right
| angles".
|
| I feel like the computing analogy to make here is "a very
| opinionated framework": it makes life a _lot_ easier, _if_
| you want to do things the same way it 's built to do. If you
| want to do stuff outside of what it's built to do you're
| gonna have to do a lot of the work yourself.
| TheRealPomax wrote:
| Artists don't draw all the way to the vanishing points, we only
| draw in the part that looks normal. Look at the figure showing
| off how straight lines behave again, and you'll see that
| everything _starts off_ actually looking like normal straight
| lines, and things don 't actually go crazy until we start
| getting close to our vanishing points.
|
| Which is why on paper, you place the vanishing points _outside_
| your drawing, so your drawing can stay constrained to the part
| of exponential space that looks normal. E.g. if you constrain
| the viewport to the unit area (the triangle between 1 /0/0,
| 0/1/0, and 0/0/1) and scale your scene down to fit inside of
| that, things will actually look perfectly fine, with a gorgeous
| perspective (but will also be visually indistinguishable from a
| wide angle camera positioned closed to your major scene point,
| so just use that).
|
| However, with computers we can trivially see what will happen
| if you _do_ try to use the full space, rather than only working
| inside an (incredibly sensible!) crop. The result is pretty
| wild.
| egypturnash wrote:
| _Artists don 't draw all the way to the vanishing points, we
| only draw in the part that looks normal_
|
| I am a professional artist and I would just like to confirm
| this line. 3-point perspective tends to start looking weird
| once you get outside of a certain sweet spot; I did _so_ many
| beginner drawings with the vanishing points too close, which
| resulted in a weirdly exaggerated set of shapes.
| cmiles74 wrote:
| The effect is also pretty dramatic and I think this is a big
| part of illustration work. Comic books in particular use
| three point perspective to add drama.
|
| https://www.youtube.com/watch?v=wyIKZhIAl0k
|
| The cropping aspect is made pretty explicit in Stan Lee's
| video. ;-)
| twelvechairs wrote:
| I think there's two issues making it this way. The big one is
| the use of 'exponential space' based on each distance being
| halved along an axis, which is not accurate to how artists
| perspective works if drawn properly (someone smarter than me
| may do the math to figure out what the real formula is here).
|
| The second point is the vanishing point for verticals is
| ridiculously close to the cube which makes it an incredibly
| tortured perspective for the eye to understand to start with.
| megameter wrote:
| I did set out to make a wireframe two-point perspective dungeon
| crawl in PICO-8 once. It worked(I recall the math for making the
| height of walls feel correct at different distances was hard to
| understand and I probably did resort to the CG approach) but I
| eventually abandoned it because I was spending way too much time
| trying to deal with occlusion and optimize it for PICO-8's CPU.
|
| Since then the system constraints have changed and I would
| probably just make a tline() raycaster.
| TheRealPomax wrote:
| PICO-8 is such a fun piece of software. Getting lost in
| graphics optimization for it feels like it's more the norm than
| the exception =D
| hypertele-Xii wrote:
| Getting lost in optimization is the opposite of actually
| making things, and as an artist, it's at the top of my
| reasons why PICO-8 _isn 't_ fun to use.
| kragen wrote:
| This is not how geometrically-correct pinhole-camera perspective
| projection works; Pomax is approaching the vanishing points
| exponentially rather than hyperbolically, which is why straight
| lines turn into curves. If you work out the geometry of the
| pinhole camera setup [edit: _with a flat imaging plane_ ], you
| find that you're just doing a division (conventionally, dividing
| by the Z-coordinate in camera space, though you don't have to set
| it up that way) instead of an exponential. This is a "projective
| transformation", and those _do_ map straight lines to straight
| lines: https://en.wikipedia.org/wiki/Projective_transformation
|
| If you have a sufficiently wide field of view, even the standard
| projection transformation gives you things that look pretty
| "distorted", which is a fun trick often used in art photography.
| Also fisheye lenses are often designed to do a non-projective
| transformation and get effects you can't theoretically get with a
| pinhole camera, like mapping straight lines to curved lines as
| Pomax does.
|
| Pomax's invention is super cool, even though it isn't the usual
| 3D-2D mapping motivated by pinhole-camera geometry. Weird is
| good! I wonder if there's a version of it in which straight lines
| become curves, but _polynomial_ curves of some reasonable degree,
| or maybe something involving square roots and division, so we can
| rasterize them without computing a bunch of exponentials? Is that
| even a reasonable way to seek optimizations in 02021?
|
| Pomax may have a good point that projective transformations
| aren't "strict three-[vanishing]-point perspective" because,
| instead of having three vanishing points, they have _an infinite
| number of_ vanishing points, a point others have made in the
| comments here. The profoundly weird and cool aspect of Pomax 's
| invention is that _every_ line converges to one of those three
| points.
| klodolph wrote:
| You can get distorted projections with pinhole cameras too, as
| long as your sensor is curved. Fisheye is impractical, but
| cylindrical projections are easy. Common way to do pinhole
| photography is with an oatmeal box, which is a cylinder.
|
| https://sdsu-physics.org/assets/PDFs/oatmeal_pinhole_camera....
|
| I'm not really trying to nitpick here, just like talking about
| pinhole cameras. With a flat image plane the pinhole lens is
| "rectilinear", but the beauty of pinhole cameras is that you
| can project the image onto any shape you want without affecting
| focus.
| kragen wrote:
| Oh, that's an excellent point! I guess I didn't even _think_
| about that, which shows how much experience I have doing
| _actual_ pinhole photography in the physical world :)
| cousin_it wrote:
| It seems to me that if you want some fancy curvilinear
| perspective, the simplest way is to render the scene normally
| (or make six renderings in a cubemap if needed), then texture-
| map it onto a suitable shape. That should work for any
| rearrangement of light rays, as long as they are straight and
| come to a point camera. Might get more fun if you want curved
| light or a camera extended in space :-)
| kragen wrote:
| Well, that won't give you the "strict three-point" property,
| where all 3-D lines asymptote to just one of those three
| points. More broadly, there are a wide range of mappings from
| 3-D to 2-D that use information that is lost in the standard
| divide-by-Z technique; some of them are used in automated
| optical inspection systems, for example.
| twelvechairs wrote:
| > Pomax is approaching the vanishing points exponentially
| rather than hyperbolically
|
| Exactly this. To put it in drawing terminology, the distance of
| a line towards the vanishing point is related to the distance
| from the camera (station point). Images like this may be of
| assistance for those of a computer and not hand drawing
| background
| https://guidetodrawing.com/site/assets/files/1082/gtd-235.79...
|
| An exponential ratio as used by the article could maybe be
| described as assuming the camera is 0 distance from every point
| drawn.
| jiofih wrote:
| > Except that's not "true" three point perspective
|
| Is "strict 3-point perspective" a known concept or the author
| just invented it?
|
| > That's the easy-for-computer-graphics version of three point
| perspective
|
| It was devised for people, not computers, over 600 years ago.
|
| I can't find any other references or why you'd want this odd
| infinite representation of space, it makes little sense except as
| a mathematical curiosity.
| robbrown451 wrote:
| Agree, none of this makes sense. Three point perspective is
| best explained by the concept of a pinhole camera with a planar
| film surface, and simply assumes that we are most interested in
| the theoretical directions of the 3 major axes, X Y and Z.
|
| For it to really duplicate the geometry you see with your eyes,
| you need to look at the resulting photo from the spot where the
| pinhole is (related to the paper, and presumably turning it
| upside down first). This of course means you need to close one
| eye, or show a different image to each eye).
|
| But computer graphics, to my knowledge(see 1 below), almost
| never thinks of it in terms of vanishing points, this is a
| convenient concept (essentially, a shortcut) for humans who are
| drawing on paper. Do computers ever even calculate where the
| vanishing points are on the drawing plane? (other than niche
| uses, such as an art composition app or the like?) I have never
| seen computer graphics software "care" about the concept of
| vanishing points, such as by having a variable that represents
| said point.
|
| I feel weird having such a negative reaction to this article
| since I have used the author's bezier library for ages and have
| a lot of respect for his writing regarding beziers and related
| curves.
|
| [1] I implemented view controls in CAD systems 25 years ago
| that are still in use today, and which concentrated especially
| on perspective views, so I have some knowledge of the subject.
| Also I learned perspective drawing skills in my industrial
| design education prior to that, and previous to that was into
| photography and mechanical drawing and obsessed over such
| geometrical stuff, starting 40 years ago now.
| TheRealPomax wrote:
| Computers graphics based on linear algebra can't do true
| vanishing points, so... no?
|
| This isn't a tutorial on how to implement a useful three
| point perspective, this is an analysis of how three point
| perspective behaves if we don't make any computing
| concessions and examine the full space. You're never going to
| use that in 3D graphics, it looks terrible and I can't even
| think of a fun game mechanic that could be based on it. Just
| use a wide FOV camera in your software of choice and you'll
| get something much better. But it _is_ a programming exercise
| that is worth running through.
|
| Remember, when we draw perspective on paper, we _never_ draw
| all the way up to the vanishing points, we keep them far away
| enough that every straight line we draw still behaves like a
| straight line. Things don 't get crazy until you get close
| enough to the vanishing points for the exponential mapping to
| become really pronounced, and starts doing really wild
| things.
|
| So obviously for an analysis of the space I'm going to draw
| something that is intentionally close enough to the vanishing
| points to show that insanity off =)
| TheRealPomax wrote:
| In drawing, it's just "three point perspective", and it's this.
| In computer graphics, every resource you look for explains
| three point perspective as a plane intersection (because then
| computers can draw it using a camera), which is not the same
| thing as pen and paper three point perspective. The word
| "strict" here is just the natural language version of the word,
| not a technical term. We're implementing three point
| perspective following the pen and paper rules, not the "let's
| subtly change how it works so a 3D camera can do this" rules =)
|
| > I can't find [...] why you'd want this odd infinite
| representation of space.
|
| Like I say in the post: _you_ almost certainly don 't ever want
| it. When drawing three point perspective using pen and paper we
| typically pick vanishing points that aren't even on the paper
| itself (you tape down your paper and mark them on your desk
| instead) to get sweet looking faux architectural drawings while
| effectively working on a "crop" where the effects of
| exponential space are subtle, instead of super obvious, so it
| never gets weird. (heck, even adding secondary vanishing points
| that are further apart for working at different scales for
| different parts of your picture so people will never see the
| effect of exponential space is pretty common)
|
| Similarly, you can get something "close enough" in any 3D
| software with a wide angle camera positioned close to your
| subject, so unless you've very explicitly setting out to do
| exponential space graphics, there is _literally_ no reason for
| you to ever need, let alone implement this.
|
| But it _is_ fun to work out what the real behaviour is if we
| try to implement strict three point perspective on a computer,
| because we like programming puzzles, and (also as mentioned)
| there aren 't any pages on the web that I've been able to find
| that cover this extremely niche projection so now there is at
| least one.
| j4yav wrote:
| Do you have animations generated from this? I would love to
| see rotations in motion.
|
| I feel like there is some game that could be created from
| needing to manipulate objects in this space.
| TheRealPomax wrote:
| https://twitter.com/TheRealPomax/status/1400974346160533508
| zozbot234 wrote:
| It looks like the OP has come up with their own variation on
| some sort of curvilinear perspective (which is a known concept
| in visual design, and may even be useful to model, e.g.
| distortion introduced by a lens) but this is not how actual 3D
| projection works.
| kragen wrote:
| Well, you _can_ do actual 3D projection using a fisheye lens!
| It might even be a worthwhile thing to do.
| TheRealPomax wrote:
| Very much not, that's the whole point of this post. This is
| what happens when you take the maths associated with 2 and 3
| point perspective, and work out what the non-cartesian
| properties actually mean if you were to implement it "the way
| it really is" on a computer.
|
| At which point you should go "this is silly, let's never do
| this" because: it's really silly, let's never do this. And
| now we know why.
| captainmuon wrote:
| Isn't regular point perspective that all _axis-aligned_ lines
| meet at the one of the three points, whereas here all lines
| _whatsoever_ eventually converge there?
|
| This reminds me of the mathematical trick to make a "hollow
| earth" work, with us living on the inside: All rays of light
| are bent. You can never see the curvature of the earth (or it
| seems that we are living on the outside). The stars that seem
| to be at ~infinity are at the center of the sphere, and the sun
| is a ball of fire orbiting around the center, and so on.
| TheRealPomax wrote:
| Almost: all equal ratio lines (x=z+c, x=y+c, y=z+c where c is
| some constant) head off in a straight line towards their
| respective horizons, but all other non-axis-aligned lines
| converge at the vanishing points.
| mpetrovich wrote:
| Back in college I wrote a 3D rendering engine using what seems to
| be a similar method as the OP. I always thought the results
| looked a little strange... https://github.com/mpetrovich/CUB3D
| TheRealPomax wrote:
| Neat!
___________________________________________________________________
(page generated 2021-06-05 23:00 UTC)