Sign in to follow this  
kamimail

the precision problem in 16 bit Z-Buffer

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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. [url="http://www.mvps.org/directx/articles/linear_z/linearz.htm"]here[/url]

I encountered a similar problem in my [url="https://play.google.com/store/apps/details?id=com.rowlhouse.picasim"]flight simulator[/url] - 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).

Share this post


Link to post
Share on other sites
[quote name='MrRowl' timestamp='1347622561' post='4980020']
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. [url="http://www.mvps.org/directx/articles/linear_z/linearz.htm"]here[/url]
[/quote]

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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this