How Games Fake Underwater Worlds: Fog, Color Absorption and Caustics
If you try this in PUBG or any game, swim close to the surface and place your camera half above water, half below it. This is not possible, because there is an instant transition between worlds without any intermediate stage.
This is not a bug; rather, it is the inevitable consequence of the way in which the water in games is modeled, and here you will find the secret of any underwater scenes in games. In this post, we will explain step by step how game developers create the illusion of being under water.
This post is the continuation of our previous post about how game developers create the surface of water using sine waves. You should definitely check it if you did not yet.
The Big Secret: Water Is Just a Sheet
Most often in games, water isn't a volume. Rather, it is a sheet of surface animated by sine waves. And there is nothing behind this sheet – just empty space.
But then what about the underwater view when you jump into the water? The trick is that when your camera passes below the surface, a number of special effects are activated to be applied to the camera rather than to the world. Combined, these effects create an impression that you are diving under water.
These effects are as follows:
1. Depth-based fog
2. Color absorption (Beer-Lambert law)
3. Wobble/ripple distortion effect
4. Caustics
5. Underwater props (foliage and fish)
Now let us discuss these effects one by one.
Effect 1: Depth-Based Fog
Your camera knows the distance from itself to each and every pixel. The depth values are already computed for you during the rendering process, so the game takes this opportunity to blend all pixels towards water color based on their distance.
The key thing here is that the fog increases exponentially, rather than linearly. A typical equation looks like this:
fogAmount = 1 - exp(-density * distance)
Nearby objects stay clear, and distant objects fade quickly into a hazy blue-green. This single effect already makes a scene feel like it is underwater.
In Unity, you can switch on built-in fog when the camera goes below the surface
Notice the condition transform.position.y < water.position.y. This single comparison is why the camera can only be in one state at a time, and we'll come back to it at the end.
Effect 2: Light Absorption and the Beer-Lambert Law
In nature, the absorption of light colors varies; red is absorbed first, followed by orange and yellow. Blue and green are absorbed last, and that is why deep water appears blue.
It is explained with the help of Beer-Lambert law, which states that light intensity diminishes exponentially as it moves through a medium. In games, it is applied independently for each color channel:
This creates an effect where the colors of nature become teal or blue when viewed in the distance while the reds disappear. It is a small example of real physics in action, and it greatly enhances realism at virtually no expense.
Effect 3: The Wobble
Waves of light distort as they pass through flowing water, resulting in objects underwater appearing wavy. Games simulate this by warping textures in screen space using sine waves once again.
The basic principle here is to distort the texture coordinates of each pixel using a time-varying sine function:
Keep the amplitude small. A subtle wobble feels like water, while a strong one just feels like a drunk camera.
Effect 4: Caustics
Caustics are the bright, shifting light patterns you see on the sandy bottom of a pool. They happen when sunlight is focused by the moving water surface.
Simulating this properly would need ray tracing through the water surface, which is far too expensive. So games fake it with two moving textures: a caustic pattern texture is projected onto the scene as light, and the same texture is scrolled in two different directions at different speeds. The two layers combine, and their patterns constantly slide past each other, creating that familiar shimmering effect.
It is the same trick used for the water surface itself: two scrolling textures that never line up.
Effect 5: Foliage and Fish
The last step is not math, it is set dressing. Add underwater plants swaying gently, schools of fish, floating particles and a sandy or rocky floor, and the scene stops looking like a foggy room and starts looking like a believable underwater world.
Plants can reuse the sine wave idea again: sway their vertices with a sine function based on height so the tips move more than the roots.
Why You Can't Be Half In and Half Out
Now we can answer the original question. All five effects, fog, color absorption, wobble, caustics and the set dressing, are applied to the camera when it is below the surface. Above the surface, they are off.
It is a switch, not a gradient. The camera is either underwater or it isn't, and the game has no concept of a camera that is partly in both. When you try to hold the camera right at the waterline, you get a broken, flickering view because the game keeps toggling between the two states, or shows the water sheet cutting through the screen.
Some games work around it with a screen-space waterline effect that draws a line across the screen and renders each half differently, but it takes extra work and most games skip it.
Key Takeaways
- Game water is usually a thin surface with nothing beneath it, not a volume of liquid.
- Underwater looks are created by effects applied to the camera lens, triggered when the camera drops below the surface.
- Exponential depth fog blends distant pixels toward a water color.
- Beer-Lambert absorption removes red first, then orange and yellow, so distance turns things blue-green.
- A sine-wave wobble distorts the view, and two scrolling textures fake caustics.
- Because it is a camera-state switch, a view that is half in and half out does not work properly.
FAQ
What is the Beer-Lambert law in games? It is a physics rule stating that light fades exponentially as it travels through a medium. Games use it to make colors disappear with distance underwater, per color channel.
What are caustics? They are the bright, moving patterns of light on surfaces under water, caused by sunlight bending through the wavy surface.
Can I do this in Unreal Engine or Godot? Yes. The techniques are engine-independent. Use a post-process material or shader for fog, absorption and wobble, and a projected or decal texture for caustics.
Do I need to write shaders? For a simple version, no. Built-in fog and a post-processing volume get you most of the way. Shaders give you control over absorption and wobble.

Comments
Post a Comment