1
$\begingroup$

I have a model that appears to have fake depth, where objects in the geometry are smaller rather than further away. That said, the model looks fine in orthographic view (if you position the camera correctly) and appears there as it actually should appear in perspective view.

enter image description here

In perspective view, of course, the objects that are "further" away are smaller than they are supposed to be when you get close to them.

How could I transform the vertices of my mesh to appear in Perspective view, as it does in Orthographic view? As far as I know, it would involve: 1) translating each vert along the x and z world planes as they appear on the perspective screen coordinates to line up with the same vert on the orthographic screen coordinates. 2) scaling the mesh along the world y, eyeballing it until everything starts to look correct.

The first step is where I find myself rather stuck. Anyone got a way to tackle it?

$\endgroup$
1
  • $\begingroup$ Is there a reason to not simply use an orthographic camera? $\endgroup$
    – PGmath
    Jan 21, 2015 at 18:23

2 Answers 2

1
$\begingroup$

This sounds like a job for math, python, and bmesh. You'll have to have an understanding of the mathematics behind orthographic and perspective projections so that you can compute replacement coordinates for the vertices.

Once you have the formula, you can write python which iterates through the vertices of the mesh and rewrites their coordinates. Something like this:

obj = bpy.context.active_object
for v in obj.data.vertices:
    v.co = funkify(v.co)
$\endgroup$
1
$\begingroup$

Expanding on Mutant Bob's answer (he provided the code, I'm commenting from the math point of view):

It is, unfortunately, impossible "in general" (except some fringe cases) to recreate the real positions of some points in space from how they appear from one point of view (and your scene essentially represents one point of view - from the front - even though it's technically 3-dimensional). You need either two points of view (two different variants of the scene; one would look as if you're observing it from the front, like you have here, and another would look as if you're observing it from the side, for example); or you need one point of view AND a depth buffer for that point of view.

Suppose you have the first situation (you have two points of view). Then the task of recreating the original positions of vertices in space would be pretty demanding (depending on whether or not we can biject vertices from one scene to another easily), but theoretically possible to pull off.

Suppose you have the second situation (one point of view and the depth buffer info). Then the task of recreating the original positions is fairly trivial (you might get lost in the equations, but the algorithm itself is pretty straightforward).

But: unfortunately, even though you have a 3D scene, it's essentially "2D": you only have the "screen positions" of vertices stored in there and placed onto some plane that is parallel to the camera screen. As a result, you have only one point of view and that's all; no second point of view, no depth information.

Here's an example: see that lever on the wall behind the character? It could be a big lever far behind the character, or it could be a small lever right next to the character. Both of these situations would result in the same projection (same image). Thus, it's not possible to "backtrack" this operation and determine where that lever really should be.

The opposite operation to what you want to do is absolutely possible to perform, but what you're asking for is, sadly, impossible since the depth information is lost.

However! If your scene isn't completely flat (all vertices being on one plane), then you could, in theory, multiply it by an arbitrary factor along the axis of depth and then multiply the coordinates along the two other axes, the further you get from the camera position, the more the multiplication factor. However, it will be a very approximate solution (you'll have to eyeball it) and it will largely depend on how (if at all) the relative depth is preserved in your scene.

$\endgroup$
3
  • $\begingroup$ But, the information stored in the actual data of the objects locates each vertex in three dimensions, right? Couldn't that be used to calculate a depth buffer? $\endgroup$
    – Tim M.
    Feb 27, 2019 at 18:32
  • $\begingroup$ Oh, wait. I guess that since the depth of the vertices is also only correct in orthographic mode, it will also be inaccurate when thought of in perspective, so that wouldn't really work. Never mind. $\endgroup$
    – Tim M.
    Feb 27, 2019 at 18:35
  • $\begingroup$ Sorry to comment spam, but here's a thought: if the model looks accurate in both front and side orthographic, you should mathematically be able to make that work, right? That would be the two points of view you were mentioning. $\endgroup$
    – Tim M.
    Feb 27, 2019 at 18:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .