Jump to content
  • Advertisement
Sign in to follow this  
Johnny123

PolygonOffset Error

This topic is 4137 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
Hi MaliciousDigit, I tried

glPolygonOffset(0.0f, 1.5f); and glPolygonOffset(0.0f, -1.5f);

Photo Sharing and Video Hosting at Photobucket Photo Sharing and Video Hosting at Photobucket

But it now shows the wireframe.

Share this post


Link to post
Share on other sites
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!