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;
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.
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!
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?
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...
Well, with the camera horizontally fixed, all vertical edges should be vertical on-screen, so...what else is there to figure out?
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.
and here what happen when you pan down...
when in fact it should look like this (2PP)...
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!