Scale of things (part 3)

Started by
4 comments, last by JohnBolton 19 years, 6 months ago
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
Advertisement
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
You could use a higher scale, or you could use doubles instead. Or, you could do both.
I am the master of ideas.....If only I could write them down...
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).
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.
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.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement