GlPolygonOffset whats the deal here? is it good or bad?

Started by
4 comments, last by zppz 18 years, 8 months ago
I am trying to draw lots of filled polygons with primitives ontop. I understand the opengl glpolygonoffset only works on filled polygons, but is this the only way to stop them from interferring?? surely there is a better way? Please help!!! Tom
Advertisement
The "better way" would be not to draw multiple polygons in the same location, any good reason why you can't simply avoid it?

The alternative to glPolygonOffset would be to do the decal math by hand.
Could you explain what you're trying to do in a little more detail?

The polygons need not be filled to use PolygonOffset.
you can use any of the following enums:

GL_POLYGON_OFFSET_FILL
GL_POLYGON_OFFSET_LINE
GL_POLYGON_OFFSET_POINT
Hi --

There are some performance reasons not to use glPolygonOffset. Since the polygon slope is factored into the actual distance that fragments are moved forward or backward in the z-buffer, fragments inside very steeply sloped (with respect to the camera) polygons can end up having a z value anywhere in the entire depth range. For this reason, hardware hierarchical z-culling algorithms have to be disabled or severely limited for regions in which polygons are rendered with glPolygonOffset turned on.

An alternative is to modify your projection matrix to perform a z-offset. You can read about this technique in Game Programming Gems 1, Section 4.1, or in Mathematics for 3D Game Programming and Computer Graphics, Section 9.1. Source code can be found here:

http://www.terathon.com/books/code/Listing9.1.txt
thank you very much, i actually own this book and will have a look next time i am at home.

Much appreciated

Tom
Quote:An alternative is to modify your projection matrix to perform a z-offset.
What a neat idea. Thanks for the link too.

This topic is closed to new replies.

Advertisement