alienizer at May 26th, 2013 22:41 — #1
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;
reedbeta at May 26th, 2013 23:11 — #2
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.
alienizer at May 26th, 2013 23:21 — #3
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!
reedbeta at May 26th, 2013 23:40 — #4
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?
alienizer at May 26th, 2013 23:49 — #5
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...
reedbeta at May 26th, 2013 23:53 — #6
Well, with the camera horizontally fixed, all vertical edges should be vertical on-screen, so...what else is there to figure out?
alienizer at May 27th, 2013 00:15 — #7
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)...
alienizer at May 27th, 2013 13:42 — #8
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!