Nearly overlapping Quads causing Jagged Edges

Apprentice
Posts: 17
Joined: 2005.08
Post: #1
Hi guys,

Im slowly fumbling through OpenGL and was wondering if anyone had some advice on my current problem.

Im slowly building up a basic heightmapped terrain engine. I have taught myself much from the red book, but Im still vague in some areas.

My particular question is: Where the terrain flattens near zero, I have a temporary Water quad that spreads across the whole map (at height 8).

Strangely, when I look at the water from afar where it meets the heightmapped terrain I get this effect:

[Image: shot23jm.th.jpg]

I've tried to fix it with blending (i.e. trying to make the water translucent) but I still get the nasty edges.

Any other ideas?
Quote this message in a reply
Luminary
Posts: 5,125
Joined: 2002.04
Post: #2
It's called "z fighting", and it occurs because there's too little precision in the z buffer to distinguish consistently between your nearly-parallel quads.

The amount of precision in the depth buffer is affected by the ratio of the "far" and "near" parameters to gluPerspective. Reducing that ratio (either decrease "far" or increase "near") will give you more precision.

In general though, you're much better to avoid having intersecting geometry.
Quote this message in a reply
Moderator
Posts: 766
Joined: 2003.04
Post: #3
Also, make sure you are using a 32 bits z-buffer.
Quote this message in a reply
Apprentice
Posts: 17
Joined: 2005.08
Post: #4
Bumping up the Z Buffer worked a treat. Now I just have to get this whole Alpha blending thing down so I can make the "water" a bit translucent.

Thanks for the tips Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Create Aquaria-like terrain- texturing edges AndyKorth 3 5,365 Jul 31, 2011 08:13 PM
Last Post: FlamingHairball
  [SOLVED]OpenGL edges of textures mk12 2 3,633 Sep 2, 2010 08:07 PM
Last Post: mk12
  Replacing edges with degenerate quads (for shadow volumes) Coyote 9 6,419 Jan 15, 2010 07:08 PM
Last Post: Coyote
  Tricks with dialog boxes in fullscreen mode causing permanent framerate drops. Sea Manky 2 2,651 Aug 7, 2007 06:20 AM
Last Post: Sea Manky
  One texture... multiple quads? Jones 6 4,163 Jul 12, 2006 01:14 PM
Last Post: kordova