Skip to main content

The texture that would not compress

Painted plates are large. Kept as raw RGBA they cost four bytes a pixel in video memory. Compressed with BC7, a format the graphics card can read directly without unpacking, they cost one. The build asked for BC7 on every painted street sprite, and Unity’s web build quietly ignored the request for ten of them. The cause: those plates were not powers of two in size (like 1024 or 2048 pixels), and they had mipmaps, the smaller copies of a texture a renderer uses when it is drawn far away. On the web, a mipmapped non-power-of-two texture cannot be block-compressed, because its smaller mip levels stop being multiples of four. Instead of an error, the engine fell back to raw RGBA, 5.3 times larger. These plates are drawn at close to one-to-one on screen and never needed mipmaps. So the release build now applies one rule to every painted sprite in the street:
1

Skip anything read as data

Masks, normals, dye classes, flow fields, relief and depth maps are never block-compressed.
2

Only large, block-friendly images

At least 256 by 256 pixels, with both sides a multiple of four.
3

Turn mipmaps off if the size is not a power of two

That is what unlocks real BC7 on the web without changing the image’s size or shape.
4

Set an explicit WebGL BC7 override at full quality

And log every plate’s memory before and after.
Result: ten street plates went from 96.5 MB to 19.7 MB of video memory, saving 76.8 MB.

The mip budget

On Eco and Laptop Cool, the game uploads every mipmapped texture starting from its second level: a quarter of the memory and a quarter of the upload. Nothing those tiers draw loses detail, because their picture is never wide enough to sample the full-size level. The same budget applies on any tier when the graphics card has no native BC7 support (the browser would otherwise expand BC7 back to raw RGBA in memory) or when its maximum texture size is below 8192 pixels, since the widest plate is 8192 by 2048.
Ishia and Kai’s colour sheets are exempt. They ignore the mip budget on every tier, so a cheaper tier saves memory on the background without ever softening the children’s ink.

Four tiers, decided twice, always the same

The tier is chosen in two places: in the page’s JavaScript, before the engine exists, so the canvas is the right size from the first frame; and in the game’s C#, which runs the street. If the two ever disagreed, the picture would jump when the engine took over. A test runs 26 machine profiles through both and requires them to match exactly. What the classifier reads, and what lowers a tier:
  • The graphics card’s name. Software renderers start on Eco. Integrated graphics start on Laptop Cool, or Eco with four threads or less, or 4 GB or less. Apple Silicon starts between Laptop Cool and Painterly High by chip class. Dedicated cards start on Balanced, or Painterly High with eight threads and plenty of memory.
  • Missing memory readings are not small memory. Firefox and Safari do not report device memory, and the classifier treats that as unknown rather than low.
  • No BC7 or a 4K texture limit caps the tier at Laptop Cool.
  • Battery. On battery caps at Laptop Cool; low battery drops to Eco.
  • Other game tabs. Two open tabs cap at Laptop Cool; three or more drop to Eco.
While you play on Auto, a quiet watchdog compares the 95th-percentile frame time with the tier’s budget. On a sustained breach it steps down one tier. It only steps back up after 25 seconds of measured headroom on desktop, never above your machine’s own tier, at most twice a session, and never again once a step up has failed to hold. No ping-pong. Two more small courtesies: switching away from the window drops the game to about 8 frames a second until you come back, and a volume, the interface size, the hour or a key binding never re-resolves the tier.