PDA

View Full Version : polygon offset and line smoothing



remdul
10-20-2005, 05:20 AM
Hi,

I'm doing two pass rendering to render polygon outlines over a mesh using polygon offset. This works fine.

However when I enable line smoothing this no longer works without clearly visible artifacts (z-fighting):

http://home.planet.nl/~buijs512/_temp/glprob.jpg

The only state change here is a glEnable(GL_LINE_SMOOTH) call. Line smoothing shouldn't be able to affect the way depth testing works, correct?

I thought this might be a driver problem, and I upgraded to the latest ForceWare drivers, but the problem isn't fixed.
The problem wasn't present with older ForceWare drivers (I believe 72.xx and older), and I do get correct results on some ancient Detonator drivers on other machines.

Can anyone confirm this is a driver bug/cheat or may there be something else that I could have done wrong?

SeskaPeel
10-20-2005, 08:04 AM
Line smoothing is implemented by the driver. nVidia renders smooth lines by displaying a small textured quad a bit larger than your 1 pixel line with alpha blend enabled.

Nothing you can do except plugging your own smoothing routine, or maybe trying to offset a bit more. Ho, and you could plug your own polygon offset routine too. Eric Lengyel has a chapter in his book about that (btw I never managed to make it work correctly, certainly due to my wrong implementation).

It's true for points too.

SeskaPeel.

[edit:] actually I managed to work this around by offsetting the mesh instead of the lines or the opposite, don't remember exactly.

remdul
10-22-2005, 09:02 AM
I managed to fix the problem by disabling polygon offset on the second (wire) pass. This is probably also also the correct way to do it, and I now have consistent results on various hardware/drivers.

It apears that on my drivers triangle primitives are implemented in a different way when glPolygonMode is GL_LINE and line smoothing is enabled.

When line smoothing is disabled the lines are not affected by polygon offset, and behave exactly like the regular line primives (which indeed, according to the spec, shouldn't be affected).

When line smoothing is enabled, I suspect its implemented (at least on my drivers/hw) as a filled triangle with a texture (much like mentioned in the above post) and also behaves like any other filled primitive, thus is affected by polygon offset.

Which in my case resulted in z-fighting, because on both passes the triangles where being pushed back.

SeskaPeel, thanks for the hint. :)

SeskaPeel
10-22-2005, 05:47 PM
np ...
I thought that you disabled your polygonoffset during one of your two passes ... but explaining things in depth sometimes puts you on the right way.
It was even simpler than what I thought.

SeskaPeel.