LOG 005 // 05 OCT 2026
Water you can believe in
I started the water with an island. From above, the sea had to do a lot of work. You should see the sand through the shallows, lose it in deeper water, catch little flashes of sun on the waves, and still recognize a lamp in the reflection at night. A blue transparent sprite could give me the color, but none of the feeling.

The water is drawn after the main lighting. Its sprite carries depth in its alpha channel: zero by the shore, one in deep water. The bed below is an ordinary lit scene sprite marked as submerged. Water draws only over those marked pixels, so the bridge and boat stay above it without a sorting trick. The shader reads a copy of the lit scene, the light map, emission and shadows. It already has most of what it needs.
For each water pixel I know two useful things before drawing a wave: how deep the water is and what the already-lit world looks like underneath. That keeps the water pass focused on changing the view, rather than lighting the bed a second time. The submerged flag is just a yes-or-no mark on the bed pixels. A bridge lacks that mark, so the water shader leaves it alone.
Looking down, then looking across
I make ripples from a slow swell with smaller chop moving in different directions. The ripple slope bends the view into the bed. In the shallows the sand stays sharp. As depth grows, the bed gets more tinted and blurred. A refracted lookup that lands outside the water falls back to the straight view, which keeps the bank from tearing apart. Thin caustic lines give the bed the moving patches of light you expect beneath waves.
To get the slope, I sample the ripple height just to either side of the pixel and compare the values. That gives a small surface normal, a direction that says which way the water tilts. I use it to shift the bed lookup for refraction. Depth controls the size of the shift and which blurred copy of the scene to read. For color, I let each channel of the bed light survive a fraction that falls with depth, then add light scattered through the water itself. The shallow bed remains recognizable. The deep bed disappears into the water color.

The shoreline had a very visible bug. The depth texture went to zero on land, and the zero boundary followed individual texels like stairs. Moving the visible edge a little deeper into the filtered depth gave it a smooth curve. I hit the same kind of stairs in reflections. The shader marches toward the bank to find what the water should reflect, then uses a binary search to place the edge between two march steps. That extra search made curved banks stop looking like a staircase.
Reflection grows stronger when you look along a sloped ripple, and farther reflections fade toward the sky. Bright emitters get a longer streak along the reflected direction. The pier lamp makes a good test: the warm line on the water has to move with the surface, not sit there like paint.
There is no 3D world to reflect here. From the water pixel I march across the water along the ripple's reflection direction until I reach a bank. I narrow down the exact crossing, then sample the already-lit scene on the other side as though the bank were a mirror line. The result is approximate, but it gives the pier and its lamp somewhere to appear. The ripple normal changes the direction, and a brighter read from the emission image stretches the lamp into a streak.

The sun sparkles caused a different puzzle. In a top-down view with one directional sun, the mirror angle is almost the same across the whole water surface. My first attempt flashed everywhere or nowhere. Now tiny facets get slightly different tilts, and the ripple slopes decide which ones catch the sun. Local lights make their own colored glints too, using the light map to work out where the light comes from.
Color mattered just as much as geometry. Blue-green water tint made a warm lamp under the surface turn green. I now let local light keep its own color through the water body. The shore gets moving foam bands, and a height shadow dims the water a little so a pier shadow remains visible. That last choice is an art decision. A reflected sky would not darken quite that way, but the scene reads better when the pier feels connected to the sea.
The same water, drawn another way
The Sakura river uses the same depth, ripples, lights and reflection data. A style function mixes them differently: three flat depth colors, thin lines that drift with the flow, hard white star glints, and one clean white edge along the bank. Koi swim underneath. Lily pads and petals sit on top. At night, the lanterns still reflect.

That is the part I like most. The water system does not dictate one look. It gives me enough information to make the island feel clear and physical, then lets the river feel like it belongs in a painting.