Depth Biasing

Started by
4 comments, last by MJP 10 years, 10 months ago

Is there a way to depth-bias without affecting the final depth result?

I want the results of the biasing with depth-testing, but without modifying the original depth value.

Advertisement

There may be a much easier way to do this (rendering isn't my strong suit), but you could render your scene (a second time) to a render target - storing the biased depth values in one of the colour channels.

It depends on the type of depth bias you are doing. There isn't an easy way to do this directly with the depth buffer, so I think you would have to render normally for the first pass to fill the depth buffer, and then use the contents of the depth buffer to produce a depth bias. So whatever pass you are doing to make use of the depth bias could just read from the depth buffer and apply the bias then and there instead of applying it to the buffer contents during creation.

If you only need the data in one pass then it would be a simple matter of transforming a vertex a second time in the vertex shader by the WVP matrix with a depth bias added. The result of that could then be passed on to the pixel shader where you can play with the biased value, while the pixel will be rendered in it's un-biased position by the first transform.

I'm using a deferred renderer. Right now I'm storing both the biased and unbiased depths, and passing them through. The biased version is stored in the depth buffer, but the unbiased version is taking up one of my G-buffer components.

I really want to get rid of it so I can squeeze more data out of my G-buffers.

Is there a way to depth-bias without affecting the final depth result?

I want the results of the biasing with depth-testing, but without modifying the original depth value.

No, unless you're okay with multiple passes or storing depth somewhere other than the depth buffer. The depth value used for depth testing is always the same as the value written to the depth buffer.

This topic is closed to new replies.

Advertisement