1
109 May 27, 2013 at 02:41

I’m using the following to get my ray vector from the view port pixel for perspective projection (y is the up/dn axis, not z). Is it possible to modify it for two point perspective? Thanks.

dir.x = (pixel.x * ViewWidthDet - 0.5) * AspectRatio;
dir.y = -(pixel.y * ViewHeightDet - 0.5);
dir.z = -FocalLength;
dir.Normalize;


#### 7 Replies

0
165 May 27, 2013 at 03:11

1-point, 2-point, and 3-point perspective are all covered by the standard projection matrix in 3D rendering - the difference is mainly an aid to artists working at different camera angles, e.g. aligned or not aligned with coordinate axes. A 2-point perspective setup basically means the camera is fixed to look horizontally and can’t tilt up and down, like in Doom. So your formula should work for one camera direction if it works for any other, I’d think.

0
109 May 27, 2013 at 03:21

Can it be done without using matrix? I tried to Google this all day but all I get is how to draw in 2PP on paper!

0
165 May 27, 2013 at 03:40

Hmm. I suppose it could probably be done without a matrix - like I said, 2-point perspective basically means the camera is fixed to be horizontal, so it only rotates around the vertical axis and you could incorporate the rotation formula directly. With some trigonometry you could also figure out the mapping from 2D coordinates of the vanishing point to the rotation angle. But why bother? The matrix approach is more general anyway. Maybe some more context of your intended application would help?

0
109 May 27, 2013 at 03:49

Yes, the cam need to be horz fixed, I did figure that one out, but that’s about all I figured out!

I’m trying to do the same as this guy…

0
165 May 27, 2013 at 03:53

Well, with the camera horizontally fixed, all vertical edges should be vertical on-screen, so…what else is there to figure out?

0
109 May 27, 2013 at 04:15

It’s only good if the ground/sky horizontal line is in the middle of the screen. When you pan the model down, that horizontal line (ground) should move down as well.

[](http://imageshack.us/a/img51/5346/hallwayperspective2.jpg)
and here what happen when you pan down…
[](http://imageshack.us/a/img51/5346/hallwayperspective2.jpg)

when in fact it should look like this (2PP)…

0
109 May 27, 2013 at 17:42

From what I can tell when we pan, the vanishing point move just as much as the near plane. I’m still in the dark on this one. Any ideas? Thanks!