Sign in to follow this  
Johnny123

PolygonOffset Error

Recommended Posts

Johnny123    115
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. Photo Sharing and Video Hosting at Photobucket 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?

Share this post


Link to post
Share on other sites
GamerYZ    169
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.

Share this post


Link to post
Share on other sites
Johnny123    115
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?

Share this post


Link to post
Share on other sites
GamerYZ    169
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.

Share this post


Link to post
Share on other sites
Johnny123    115
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this