Nearly overlapping Quads causing Jagged Edges

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:


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
Posts: 5,143
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
Posts: 776
Joined: 2003.04
Post: #3
Also, make sure you are using a 32 bits z-buffer.
Quote this message in a reply
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