Devlog

, Built, Looks

Swapping models without anyone noticing

Far off, the trees, the grass and the people are drawn with simpler models. They used to swap in a single frame, and you could see it. Now they fade, swap only where a script measured you can't tell, and the woods' floor gets painted on.

0 wished for this

Every game that shows a lot of stuff does this trick: far away, things get drawn with simpler models. A tree's crown 200 units off doesn't need 80 triangles, 20 will do. At that size nobody can tell, and the graphics card gets a LOT less to draw. Little Shores did it too: the trees, bushes, flowers and grass, the people, the long bridges and the ruins on the desert islands all had a model for the distance.

Full: the woods in their full modelsFar: the same woods in their far models
The same trees from 40 units, drawn in their full models and in their far ones. Up close you can tell. Far off you shouldn't.

Then I started wondering: for what elements do we actually have such a thing? For every model? Is there a set rule?

There wasn't. Each kind of thing switched at a distance of its own, picked by eye (my eye). And every single one switched instantly, from one frame to the next. So yes, things popped.

First, look at it properly

Before fixing anything I wanted to actually SEE how bad each switch was. So every one of them got drawn both ways in the very same frame, the pixels that change marked in magenta, and filmed zooming through at the game's own pace. Ranked by how much they showed:

  1. The desert ruins. Stone by stone turned into smooth courses, and the far model was plainly paler than the near one.
  2. The timber bridge. Planks and railings turned into a flat strip, the whole bridge in one frame.
  3. People. The face, the hands and the cap's brim went, right in the sharp middle of the picture as you zoom in.
  4. The trees. Each crown barely changes, but a whole patch of 16 by 16 units switched at once, so the pop ran over the woods in squares.
  5. The ferns along the woods' edges, which simply vanished 60 units out.

A fade instead of a pop

The fix for the popping: for about a third of a second both models are drawn, each one leaving out exactly the pixels the other one draws, by a fine pattern fixed to the screen. Every pixel is covered once, nothing shines through, and the shadows fade along. A dithered cross-fade, basically.

And then the first snag. Zooming in fast, the camera rushes past the switch in a few frames, and the fade gets squashed with it, so short that it almost looks like there's no fade at all.

SO: the camera knows where it's heading. A thing now turns to its detailed model as soon as the camera heads nearer than its switch, not once it gets there, so the fade is done before you arrive. A camera that jumps, say to a link's view, fades nothing at all, since the whole picture is new anyway.

Zooming out over the same woods: on the left as it was, on the right with the fade and the new distances

To put a number on it, the camera crept out across a switch, a fifth of a percent of its distance per frame, and every frame got compared with the one before. The most of the picture that changed in a single frame:

WhereBeforeAfterThe camera alone
A great pyramid4.59%0.99%about 1.0%
A villager1.13%0.88%0.81%

So the switch doesn't stand out of any frame anymore. It drowns in the change the camera makes anyway. (That pyramid lost its far model later anyway, more on that below.)

Where to switch? Measure it

Next problem: all those distances picked by eye. The new rule is that a far model may only take over where you can't tell it from the near one, under about a pixel and a half of difference, in shape and in colour, its shadow included. A script draws near and far in the same frame and steps them further and further away until they match.

First run, measured strictly: NOT ONE far model passed, anywhere the camera goes. Here's why:

Near
Far
What changed

The outlines barely move, but with fewer facets a far model shades every crown a tiny bit differently, and pixel by pixel that's a lot of magenta. Ok, fair. So the rule became: the outline has to stay within 1.5 pixels of a normal screen, and the colour, averaged over the thing, within what the eye tells apart. The facets inside are free, the fade carries those.

Second run: the far models only held up three to five times farther out than where they had switched. Some never. So the far models themselves had to get better first. The far grass tufts, for example, didn't cast a shadow at all, and their three blades covered only about a third of what a near tuft covers. Now they cast one and cover 97%. Then measure again:

WhatSwitched atSwitches at
Trees140122
Bushes120213
Flowers80202
Meadow grass80233
People7.57.5
The long bridges48never
The desert ruins45 to 70never

That's in units from the camera, a unit about a building's tile, measured on a big retina screen. On a screen 1080 pixels high everything switches at about 0.6 of that, since fewer pixels show fewer details. The game works that out for your screen by itself.

Bushes, flowers and grass now stay detailed much farther out, so more full models are on screen. But a fade only hides a switch if the two models look alike where it happens.

And the ruins and the bridges? Their far models only matched the near ones from about 160 units out for the bridges and 360 to 570 for the ruins. That far away, one ruin is a tiny part of the island in view, so a far model would save basically nothing. So they don't get one anymore, and are drawn whole at any distance.

Before: the temple's far model, 78 units outAfter: the temple drawn whole
A ruined temple on a desert island, 78 units out: its old far model, paler, and the temple as it is drawn now

Painting the ground

Some things don't swap at all, they just stop being drawn at some distance: ferns, toadstools, fallen logs and old stumps, the corals and shells on the sea floor. Those simply vanished at their edge. And that's where I had an idea: how about painting the ground roughly in the models' colours? At a high distance, then low poly, then high poly.

So the woods' floor and the sea floor now have a map underneath, of how much of each kind of cover grows where, and as the props fade out at their edge, their colour fades in on the ground under them. With that, the ferns stay drawn out to 231 units (they ended at 60), the toadstools to 93 (from 40), the logs and stumps to 212 (from 110), and the paint carries on beyond. Under the water it shows most:

Before: the lagoon's floor, its corals and seagrass ended at their edgeAfter: their colour painted on beyond it
A lagoon on a desert island, 130 units out. Before, the corals and the seagrass had ended at their edge, the reef beds lying alone on pale sand; now their colour carries on in the paint

I tried the paint on the meadows too. The script was happy with it. But looked at on a normal screen, the meadows lost the fine stipple of grass tufts, which none of the measurements saw. So the meadows keep their far models, as before.

One more thing came up on the way: a few freezes right after the loading screen disappeared. The fade's materials got prepared the first time something faded, which was right after loading, and that froze the picture for up to two seconds. Now they're prepared while loading: a tour of twenty seconds after a load compiled 47 of them before, and 2 now.

Who else gets one?

Last question: does anything else deserve a far model? Measured on the biggest town there is, seen whole from 640 units: the rocks draw 0.35 million triangles, the heather 0.11, all the town's buildings together 0.2, a ship 7,000 to 44,000, a cow 532. Hiding any one of them saved nothing measurable. Except the dune grass: 0.72 million triangles, about a ninth of the whole view.

So the dune grass got a far model: five wider blades for the fifteen of a tuft, each as tall and as pale at the tip as the blade it stands for. From 640 units that's a million triangles fewer. Can you spot it?

Before: the dune grass in its full model, 480 units outAfter: the dune grass in its far model
Beaches 480 units out, the dune grass in its full model and in its far one. 0.19% of the pixels differ, single specks scattered over the whole island

Me neither. Honestly, the frame time stayed within the noise on my machine. But that's a million triangles fewer for every computer that's slower than mine.

What's next

One thing is still left over: the fish, the rays and the dolphins near the shore are only drawn within 45 units of where you look, and they still pop in and out at that edge. They're next in line for the fade.

Comments 0

Join to comment: with your address and a code, kept to the house rules.

    No comments yet.

    Join in

    Join the island

    One account for all of it: a say under every devlog post, a wish for the ideas you'd like built, letters from the workshop now and then, and a place in the playtest to ask for, before everyone else. A code to your address signs you in, no password to keep.

    Joined already? The same address signs you in.