Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have downloaded completely different samples with water effects (in XNA) and I've noticed that they all exhibit a common problem: when the camera direction (only the direction, not the position) moves, a noticable and annoying flicker occurs where the water meets terrain. I'm curios to find out more about this. Why does it happen? Does it have a name? And what can I do about it?

share|improve this question
Wild guess: maybe your near plane is too close to the camera. This limits the effective resolution of the Z buffer. – Jimmy Feb 10 '12 at 14:01
Could you link to one of these samples? – David Gouveia Feb 10 '12 at 14:19

It's named Z-fighting. You can google a lot information about it. For example here on wiki. In short: your water and terrain plane are in the same distance from camera (they are coplanar). If you move your camera (direction), float results differ a bit, so sometimes (I mean: some pixels) it chooses water to be drawn, sometimes it chooses terrain.

And you can solve this problem easily - just move your water plane a bit above or under the terrain, if they have the same "height" (they are coplanar).

share|improve this answer
But the terrain and the water are not "particulary" coplanar. I've tried to put spheres in the water with 1/4 of them abouve the water and got the same effect too? Althogh I may really be plain z-fighting I'm seeing (which I do know about) - I have no clue on how to fix tihs (and neither have the authors of those effects I've tried, I gusee. Or it doesn't bother them...) – danbystrom Feb 10 '12 at 13:43
The above guess is probably the best one given the details we have. We need a picture or video – brandon Feb 10 '12 at 14:22
No. It is not Z-fighting. If it were Z-fighting I would see it on pixel level. But the effect I asked about (and see in several samples) seems rether to happen on a vertex level. Once I figured out how to do recording I'll be back! – danbystrom Feb 11 '12 at 20:47
You can use this online service for recording apps or desktop: – zacharmarz Feb 12 '12 at 8:11

It is floating-point prcision error, you can fix that by not changing view matrix, if it has change only for little, if X or Y mouse rotation is less then 0.1 then use old view.

share|improve this answer

This problem can also be solved by using a logrithmic z-buffer which can be done in your shader, and is very very easy to implement.

share|improve this answer
More details would make this a better answer. – Byte56 Apr 8 '12 at 15:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.