glPolygonOffset(1,1) not sufficient?

Hi!

I am having trouble with glPolygonOffset, which leads me to the question if there are any cases where the offset generated by glPolygonOffset(1.0, 1.0) is too small (to prevent z fighting)?

WHAT I DO IN PARTICULAR:

  1. Render a “pushed-back” triangle mesh with glPolygonOffset(1.0, 1.0) to setup a GL_DEPTH_COMPONENT32F depthbuffer texture (FBO bound)

  2. Render the same Geometry as GL_POINTS with Pointsize=1 while using a vertex/fragment shader program

  3. In the fragment shader i manually calculate the depth of the rasterized one-fragmant point vertices and compare this depth to the depth value in the previously generated depth image.

WHAT I EXPECTED:
Since an offset should have been applied to the mesh in the first step i expect each point-vertex to have a smaller depth value and to lie in front of the filled mesh. Unfortunately some points don’t.

WHAT I TRIED:

  • Choosing glPolygonOffset(1.0,2.0) seems to do the trick for my current geometry - but i don not understand why and i suspect it won’t work for other settings (i need to be flexible here).

  • glPolygonOffset(1.0, 1.999) does not work for a single point more than (1.0, 1.0).

  • Since the “bad” points lie on a slope relative to the viewing direction i tried glPolygonOffset(10.0, 1.0), but this only works for very few points more than (1.0, 1.0).

Any help would be greatly appreciated - i am out of ideas…

See pages 20-26 here: Shadow Mapping with Today’s OpenGL Hardware (Kilgard, 2002)

But also see this (GlPolygonOffset whats the deal here? is it good or bad?) and this (glPolygonOffset units).

Ok, thats a nice explanation for the use of the slope parameter - thanks.

(1) So since i am rendering the scene twice using the same eye position and perspective setup it seems i do not need the slope-factor in glPolygonOffset at all, because each fragment depth should be computed at the exact same position right?

(2)However setting glPolygonOffset(0,1) or even glPolygonOffset(0,2) causes a lot of z-fighting along slopes… ?!?

(3)And still my question remains why glPolygonOffset(, 1) is not sufficient since an 1r offset should guarantee a distinct z in the depthbuffer according to the gl spec…

Meanwhile i will have a look at the modify the projection matrix - approach mentioned in your posted links…