Friday, June 18, 2010

Water Fog

I've added a new feature to my terrain shader that accounts for depth when rendering portions of the terrain that are underwater. Because the water "plane" has a constant alpha value, the deepest part of a body of water is just as visible as the ground that's only covered by a few inches of water. In reality, bodies of water such as lakes and oceans have dirt and other particles that obscure light from reaching the bottom.

My approach to this problem is basically just per-vertex fog. Instead of interpolating colors based on distance from the camera, the shader uses the 'y' coordinate of the vertex in world space, and calculates its distance below the surface. This simple effect definitely gives the water a more realistic sense of depth.

Without Water Fog

With water fog

No comments:

Post a Comment