Realistic terrain rendered in real-time

A shader I wrote to realistically render terrain with bodies of water.

It's a ray marcher, where rays are cast from the camera and move in small steps towards the terrain. At points where rays intersect the surface of water, a reflection and refraction ray are cast, and their contribution gets added to the final result.

The effects of light scattering and absorption are also recreated in this shader. Within the water, light gets absorbed gradually, and above the water, light scatters as it travels through air, obscuring distant objects.