Terrain / "water" texture depth/rendering problem


I made simple flat terrain with river. I added filler texture and i have encountered some graphical issues (it is same if i use simple unity water). I appended 2 images. Left is game view and right is scene view (issue appears identically in both views).

If camera is directly above terrain (looking down), everything looks ok (though, when i sam moving camera vertically, water is fluctuating up and down). (Scene view is not directly top down, you can already see rough edges).


When i add some angle to camera, everything looks broken, unless i am certain distance from the terrain.


How does Unity decide? What is wrong here?

This is because of floating point arithmetic. Any non-integer value tends to be floating point, which is very inaccurate. As you get further away from these objects, the visible distance between them becomes less, and errors crop up in the z-buffer. Transparent objects are particularly prone to sorting errors too, since they can’t be directly written into the z-buffer. As for how to fix it, you can reduce the clipping range of your camera - either increase the near clipping plane, or decrease the far one. This shorter range allows for the z-buffer to keep more accurate depth values after projection, so you don’t get the same artefacts.