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?
|
|
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). |
|||||||||||
|
|
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. |
|||
|
|
|
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. |
|||||
|