# Scale of things (part 3)

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

## 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 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 on other sites
You could use a higher scale, or you could use doubles instead. Or, you could do both.

##### Share on other sites
Quote:
 Original post by Nathaniel HammenYou 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 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 on other sites
Quote:
 Original post by MegelanSo 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.

• 21
• 16
• 9
• 17
• 13