View Full Version : Problem with polygon offset

Jaap van den Bosch
07-23-2008, 06:40 AM
I am having a bit of a problem with the polygon offset of a model I've created. I've made an urban model and I'm trying to display all the windows on top of the walls without having to cut out the windows. But somehow the offset function it isn't working like I thought. I think it has something to do with the size of the objects. All the windows are one big object as are the walls. No matter which values I enter (from sensible ones to extremely large ones) there's still some stitching occurring. There's also some correlation with the distance between the viewpoint and the objects's polygon offset behavior. For instance, when I find a value that works fine moving closer to the object makes stitching appear again (in a way that looks like the window is coming out of the wall at an angle).
In my opinion it has something to do with the size of the object. When I tried it with an object consisting of several planes and another object consisting of several planes in the same plane, the polygon offset function works like a charm. But this model with a bunch of windows which are not in the same plane is much more 3D than two flat objects. It is like the offset function is not calculating the values per polygon, but rather per object.
Am I using the offset function incorrectly? Or am I using it for something it wasn't designed for? Any help would be greatly appreciated!

Jaap van den Bosch
07-28-2008, 10:18 AM
...small kick...

Nobody has any ideas? I still don't have a clue as to where to look for a solution.

07-28-2008, 11:46 AM
You don't have the "enter" key on your keyboard?

Jaap van den Bosch
08-01-2008, 01:18 AM
I think my post is pretty well written. Did I violate some forum rule?

But back on topic: What could the solution be? Or is this more a question for the expert section?

08-01-2008, 05:58 AM
Well your post is hard to read, so it means that volunteering for helping you needs a lot more motivation than usual...

I believe you already read this thoroughly :

Something like this usually works well in a lot of cases :
glPolygonOffset(1.0, 1.0);

Be sure to apply it to the windows only, and not to the buildings.

Screenshots from near, medium, and far range please ?

And relevant code ?

08-04-2008, 04:29 AM
Correction, I think I had that reversed : apply it to the buildings only, and not to the windows.

Jaap van den Bosch
08-04-2008, 08:27 AM
Yeah, it's hard to explain a visual problem with just text. I made a small movie of the problem, you can find it here: http://archidimex.com/downloads/PolygonOffset.wmv
Together with my opening post it should be clear now what happens, although I'm still puzzled.

A polygon offset of -1,-1 does not seem to do the trick (applying 1,1 to the buildings results in the same effect). I'm not programming in OpenGL, but in Vizard (which uses OpenGL). However there is a command in Vizard, which applies the glPolygonOffset to an object. When I make a test script with just two squares the polygon offset works like a charm.

08-04-2008, 08:44 AM
It is not very clear in the video, but you seem to only change the first parameter 'factor'.
Try large offset values for both terms, 'factor' and 'units'.

Are you using an extreme case of very small near clipping plane and and very large far clipping plane ? That would also decrease the z precision.

Jaap van den Bosch
08-05-2008, 02:50 AM
The two sliders are factor and units. The clipping planes are set at 0.1 and 5000 meters, so that isn't that's extraordinary. Large values like -1000,-1000 result in much better behavior, but -1,-1 should work. I am sure the window planes are in the same plane as the wall....
I'm also puzzled by the fact that the window plane seems to come out of the wall at an angle.

Jaap van den Bosch
08-09-2008, 05:10 AM
small kick...

I've been playing around with some values, but with no improvements. Maybe it has to do with some OpenGL behavior about objects and subjects? Does anybody have an idea where to look next?

08-10-2008, 07:50 AM
I guess it has more to do with how your hardware rasterize polygons.