View Full Version : polygon offset
I don't think I understand the concept of this function, why doesn't it just subtract a bit from the depth value when writing to the depth buffer?
The polygons I'm trying to outline are at a steep angle, over 45 degrees. I don't see any difference with the offset enabled, the outlines I'm drawing are stitching like you'd expect without the offset.
09-22-2004, 03:06 PM
Just subtracting a bit to the z value is not sufficient to solve the problem. The precision varies with depth and derivatives and the zbuffer errors change in magnitude with the depth and slope of the fragments.
In addition the amount that needs to be added depends on the hardware precsions.
So, one of the terms is the depth amount you are talking about but corrects for hardware where 1.0 is the equivalent of the minimum offset required. The other is an ammount which varied with the polygon slope and is basically the pixel to pixel delts z.
Your values of 1,1 are good choices but you should use 1.0f, 1.0f since it is clear then that this function takes floats.
Your problem seems to be that you are using polygon offset but apparently drawing lines. This is bogus, offset applies to polygon fill only. Try enabling GL_POLYGON_OFFSET_LINE but again this depends on exactly how you are drawing the lines.
A better approach may be an negative signed offset the other way when you draw the original filled polygons.
Thanks, that was it. I was drawing with GL_LINES and not polys in line mode.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.