HanWu

01-08-2011, 08:22 PM

May I know what is the maximum supported values of near and far clipping plane for the glOrtho function? What will happen if I specify a very big near and far clipping plane? Say the near and far clipping planes are -1000000 and 1000000.

Alfonse Reinheart

01-08-2011, 08:59 PM

What will happen if I specify a very big near and far clipping plane? Say the near and far clipping planes are -1000000 and 1000000.

Math happens.

The GL_PROJECTION matrix, whether orthographic or perspective, will transform points into clip-space. They then go to normalized device coordinate (NDC) space, where each coordinate is bounded on the range [-1, 1].

Therefore, whatever your pre-projection space is, the Z-range will be squashed down to [-1, 1].

Floating-point numbers only have so much precision. And while floating-point numbers retain much of their precision at the [-1, 1] range, they still only have so much to give.

When you start talking about numbers in the millions, you're probably starting to get close to floating-point precision limits. This is made worse when you have to put this into a depth buffer, which is typically 24-bits in size. You lose a bit more precision in the transfer.

But really, the question you need to ask yourself is this: what difference in depth do you need to resolve? That is, for a given numerical range, there is some minimum difference between two objects that, below which, it is OK for the two to be distinct. How close do two objects have to be before you stop caring which one is in front of the other?

Given your range, if that number is ~10 or so, I wouldn't be concerned. But if you need to distinguish objects to less than 0.1 or so with a plus/minus range of 1 million, I'd be concerned.

Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.