gluPerspective

Started by
3 comments, last by laeuchli 22 years, 5 months ago
What should I set parameters of this function to? I keep getting zfighting, and things disapper to quickly when I get close to them. I''ve tried changing znear, but it doesn''t help much. What values do you all use???
Advertisement
It''s the ratio between near and far that is the most important. I try to make sure that (far == 100 * near). That seems to be adequate in most cases.
Kippesoep
Here''s a part of my post in the Draw Distance thread, hope this helps.

gluPerspective( fov, ratio, near, far );

fov - this variable is the field of view (you probably know this) to either side of center, so it''s half of the total field of view. So if you wanted the fov to be 90 deg, then you would set this to 45.

ratio - the aspect ratio of the screen, this is just width/height, I would suggest using your resolution in that ratio, but 4/3 (1.3333f) should work for most standard resolutions.

near - the near clipping. This is how far from the camera an object must be to still be drawn on the screen. Set this to a very small value, I had it at 0.1f.

far - far clipping. This is how deep the depth buffer will be. If you''re going to use a skybox and you want each polygon to be 50 units away from the camera, you will need to set this at least to the square root of triple 50 squared (I''m assuming you know the pythagorean theorem and probably trigonometry too) to prevent the corners from being clipped. So, for a distance of 50, you''ll want to set this to at least 87.
about the skybox its not important how big it is,
because the skybox doesnt contain depth info.
u are correct that the values have to be within near-far range though.
Ummm if say your skybox is 50 units away from the camera at the center of each polygon, and your far distance is closer than 86.something, then you will get the skybox clipped, so yes, it does matter how far away things are clipped for your skybox.

This topic is closed to new replies.

Advertisement