the precision problem in 16 bit Z-Buffer

Started by
5 comments, last by MJP 11 years, 7 months ago
Hi ,all:
I am working at a project that aims to develop a virtual globe system by using WebGL.
We have made the system work, but there is z-fighting problems.
I have heard from others that there exists a solution that use a perspective projection matrix,a matrix different from the projection matrix used in the OpenGL,which can resolve/relieve the precision problem.
Does anyone known the equation of the projection matrix? Thank you very much!
Advertisement
Just out of curiosity, why do you not use a 24 bit zbuffer ?
Hi Ashaman73,
Some browsers only provide the 16 bit depth buffer for WebGL application.
I've never used WebGL, but it seems to support vertex shaders, so you could modify the depth value there - e.g. scaling to generate a linear depth (or something in between). E.g. here

I encountered a similar problem in my flight simulator - Tegra 2 devices only provide a 16 bit depth buffer. I ended up dynamically adjusting the near plane, so when the camera is away from the terrain the near plane is quite far, which reduces z-fighting in distant objects. The near plane distance is reduced as you get close to the ground in order to prevent seeing through the ground (fortunately the ground then tends to obscure view of the z-fighting artefacts happening far away).

I've never used WebGL, but it seems to support vertex shaders, so you could modify the depth value there - e.g. scaling to generate a linear depth (or something in between). E.g. here


I wouldn't recommend that, it really f**ks with your rasterization.

There's no magic tweak that I know of that will fix the precision issues of a 16-bit integer depth buffer. In the past people dealt with it by just moving up their near plane as far as they can bear it, and also pulling in the far plane if possible. With floating point depth buffers you can flip the clip planes to try to "balance out" the precision, but with an integer depth buffer you don't want to do that.
MJP ,MrRowl,Thanks for your reply.
I don't really understand why the w-compensation method suggested by MrRowl will has negative effect on the rasterization.would someone can clarify it to me ? Thanks!
There's an explanation here: http://forum.beyond3d.com/showthread.php?t=52049

This topic is closed to new replies.

Advertisement