Why non-linear depth buffer?
Members - Reputation: 885
Posted 27 June 2009 - 11:40 AM
Members - Reputation: 852
Posted 27 June 2009 - 11:57 AM
If two objects are 2.5 or 3 depth units apart and they're right in front of you'll be able to tell the difference between 2.5 and 3. If they're 10000 depth units away you probably won't be able to tell the difference between 2 and 20 units apart because they're probably tiny. Hence, better to have more resolution up close where it matters.
Moderators - Reputation: 29435
Posted 27 June 2009 - 08:35 PM
The results of these graphs did scare me quite a bit - in a common case in our game engine, 90% of the precision was used to store the first 10% of possible depth values.
Seeing that I'm currently working in very low bits-per-pixel, I've got to be very careful about the near/far plane values in order to get a usable linear map out of the Z-buffer. If I had the choice of using a W-buffer, I'd definitely give it a try.
Members - Reputation: 223
Posted 28 June 2009 - 08:42 AM
Members - Reputation: 191
Posted 28 June 2009 - 09:09 AM
While W is linear in view space it's not linear in screen space. Z, which is non-linear in view space, is on the other hand linear in screen space.
hmmm. Isnt it the other way around?
In regard to Directx, View space is the world/view matrix, right? so any position value linearly increases as it gets further away from view.pos.
Where as screen space is world/view/proj matrix right? the result after pos.z/pos.w, which is a non linear curve for the z value.
what am i missing here? :P
Members - Reputation: 291
Posted 28 June 2009 - 09:10 AM
think of a 16bit depth buffer with near,far values of 1,10000 (pretty typical)
with linear depth thats only accurate to ~0.16 which is visually gonna lead to terrible zfighting on screen
Crossbones+ - Reputation: 2261
Posted 01 July 2009 - 01:19 PM
The fact that you get more z precision closer to the near plane is just a side effect and has nothing to do with the motivation behind 1/z interpolation.
I work on this stuff: C4 Engine | The 31st | Mathematics for 3D Game Programming and Computer Graphics | Game Engine Gems | OpenGEX