Jump to content
  • Advertisement
Sign in to follow this  
Mekanikles

OpenGL Flickering edges in OpenGL

This topic is 3787 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

Hi, I do realize that this has probably been asked a million times before since I know it to be a common problem but I can only find solutions to issues related to texturing. My problem is that I get flickering edges when drawing adjacent surfaces. My surfaces use no textures, they're just phong shaded. The flickering appears as white dots that move around. I want to build a retro style level using building blocks that should appear seamless. Any help would be appreciated, thanx in advance /Mekanikles

Share this post


Link to post
Share on other sites
Advertisement
Don't think antialiasing is the problem here. if you read it carefully, he's getting flickering between polys, not jagged edges.

The first thing I would suggest is looking at your z-buffer resolution. If it's 16 bit right now bump it to 24 and see if that helps. Also, if you have two polygons that are meant to be connected, make sure that their vertices line up EXACTLY. Even an incredibly small offset can lead to rendering artifacts.

Share this post


Link to post
Share on other sites
Yeah, sounds like some form of z-fighting. You might also want to check your calls to glFrustum or glPerspective and see what your near plane is set to. If you've got it set to something ridiculously small (like 0 or 0.1) then you'll waste all your precision near to the camera. Push it out further and see if it helps.

Share this post


Link to post
Share on other sites
Thanx for the swift replies. However, I don't think my Z-buffer is the problem since the adjacent polygons aren't overlapping and I see white artifacts where two black surfaces connect. I do believe it's an precision problem though, that the two edges really aren't connecting properly due to subpixel faults when filling the surfaces. But I am putting the vertices of the surfaces on the exact same spot (I'm only dealing with integer map coordinates). I read somewhere that putting a small border on each surface to "fill up" the possible gap can solve it but then I would get Z-battling between those borders.

On a side note: Lots of less polished PS1 games had this problem so it seems to be rather common :-)

thxnx again /Mekanikles

Share this post


Link to post
Share on other sites
Use indexed primitives (indexed triangle lists or indexed traingle strips being the most efficient), and all these problems will instantly go away. But you could run into some issues with texcoords.

That said, you should not get any kind of sparkling along connected edges, if you really supply the exact same coordinates for connected vertices.

Try to post a screenshot of the artifact, that would help,

Share this post


Link to post
Share on other sites
A screenshot would probably help.

Are you possibly mixing the fixed function pipeline with shaders? That can cause even identical input coords to render to slightly different screen pixels (use the ftransform() function if you really want to mix the two).

Share this post


Link to post
Share on other sites
@Yann L: Hm, I'm not quite sure what you mean, does it pay to use indexed list for simple quads? (my level is made up by connected boxes).

Here's a screenshot anyway:
Screenshot of flickering egdes 2

It doesn't show an awful lot here, but when moving the view it flickers alot, sometimes whole lines of white along the edges. I don't know if the shader has something to do with it, the "white" dots change color from grey to white when moving the lights around, so they seem to be affected by the shader.

@OrangyTang: I do not quite understand what you mean but I am using the ftransform.

thnx /Mekanikles

[Edited by - Mekanikles on March 2, 2008 6:51:51 AM]

Share this post


Link to post
Share on other sites
Update: I've tried modifying the near clipping plane and the artifacts go down significantly (though never quite disappear). At a value of 10 they're almost gone, but that's way too high, I'm using around 1 now and it feels like that's as far as I can go. My far clipping plane is 300 btw if that's any help. I'm using relatively large coordinates where the columns in the picture are about 5*30*10.

Share this post


Link to post
Share on other sites
Well, from the image and near-plane description you gave, I defiantly think that it's what we were saying earlier: The vertices are not the same, numerically, so the subpixel calculations are causing overlap and, naturally, some z-fighting.

It sounds like you want them to be two separate meshes for some reason, so sharing an actual vertex may be impossible here. If that's the case, you will probably want to find a way of preventing the z-test from happening along that edge. If possible disable z-testing when drawing those elements, and if not try using polygon offsets: http://www.opengl.org/resources/faq/technical/polygonoffset.htm

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!