Sign in to follow this  

Scale of things (part 3)

This topic is 4823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello ! I used 1.0f = 1 unit = 1 inch for my OpenGL games. But when creating a 2000 meter terrain with that unit the terrain is 80000.0f wide. This results in flickering on on far away polygons. I think cause the zBuffer calculations are not very accurate with such high floating point values, am I right ? :) So I better set 1.0f = 1 unit = 1 meter or what do you think is best solution for this problem ? :) Best greetings, Megelan

Share this post


Link to post
Share on other sites
I heard about a similar problem from someone a few months ago. Basically at the extremes (objects at the maxs of scale; 80000.0) your reducing your floating point precision because most of the 32 bits is being used to represent the integer portion of the value. So it could very well be the zBuffer issue you think it is. I would suggest trying a test of the other scale and see if it works.

--Ninj4D4n

Share this post


Link to post
Share on other sites
Quote:
Original post by Nathaniel Hammen
You could use a higher scale, or you could use doubles instead.

Dosn't OpenGL only use floats, internally? Or at least most graphics hardware? This might be a good solution for some cases in unit positioning (read: might) but this will only cause slowdowns if the OpenGL API does use floats internally (well, the windows DLLs that usually implement it anyways - the driver interface for your graphics card which does the actual work - which also might be using floats, no wild guesses even on that though).

Share this post


Link to post
Share on other sites
The absolute scale doesn't matter when it comes to the Z-buffer. Just keep the relationship between the near and far plane within reason. One rule of thumb is that the ratio should be about 1:1000. So if your far plane is at 80000, the near plane shouldn't be much below 80 units.

Share this post


Link to post
Share on other sites
Quote:
Original post by Megelan
So I better set 1.0f = 1 unit = 1 meter


Expanding on what Fingers_ wrote:

The problem is not the units or the scale, the problem is the distance to the near plane. The ratio of the distance to the farthest object and the distance to the near plane should be around 1000 (just a rule of thumb).

Note that the distance to the far plane has very little effect on Z-buffer resolution. In fact, a common technique for drawing shadows requires that the far plane is at infinity.

In summary, to improve Z-buffer resolution, place your near plane as far from the viewpoint as possible.

Share this post


Link to post
Share on other sites

This topic is 4823 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this