Advertisement

Perspective View Queries

Started by May 04, 2005 10:07 AM
6 comments, last by Brother Bob 19 years, 4 months ago
When we move an object with fixed size (e.g. a sphere) on a circular orbit around the viewer's position it seems to be changing in size. It is growing when approaching the edges of the view frustum. We set the perspective matrix to

gluPerspective (120.0f, 1, 1, 10.0f);	

So logically the visible size should not change (we recall our everyday experience) but it does. Could you be so kind to explain, why does it happen, or how to get the effect of human's eye in the perspective view. P.S. when we move the object in the plane (that means that the distance from the viewpoint to the object is changing) the visible size of the object doesn't change (but it should). That must be another demonstration of the same problem which we've encountered in the above mentioned phenomenon.
C++ RULEZ!!! :)
simple, your using a fov that is slightly extreme.

you have a fov of 120, it represents a field of view of 240 degrees.

I use a fov value of 45, and so does most 3d games in existance(since it's the closest to our field of view).
(note: in open gl fov is calcylated from the center to the edge of the screen so a fov value of 45 is really 90 degrees)

now since 3d cards can't display curves that well 3d objects get distorted in a funny way at those extreme filed of view values.
at the edges things appear reasonably ok, but in the center it's all squashed into a little point(with funky/horrible streching inbetween).


So try something like this instead, gluPerspective (45.0f, 1, 1, 10.0f);

allso your aspect value is slightly off, unless you have a square screen that is.
Advertisement
Quote: Original post by lc_overlord
simple, your using a fov that is slightly extreme.

you have a fov of 120, it represents a field of view of 240 degrees.


thanks lc_overlord, for response,
actually looking in MSDN:
fovy The field of view angle, in degrees, in the y-direction. 

i believe fovy is the whole angle - not the half of it... so if the argument is 120 - it means the field of view is 120° - not more, not less... or are you sure it equals twice that? (unfortunately i haven't got ogl specifications right away... so my opinion is based on MSDN and NeHe's tutorial N 1):
The following lines set the screen up for a perspective view. Meaning things in the distance get smaller. This creates a realistic looking scene. The perspective is calculated with a 45 degree viewing angle based on the windows width and height.

while the argument 45 is passed to the function...

Well... now i beleive OpenGL perspective correction "catches" only the depth of the polygon (in the screen)... that is, the pixels of same depth are transformed identically, independently of their (x,y) coordinates...
can you agree/disagree with that?
+ in order to receive a real looking scene, as viewed by a human eye we need to make use of some artificial advanced techniqs, like... like what? is it so-called "fisheye"?
C++ RULEZ!!! :)
Quote: Original post by BrennendeKomet
i believe fovy is the whole angle - not the half of it... so if the argument is 120 - it means the field of view is 120° - not more, not less... or are you sure it equals twice that? (unfortunately i haven't got ogl specifications right away... so my opinion is based on MSDN and NeHe's tutorial N 1):

fovy is indeed what MSDN says, but MSDN does not state between witch tree points the angle is derived from, i happen to know that it is from the center of the screen to an imaginary point that represents your eye and finaly one of the edges of the viewport.
this has been confirmed trough experiments



Quote: Original post by BrennendeKomet
Well... now i beleive OpenGL perspective correction "catches" only the depth of the polygon (in the screen)... that is, the pixels of same depth are transformed identically, independently of their (x,y) coordinates...
can you agree/disagree with that?
+ in order to receive a real looking scene, as viewed by a human eye we need to make use of some artificial advanced techniqs, like... like what? is it so-called "fisheye"?


i wouldn't say identicly, more like uniformly, but it doesn't really matter, if it looks good it's ok.

Unless you have a pair of werry extreme pair of eyeglasses humans never see anything in fisheye perspective.
and allthough we have a field of view of 180 degrees, it isn't like a fisheye, it's not distorted like that, infact a computer screen can't display what a human can see unless it can wrap itself around us.
So when looking at a computer screen we are most used to 90 degrees fov since then it would be like running around holding up a pictureframe infront of us.
Our brain likes that better than fisheye perspective.

Quote: Original post by lc_overlord
Quote: Original post by BrennendeKomet
i believe fovy is the whole angle - not the half of it... so if the argument is 120 - it means the field of view is 120° - not more, not less... or are you sure it equals twice that? (unfortunately i haven't got ogl specifications right away... so my opinion is based on MSDN and NeHe's tutorial N 1):

fovy is indeed what MSDN says, but MSDN does not state between witch tree points the angle is derived from, i happen to know that it is from the center of the screen to an imaginary point that represents your eye and finaly one of the edges of the viewport.
this has been confirmed trough experiments

I have seen a few posts indicating that some people seems to have a GLU implementation where the FOV is half the vertical angle, but most have it as the full angle. My implementation, for example, uses the full angle between the bottom and top clip planes as the FOV. Meaning; 90 degrees is 90 degrees top to bottom, not center to top/bottom. I use the standard implementation shipping with Windows.

Quote: Original post by lc_overlord
Quote: Original post by BrennendeKomet
Well... now i beleive OpenGL perspective correction "catches" only the depth of the polygon (in the screen)... that is, the pixels of same depth are transformed identically, independently of their (x,y) coordinates...
can you agree/disagree with that?
+ in order to receive a real looking scene, as viewed by a human eye we need to make use of some artificial advanced techniqs, like... like what? is it so-called "fisheye"?


i wouldn't say identicly, more like uniformly, but it doesn't really matter, if it looks good it's ok.

Unless you have a pair of werry extreme pair of eyeglasses humans never see anything in fisheye perspective.
and allthough we have a field of view of 180 degrees, it isn't like a fisheye, it's not distorted like that, infact a computer screen can't display what a human can see unless it can wrap itself around us.
So when looking at a computer screen we are most used to 90 degrees fov since then it would be like running around holding up a pictureframe infront of us.
Our brain likes that better than fisheye perspective.

Just as a comment, the real angle you get while sitting infront of a monitor, assuming a fullscreen window, is usually somewhere between 25 and 30 degrees (full top-to-bottom-angle). That is the angle you should use to get "correct" perspective as in real life. Small, yes, but as you say, the monitor would have to wrap around you to get a larger FOV. SO even 90 degrees, while it may look good, is way more than the actual angle.
To test the full vs. half FOV angle, I made a simple program one can try. Here's the display function; I assume you can provide the rest of the code to setup a window.
	glMatrixMode(GL_PROJECTION);	glLoadIdentity();	gluPerspective(90, 1, 0.1, 100);	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();	glPointSize(5);	glBegin(GL_POINTS);	for(int y = -10; y < 11; ++y)	{		glVertex3i(0, y, -10);	}	glEnd();

The code draws 21 points linearly spaced every unit between -10 and 10, at a distance of 10 units from the viewpoint. That means, with a full horizontal angle of 90 degrees, the 21 points should exactly fit between the top and bottom of the viewport.

If the FOV parameter in gluPerspective is the full angle, the FOV parameter should be 90, as in the code, to get all points spread out over the entire viewport height. If it specifies half the angle, the parameter should be 45. Try and see what value that gives the points spread out over the entire viewport height, and that should also tell if it's full or half angle.
Advertisement
Quote: Original post by Brother Bob
Just as a comment, the real angle you get while sitting infront of a monitor, assuming a fullscreen window, is usually somewhere between 25 and 30 degrees (full top-to-bottom-angle). That is the angle you should use to get "correct" perspective as in real life. Small, yes, but as you say, the monitor would have to wrap around you to get a larger FOV. SO even 90 degrees, while it may look good, is way more than the actual angle.


if it's only 25 - 30 degrees then your using a microscopic screen.
just now im sitting at an 19" screen and it's at least a full 45 degrees up and down.
At home i have a 21" screen, it's way cooler.

i will test that code when i have time(and a computer i could compile it on).
Quote: Original post by lc_overlord
if it's only 25 - 30 degrees then your using a microscopic screen.
just now im sitting at an 19" screen and it's at least a full 45 degrees up and down.
At home i have a 21" screen, it's way cooler.

i will test that code when i have time(and a computer i could compile it on).

Using an 18" monitor, sitting about 50 cm from it. That's about 30 degree full top to bottom angle. And I don't want to sit any closer either, cause the monitor comes too close and it strains my eyes to focus so close for a longer time.

Not questioning your numbers, but with 45 degrees up and down, on a 19" monitor, you would have to have the eyes, like, 20 cm from the monitor...

This topic is closed to new replies.

Advertisement