Take the 2-minute tour ×

I have a two coplanar polygons.

I tried doing.


and expected one to be distinctly "on top of" the other.

This is the case until about 70-75 units away (with a near clipping plane of 1, and a far clipping plane of 10,000). Then a region of about 50 units where there is z-fighting, and then the alternate polygon seems to appear on top.

Does the Polygon Offset get added before or after the normal z-calculations? If it was after, I would have thought it would have "just worked" at all distances.

Am I using the wrong values? Am I misunderstanding the expected results? Or should this work, and I am probably doing something wrong elsewhere?

I was afraid to try larger values, because there are other objects in the scene, and if the number was large enough, they could "jump" in front of those object too at far distances.

share|improve this question
add comment

2 Answers

I haven't used glPolygonOffset, but I just read up on it in the official FAQ -- required reading if you haven't already seen this. There is also the man page.

According to that reference, the offset is calculated after the normal Z calculations, but applied before the depth test and before being written to the depth buffer.

I can think of two issues. Firstly, the FAQ recommends you use glPolygonOffset(1,1), not (0,1). The first "factor" argument is multiplied by the slope of the polygon and added to the offset. This is apparently important for "edge-on" polygons. If the polygon is facing the camera, it doesn't matter, but if it is at an angle, the amount you need to push it forward increases with the angle.

Secondly, are you enabling the offset for just one of the polygons? If you have it enabled for both (or forget to disable it), then it will apply to both polygons, and have a net effect of zero.

Thirdly, I suspected that your depth buffer is too large (given that depth buffers have a hyperbolic scale which favours objects close to the camera). I'm not so sure about this, given that glPolygonOffset is supposed to work with depth values, not Z values (so the scale of the depth buffer shouldn't be a factor here). You might want to try it with a shorter depth buffer (maybe 1000) and see if that makes a difference.

share|improve this answer
add comment

You can try to set one polygon offset positive one offset negative, I bet that will work.

glPolygonOffset(0,1) and glPolygonOffset(0,-1)

share|improve this answer
add comment

Your Answer


