_x57_

01-06-2010, 10:12 AM

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...

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...