Jump to content

  • Log In with Google      Sign In   
  • Create Account


gluPerspective - Near & Far problems


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 polar01   Members   -  Reputation: 114

Like
0Likes
Like

Posted 23 December 2010 - 08:28 PM

Hi,

I currently use the following code to set up my perspective.

gluPerspective(45, aspectRatio, 0.1f, 1000.f);

The problem is that with large objects, or very small one... I see nothing.

If I update the near/far planes... I got precisions problems with the gluUnproject etc...

So, can you tell me how you handle this ?

Thx

Sponsor:

#2 V-man   Members   -  Reputation: 805

Like
0Likes
Like

Posted 25 December 2010 - 08:02 AM

I imagine you are doing what seems to be common: using the depth buffer to select object. Use another solution like an math library to do a ray cast intersection test.

Your large objects have a large radius like 1000 and more?
There is a special matrix for this case.

#3 polar01   Members   -  Reputation: 114

Like
0Likes
Like

Posted 27 July 2011 - 12:59 AM

Does someone has an idea to solve the problem. Far and near plane are important, so they depend of the scene (size of the scene).

- I can use the scene bounding box to change/compute the far/near plane ?
- Have you experimented this ? There is no side effect ?

Thanks
--------------------------------------------------------------------------------Aurora Studio - PureLight - Animation & rendering software and API.http://www.polarlights.net

#4 Aks9   Members   -  Reputation: 826

Like
0Likes
Like

Posted 27 July 2011 - 03:59 AM

The problem is that with large objects, or very small one... I see nothing.
If I update the near/far planes... I got precisions problems with the gluUnproject etc...

Actually you don't see polygons in front of near and behind far clipping planes. It is normal, since clipping planes define view frustum.

There are many techniques to handle large scenes. I suggest you to split your scene into several parts by distance/size each with its own near/far clip planes. Try to keep far/near ration less or equal to 10e5.



#5 Hodgman   Moderators   -  Reputation: 29725

Like
0Likes
Like

Posted 27 July 2011 - 04:28 AM

It's very important to set your near plane out as far as possible. The value used for the far plane is much less important.

Very small relative near-plane numbers (like 0.1m compared to objects that are 100m away) cause lots of precision problems.

If things start disappearing because your near-plane value is too large, you can always compensate by moving the 'camera' position backwards.

What units are you currently working in (metres, centimetres), and what size scenes are you trying to render?

#6 Brother Bob   Moderators   -  Reputation: 8089

Like
1Likes
Like

Posted 27 July 2011 - 05:43 AM

Very small near-plane numbers (like 0.1) cause lots of precision problems.

A near plane at 0.1 is, in itself, nothing wrong at all. It's all about the relative scale of your scene. The advice itself, that a very small near-plane distance is bad, is very much correct, but when the actual value is entirely dependent on the scale of the scene, then giving an example of a small value can be a very dangerous, and perhaps outright wrong, piece of information.

What matters are the ratios of the distances between the near plane and the objects of interest, not the value of the near clip plane alone.

#7 Hodgman   Moderators   -  Reputation: 29725

Like
0Likes
Like

Posted 27 July 2011 - 06:04 AM

A near plane at 0.1 is, in itself, nothing wrong at all.

Edited my previous post to make it less misleading. Check out the graphs on this page - they show how when using smaller 'near' values, how the precision-distribution curve becomes much steeper at the near end.
As a general rule of thumb, the near plane value should be as large as possible, while the value of the far-plane is much less important.

e.g. in your situation, by changing the near value from '0.1' to '1', your z precision in the range between 1unit and 1000units will be approx 10x better.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS