z-bias formula

Hi guys,
I was wondering if I can get some help about
how hardware is implementing the zbias.
If i’m using a clasic zbuffer not wbuffer how is
the zbias applyed? Is it in homogenouse space
before w divide or in screen space after w divide?
Is it 1/(w + offset) or 1/w + offset ? I’m
considering that the offset is constant per pixel.
If the offset is not constant per pixel inside a
primitive what is the offset formula ?
Regards.

Hi.

The offset is done in screenspace, and it is constant for each polygon. See the spec, sec. 3.5.5.

Regards, Jonas

Hello,
Using the following formulas for calculating the
offset: offset=m*sloapFactor + r * unitsFactor, where m is the maximum z sloap and the r for the an integer zbuffer is one whats the sense for sloapfactor ?

Regards.

I mean if you render a sphere at resolution 640x480 and take a zbuffer picture and after
you render the sphere at 800x600 and take z pictures the zvalues for the 2nd sphere will be
greater than the first sphere (the sphere remains
at the same position in camera space) considering that the sloapScale >= 1. Thats because the m will be grater in the 2nd case since m = max(abs (dz/dx), abs(dz/dy)) (2nd sphere dx is greater than 1st sphere dx).

m for the second sphere(at 800x600) should be smaller, since dx is larger and the denominator :slight_smile:

Your observation, is as I see it, correct. The offset does depend on the resolution.

To see why this is desireable, consider shadow mapping - nvidia has a presentation about it, which explains the details. (Its a bit hard to explain, and can be tricky to understand)

Slope factor is there because rendering has rounding errors and these impact what interpolated fragment depth you end up with. The steeper the derivative of z for a polygon the greater the potential z sampling error is due to transformation precision, subpixel rounding, interpolation precision, eye z precision etc. A fixed offset cannot compensate for this on a polygon with varying orientation. Basically the steeper the slope in z the more offset you need, but you don’t want excessive offset when the derivative of z is low.

The offset gives you two values, one is a constant offset for when the polygon is orthogonal to the viewer, the other is an additional offset as a multiplier on the derivative of z to increase the offset as z interpolation increments increase and z rounding and interpolation errors increase.

Thanks a lot guys, that makes sense.