Can anyone explain glPolygonOffset?

Hi,

Can anyone explain what glPolygonOffset(factor, units) does and the influence of each parameter (factor, units).

Thanks,

Billy.

units is a constant offset in depth values, say, you run 24bit z, setting units to 1, should offset your depth values by 1/(2<<24) (in normalized device coords).

factor brings dependency on the depth slope into that offset. Z fighting of almost coplanar primitives becomes worse the higher their depth slope is. With factor, you can let the gl automatically adjust the depth offset according to that.

glPolygonOffset(0.0f,1.0f); will unconditionally offset all polygons by one.
glPolygonOffset(1.0f,0.0f); will offset polys with a depth slope of one (rotated 45° into the screen) by one, polys parallel to the eye plane it won’t offset at all.

Just play around with it a bit, for most applications a little mixture of both is good.

Thanks zeckensack for your reply.