What it is
POLYSEA is a naval strategy game we are building (Unity 6, URP). This post is about the "moving fog" we gave it: a ship ploughs a furrow through the fog as it sails, a broadside blows it away, a cannonball leaves a thin tunnel behind it, an explosion blasts a hole, and then the fog slowly closes back in. Below is a night battle with the fog about 5 metres deep.
22:00, four English ships against three skeleton ships. Hulls, muzzles and cannonballs in flight cut dark channels through the fog, and at the 10-second mark a skeleton ship blows up.
How it started: a post about the fog in Ocarina of Time
On 8 November 2026 we came across two posts on X by KANA (@KanaWorks_AI). The one from 6 November said he had recreated in Godot the "moving fog" he had seen in the remake of The Legend of Zelda: Ocarina of Time: a spin kick clears a round patch, and the fog it pushes away piles up at the edge and then drifts slowly back. The post from 8 November explained how it was done. The main points:
- No 3D shape of the fog is stored, only one 2D map of how thick the fog is (32 metres square, 10-centimetre cells, 320×320);
- Cold fog is heavier than air and spreads along the ground, so it can be treated as a shallow layer of water and updated on the GPU every frame with the shallow water equations;
- Only a thin layer, up to 1.25 metres above the ground, is ray marched, in 16 steps per pixel;
- The fine pattern of the fog moves with the flow;
- The usual way to solve incompressible fluids (Stable Fluids) cancels the outward push in its pressure projection, so no hole opens; that is why he switched to the shallow water equations.
We wanted to know whether this would work in a sea battle, and started a test that same evening. We do not know what technique the remake itself uses. What follows is the approach KANA published, and how we implemented it in POLYSEA.
The fog we had before
POLYSEA already had a fog weather, drawn in a full-screen "atmosphere" overlay: five points along each view ray give a haze that thins with height, and drifting noise patches are laid on top. From the chart's height it is an even, thin veil, and nothing changes when a ship sails through it.

Left: the fog we had before. Right: the first version of the flowing fog. Same game, same moment, same camera; only one switch differs.
Step 1: the fog is just a thickness map
- The sea within a 1024-metre square around the camera is cut into 512×512 cells, 2 metres each. KANA's scene is a person walking on the ground, so 32 metres is enough; we look down on ships from the height of a chart, with hundreds of metres of sea on screen, so our cells are much bigger.
- Each cell holds four numbers: the fog's thickness, its east–west speed, its north–south speed, and the fine pattern of the fog surface in that cell (more on this later). The whole map is one floating-point texture.
- When the camera has moved more than 120 metres, the map is shifted by whole cells, and the newly exposed edge is laid with fog as the weather says.
- The weather decides what the fog "should" look like: a 4-metre sheet over the whole sea, with patches about 260 metres across and up to 20 metres thicker on top, drifting slowly with the wind.
Step 2: treat the fog as shallow water
Every frame, every cell is updated once on the GPU (in a compute shader), with steps of at most 1/30 of a second:
- Carry it along its flow: each cell traces backwards to find where the fog that is now here came from;
- Thick fog runs into thin. Fog is only slightly heavier than air, so this force is kept very weak;
- Where the flow spreads out the fog thins, and where it gathers the fog heaps up;
- The wind slowly drags it along, and its own motion slowly dies away;
- Left alone, it returns to what the weather lays down with a time constant of about 28 seconds, so a hole takes most of a minute to close;
- Its edges are blurred a little and its flow is smoothed a little. These two were added later; the reasons are under "What went wrong".
Step 3: what pushes the fog
| Source | How it pushes | What you see |
|---|---|---|
| Ships | Three circles along the hull (bow, waist, stern) push outward by the ship's speed and thin the fog inside them | The bow shoves the fog aside and the stern leaves a furrow whose rims bulge and slowly close |
| Muzzles | On firing, a cone about 24 metres long pushes along the line of fire | A broadside combs streaks through the fog |
| Cannonballs in flight | Each frame, the segment from the ball's last position to its current one pushes the fog aside and thins it; a ball higher than 30 metres leaves the fog alone | A thin tunnel along the trajectory that closes within a few seconds |
| Splashes and hits | A small outward push | A small puff where the water splashes |
| Explosions | An outward blast whose strength varies by direction with noise | A large hole with a ragged edge |
Every frame these pushes are packed into one list and handed to the GPU, up to 160 of them. Ships push all the time; shots, cannonballs and explosions push once.

Left: only the muzzles push the fog. Right: with cannonballs in flight added, each trajectory leaves a thin tunnel in the fog.
Step 4: drawing it
The fog is drawn inside the existing full-screen overlay; no new models were made:
- For each pixel on screen, the view ray is followed from the top of a 40-metre layer down to the sea and cut into 16 segments;
- The thickness map is read once at each end of a segment, the fog top is taken to change linearly in between, and the amount of fog the segment passes through is computed exactly with a formula. No points are picked at random, so there is no grain;
- The top of the fog is not a sharp plane: the thicker the fog, the more of its height it takes to fade out (half its thickness), so it reads as soft billows rather than a slab;
- The more fog lies overhead, the darker it gets, which gives the fog depth;
- The fine pattern on the fog surface is computed per cell in the simulation and carried by the wind and the fog's own flow. To keep it from being stretched out of shape, three sets of pattern coordinates are reset at staggered times and blended by weight, a method KANA described in his post;
- With the flowing fog switched off, the picture is exactly what it was before.

A close-up after the fixes: the edges of the furrow a ship cuts are soft.
What went wrong
The same night the first version was ready, we recorded a before-and-after video; the verdict was "not bad, but it needs tuning". From there we worked through the problems one by one, from screenshots taken in the game.
1. The fog looked like slabs, with "curtains" hanging from the edges
There were two causes. First, the top of the fog had only a 6-metre soft edge, so thick fog became a flat-topped slab and the border between thick and thin became a wall. Second, the shallow water equations squeeze the rims of furrows and holes into steep cliffs. Patterns along a wall got stretched vertically, and seen at an angle they looked like curtains. The fixes: the fog top fades according to its thickness; the simulation blurs edges at 3 square metres per second; and the most fog can heap up in one step where the flow gathers went down from 1.5 times to 1.2.
2. Grain and a fine crosshatch
The usual sheet of fog is only about 4 metres thick, about the same as the height a single segment spans (around 2.5 metres). Originally each segment sampled one point, and a dither that depends on the position on screen decided whether that point fell inside the fog; the dither itself has a regular diagonal pattern. After switching to an exact formula for each segment and dropping the dither, we roughly measured the grain as the brightness difference between neighbouring pixels: it went from about 10 down to 3–4.

At full size. Left: the first version, with grain and a diagonal crosshatch on the fog. Right: after switching to the exact calculation.
3. Terraces
Once the dither was gone, horizontal bands appeared like steps wherever the fog's thickness changed quickly: each segment read the map at only one point, so within a segment the fog top was flat. Reading the map at both ends of each segment and joining them with a straight line removed the steps. Neighbouring segments share the point between them, so the number of lookups per pixel only went from 16 to 17.
4. Fine stripes one cell apart behind the muzzles
Where a muzzle had pushed the fog, fine stripes exactly one cell (2 metres) apart were left on the surface. We read the fog field back from the GPU: near the muzzles, about 40% of the flow was a zigzag, positive in one cell and negative in the next; far away it was 5%. The shallow water equations work out the push and the spreading from the difference between the cells on either side, which is exactly blind to this zigzag, so it never dies out on its own. Adding a little smoothing to the flow (4 square metres per second) brought the zigzag down to about 20%. More smoothing gives a cleaner picture, but it also weakens how hard the muzzles push the fog, so we left it as a slider on the tuning panel.
Cost
At first we read the GPU time of each frame straight from the editor, estimated about 3 ms extra at 1440p, and planned to draw the fog at half resolution. But the editor's readings were far too noisy: many came back as 0, and now and then one jumped to 60 ms. So we changed the method: freeze the same 4-against-4 sea battle on one frame, render the same picture from the main camera over and over, alternate between fog on and off three times each, and wait for the GPU to finish before stopping the clock each time.
| Resolution | Old fog | Flowing fog | Difference |
|---|---|---|---|
| 2560×1440 | 2.77 ms | 2.96 ms | +0.2 ms |
| 5120×2880 | 9.33 ms | 10.13 ms | +0.8 ms |
The fog simulation takes about 0.03 ms per step, and the CPU side about 0.02 ms per frame. These numbers come from our development PC; on a slower GPU they grow in proportion. On this machine, drawing at half resolution is not needed for now.
Tuning panel
To tune while playing, we added a panel that opens with F9. The fog's distribution, look, flow and pushes, as well as the time of day, the lighting and the look of each weather, can all be adjusted with sliders, and the values can be saved to a JSON file. The night battle at the top uses 22:00, fog about 5 metres deep (a 1.6-metre sheet, with patches up to 3.6 metres thicker), and a density of 0.35 per metre.
Where it stands
- The flowing fog lives on a test branch. We made a test build, v0.8.51-fog, but it is not in the main game yet.
- Not done yet: checking it in the captain's view, and light shining on the fog (lanterns, muzzle flashes), which KANA has and we do not.
- The first version, the fixes above, the cannonball disturbance and the cost measurements were all done between the evening we saw the post and the early hours of the next day (2026-11-08 to 11-09).
- The code and tests were written by Claude Code (Claude Opus 5.5); we judged the look, asked for changes and made the trade-offs.