PolygonOffset Error
I am implemeting simple Silhouette outlines, using PolygonOffset, as a lot of articles mention.
But the polygon fills seem to appear over the top of over-lapping polygons.
Example code that I'm using:
//Draw Silhouette
glEnable( GL_POLYGON_OFFSET_FILL );
glPolygonOffset( -3, -3 );
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
glLineWidth( 3.0f );
glColor3f( 0.0f, 0.0f, 0.0f );
glDisable( GL_LIGHTING );
Draw();
//Draw Fill
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glEnable( GL_LIGHTING );
glColor3f( 0.0f, 0.0f, 0.0f );
Draw();
//Draw Other
glDisable( GL_POLYGON_OFFSET_FILL );
Draw2();
I've tried using a range of values for glPolygonOffset, but it doesn't seem to help, any other ideas that I could try?
Hi MaliciousDigit, I tried
glPolygonOffset(0.0f, 1.5f); and glPolygonOffset(0.0f, -1.5f);
But it now shows the wireframe.
glPolygonOffset(0.0f, 1.5f); and glPolygonOffset(0.0f, -1.5f);
But it now shows the wireframe.
Use offset on Lines instead of Fill and set the number to something like 3.0 and 50.0
Remember to cull the right face at each drawing pass.
Remember to cull the right face at each drawing pass.
Offsetting the Lines was the first thing I tried, But I get a lot of lines that pop in and out as the camera moves. This mostly happens to polygons that are at 90 degree angles to the camera.
This doesn't happen when offsetting the Fills.
---
The poping seems to only occur when offsetting the lines backwards ( glPolygonOffset(1,1) ). I've experimented by moving the Lines Forward by -1, then the Fills by -3. Hopefully drawing the Fills above the Lines, but without the Lines too far Back to cause poping.
But it's still not looking right, is this even a viable option that I should keep experimenting with?
This doesn't happen when offsetting the Fills.
---
The poping seems to only occur when offsetting the lines backwards ( glPolygonOffset(1,1) ). I've experimented by moving the Lines Forward by -1, then the Fills by -3. Hopefully drawing the Fills above the Lines, but without the Lines too far Back to cause poping.
But it's still not looking right, is this even a viable option that I should keep experimenting with?
Yes it is viable. You are probably not culling the faces. When drawing fills, cull backface. And when drawing lines, cull frontface. If you just do that then unless you have geomtry that is very thin you won't even need polygon offset. Also try the numbers I gave you.
By doing that, I get the same effect as my first image, but with the Lines showing through instead of the Fills.
I have this similar set up already (With-out Polygon Offsetting), however, it doesn't work that well for concave meshes. I need to be able to draw, for example, a planar square, that's divided into a grid of triangles, without showing the complete wireframe, only the outside silhouette.
Using Polygon offset allows me to do this, but it doesn't looking right when polygons intersect.
I have this similar set up already (With-out Polygon Offsetting), however, it doesn't work that well for concave meshes. I need to be able to draw, for example, a planar square, that's divided into a grid of triangles, without showing the complete wireframe, only the outside silhouette.
Using Polygon offset allows me to do this, but it doesn't looking right when polygons intersect.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement