How the Aquarium Was Made in Pocket Cat Desktop: Sprites, Layers, and a Pixel Water Shader
What the artist draws, how the layers are assembled, what the shader does, and what went wrong along the way.
Pocket Cat Desktop has a little fishing mini-game: the cat sits on the taskbar with a fishing rod, and you click to catch fish. For a while, the catch was just three counters in the save file. It felt disconnected from the game, so I decided to make the catch part of the game world: an aquarium on the taskbar, with real water, light caustics on the gravel, and fish. This short post is about how it all works: what the artist draws, how the layers are assembled, what the shader does, and what went wrong along the way.
The physics of it
Before starting, I spent a little time reading articles and shader breakdowns about water, caustics, and refraction, and... not much of it applied. A flat aquarium viewed head-on with an orthographic camera doesn’t refract anything: parallel walls shift the image by zero pixels. Fresnel reflection from glass at normal incidence is a constant 4%.
62 pixels of water tint the light by an amount you can’t make out. So every “watery” feature in the aquarium is a stylized lie that the eye accepts because it’s seen it in a thousand cartoons: a wavy line at the top, darker water near the bottom, bright flickering patches on the gravel, and a bluish cast over everything deep underwater.
That’s fine for pixel art. There’s no need to copy the desktop/background behind the window into a render texture, no need to redraw the cat through distortion, and the whole effect lives on a single quad.
What the artist draws and what the shader adds
The aquarium is a glass box without a back wall. The desktop and the cat are visible through the water. The artist draws:
- the front part: the frame, base, lid, and two diagonal glass highlights, a 136×80 sprite with its pivot at the bottom center;
- a 132×8 strip of gravel;
- a rock and three tufts of grass, each with three swaying frames (idle, and offset left and right);
- 3 fish with 4 animation frames each, sized 16×10, 20×12, and 28×16, facing right. To face left, we just flip the sprite in code.
There’s nothing related to water in the atlas at all: no water fill, no caustics, no surface line, no highlights on the fish. The shader draws all of that, so we can do all kinds of things without changing the sprites.
A few constraints ended up making life much easier. The inside of the glass is a rectangle within the front sprite: columns 2 to 133 and rows 6 to 71. Every pivot sits on a whole pixel, so nothing falls between pixels when the Pixel Perfect Camera snaps the sprites. All the frames are in the same atlas as the rest of the furniture, at 64 pixels per unit, with point filtering and no compression.
Layers and sorting
The prefab is a stack of sprites around a single empty quad:
Order: gravel, rock, and two tufts of grass at sorting order −5; fish, spawned at runtime, at −4; one tuft of grass in front of the fish at −3 to give the scene some depth; the water quad at −2; the frame at −1. The cat’s default order is 0, so a cat walking past appears entirely in front of the aquarium, frame and all.
The lid is a thin collider with the same interaction points used throughout the game, so the cat can jump onto it, sit, or sleep there.
The aquarium enlarged 4x for clarity:
The water shader
The water is a one-pixel white sprite stretched to 132×62. Its shader does four things, and each follows the same pixel discipline: every continuous input is snapped to the art grid with floor(worldPos *64)*<em>, time advances in steps of 10 frames per second with `floor(time`</em> fps) / fps, and every smooth value is posterized into 2–3 bands. No gradients, no subpixel movement.
Depth tint. The quad’s pixel row gives the depth, from 0 at the surface to 1 at the gravel; the color is interpolated from a light top to a darker, more saturated bottom in three bands.
Caustics. Two networks of cell boundaries on a jittering grid (distance to the second-nearest center minus distance to the nearest one, the classic Voronoi edge) drift in different directions at speeds of 1 : 0.75. Taking the minimum of the two leaves only their intersections, which reads as sparse patches of light rather than a grid. The result is posterized into two bands and intensified toward the gravel, because light focuses with depth. Here are the steps on the water rectangle: the first layer, the second layer, their minimum, and the posterized result.
The core shared by the water and fish shaders:
float aqCaustic(float2 px, float t, float cellPx, float driftPx)
{
float2 uv1 = (px + float2(driftPx, driftPx *0.6)* t) / cellPx;
float2 uv2 = (px - float2(driftPx *0.75, -driftPx* 0.45) *t) / (cellPx* 1.23);
float c1 = 1.0 - saturate(aqCellBorder(uv1) *5.0);
float c2 = 1.0 - saturate(aqCellBorder(uv2)* 5.0);
return min(c1, c2);
}
In the first version, the border was multiplied by three instead of five. The lines were wide, the minimum still covered almost the whole aquarium, and the water read as a grid. Making the lines thinner fixed it with a single constant.
Surface. The top row of water pixels drops by one pixel along a traveling wave made from two sine waves and a hash by column, in steps of 8 frames per second, except for the two pixels at the sides, where the water stays raised. That’s the meniscus, and it’s a pretty convincing sign of a surface.
Blending. The game is a transparent window over the entire desktop, and Windows composites it using premultiplied alpha. The naive Blend SrcAlpha OneMinusSrcAlpha squares the alpha of anything translucent relative to the desktop. The water, like URP’s default sprite shader, blends color using SrcAlpha OneMinusSrcAlpha and alpha using One OneMinusSrcAlpha, so the window’s alpha accumulates correctly and the tint is exactly the one we specified.
Because the caustics use world coordinates as their input rather than the quad’s UVs, any other sprite can sample the same pattern. The fish shader samples the sprite, multiplies it by the water color in three depth bands, and adds the same caustics at quarter strength. The light on the gravel and the light on the carp’s back line up, and nothing had to be baked into the fish art. MaterialPropertyBlock passes the water rectangle in world units, its size in pixels, and the pixels-per-unit value to the water and each fish, so an aquarium placed anywhere on the taskbar keeps the surface on the right row.
Fish
I didn’t make prefabs for the fish. A released fish is an entry in the save file: a species and a random seed, and the aquarium spawns a sprite for each entry on startup. The seed drives System.Random, which determines each fish’s personality: how fast it swims within its species’ range, how often it stops, and where it starts. If you restart the game, each fish keeps its behavior.
The movement is a little bit of steering: choose a mostly horizontal target within the species’ depth band, accelerate toward it with a speed limit, slow down at the target, sometimes pause for a few seconds, and occasionally dart off. Fish push each other apart within 14 pixels, bounce off the walls, and only turn around once their horizontal speed crosses a small threshold, so they never twitch in place. A resting fish barely moves its tail. Minnows stay in the upper half, perch in the middle, and carp at the bottom.
I didn’t use an Animator. A small component that steps through an array of frames, ping-pongs 1-2-3-2, and starts at a random phase does the job, and the fish need to be linked to their speed anyway.
Clicking the aquarium opens a small window: one row per species, showing how many are in the aquarium and how many are in the bucket.
The cat on different depth planes
The cat now has a depth band. In the front band, it’s drawn at its usual sorting order, in front of the whole aquarium (and other objects, for that matter). In the back band, it’s drawn at −10, behind the gravel, fish, and water, and the water shader tints it and lays caustics over it for free.
When starting a walk, the cat checks whether its path crosses an object and chooses the back band half the time. Jumping, sleeping on the lid, and fishing restore the band’s sorting order rather than a fixed zero, while any surface other than the floor forces the front band. The cat never switches layers while on the glass.
A few problems that came up
- The jump approach point was too close to the aquarium, and its sorting override kicked in while the cat was still behind the glass. The point was moved to where the cat’s entire sprite is clear.
- While recording a GIF, I zoomed the main camera in on the aquarium. The game projects the taskbar and all window blocks out of the camera view, so the floor shrank to three units and the cat fell off the edge of the world. The recorder no longer touches the camera; it renders it to a screen-sized texture and crops a section.
- A second camera rendered manually in URP showed only the background. The same fix works here.
What’s next
Now I need to add new cat animations for more interaction:
- Poking the glass. The fish should be startled by this.
- Trying to catch fish inside while sitting on the aquarium.