Skip to content
Devlog

Devlog #30 • Under the Hood: The Same Picture, Less Memory

A second technical devlog with charts: grass without shadow maps, smaller memory pools on the graphics card, half the world data in memory, and small finds that add up. Every change checked side by side.

14 November 20268 min read

The last devlog was about servers and the world generator. This one is about your machine: how much work the graphics card does for a frame, how much video memory YUMA needs, and how much memory stays taken without anyone using it. The rule was the same as last time: every change was measured, and the picture after it was compared with the picture before. If you could see the difference, it did not go in. Everything here is on the development branch and comes with the next version.

−2.5 msGPU time per frame on High at 1440p
−600 MBvideo memory on Epic
−577 MBworld data in memory after loading
4.3×faster search for the plant in front of you

Every chart shows a measurement before and after a change. Each row is scaled to its own “before”, so the gold bar is what is left of it. Measured on an Intel Arc B580 with 12 GB and a Ryzen 9 5950X.


Grass That Casts No Shadow and Still Has One

We started with a question: where do the roughly 26 ms of a frame on High at 1440p go? The largest items were the virtual shadow maps at 3.8 ms, the base pass at 3.3 ms and upscaling at 2.9 ms. The shadow maps held a surprise: the grass. The blades within 6 to 12 m of the camera were drawn into the sun’s shadow map, and that cost 1.6 to 1.7 ms.

Side by side, you see almost none of it. The shadows a clump of grass casts on the ground come almost entirely from the sun’s contact shadows, a short screen-space effect over 40 cm that runs anyway. Grass now casts contact shadows only, on every preset. The “Grass shadows” option is gone, and so is the toggling of shadows on grass patches while you walk.

A meadow by the coast: the blade shadows on the ground come from the contact shadows

GPU time at two spots of the photo tourBeforeAfter
Meadow at eye height−9%
18.92 ms
17.20 ms
Forest at the spawn−8%
20.81 ms
19.18 ms
Arc B580, 2560 × 1440, High preset, TSR Quality, noon. Same camera position before and after. The blade shadows on the ground look the same.

Two more items from the same measurement:

  • Cloud shadows. The clouds cast their shadow through a shadow map of their own, and they darken the sky through an ambient occlusion pass. On High and Epic both now use the Medium settings. Cloud shadows are soft patches a kilometre wide at either resolution. Side by side, old and new shots differ less than two old shots taken a minute apart, because the clouds drift in that time.
  • Terrain tessellation. On High, nearby ground is now subdivided one step less. In 1:1 crops at eye height on scree, forest floor, ridge, beach and meadow there is no difference to see. Epic keeps the finer step.
Single passes on the graphics cardBeforeAfter
Cloud shadow map−40%
0.83 ms
0.50 ms
Cloud sky occlusion−50%
0.26 ms
0.13 ms
Terrain in the shadow maps−14%
1.07 ms
0.92 ms
Base pass−8%
2.06 ms
1.90 ms
ProfileGPU, Arc B580, 1440p High, before and after measured in turn. Tessellation: only this game on the GPU, four pairs.

And one find on the render thread: the foam along the coast is drawn into a texture of its own that moves with the camera. That ran every frame, even far inland with no sea in reach, and cost 0.87 ms. Now the game checks a coarse height map for sea within 300 m. If there is none, the foam pauses.


Less Video Memory

The graphics card reserves some memory pools right at the start, whether they are used or not. Two of them were much larger than needed.

  • Virtual shadow map pages. On Epic the engine sets up 4,096 pages. Across the whole photo tour at 1080p, at most 450 of them were in use, and about 1,690 even at four times the pixel count. The pool now has half. If it ever runs tight, the engine lowers the shadow detail by itself and does not drop pages.
  • Nanite streaming. The pool for the geometry Nanite streams in on demand was 512 MB. The most visible geometry at any spot of the photo tour was 62 MB, in dense forest. It is now 256 MB, still four times that. All 20 spots of the tour show the same meshes.
  • Terrain index buffers. A piece of terrain has about 3,800 vertices, so its indices fit in 16 bits instead of 32. That halves the memory they take.
Video memoryBeforeAfter
Shadow map pool with its hierarchy−50%
612 MB
304 MB
Nanite streaming pool−48%
528 MB
272 MB
Terrain index buffers−50%
96 MB
48 MB
Arc B580, 1920 × 1080, Epic preset. Terrain: the spawn of the test world, the indices of all visible terrain pieces.

On High the shadow map pool is smaller and saves less, about 150 MB. The other two savings apply on every preset.

Spruce forest at a river mouth: where Nanite needs the most geometry


World Data Nobody Looks At

An island off the coast: only what lies around the player is loaded

A YUMA world is large, so only the part around the players is kept in memory. Or so we thought. A measurement 50 seconds after the loading screen showed 1.1 GB of world data, and more than half of it was far from the player. We logged who touches which island and found four culprits:

  • During the loading screen your character still waits at the origin of the map. Several systems already took it for the player and loaded the world data at the origin: 350 MB of detail data and a 90 MB island map that nobody needed afterwards.
  • The climate query for villagers, crops, fishing and weather read the full island map. A village 18 islands away held 91 MB for the whole session that way. Temperature and moisture are smooth fields, the coarse copy of the map is enough for them, and it is 8 MB.
  • A settlement whose ground still had to be adjusted checked every second whether its terrain was loaded yet, and loaded it while checking. Now it waits until a player is nearby.
  • Every save sampled the ground under every settlement and loaded distant islands to do it. Now it only reads islands already in memory.

On top of that, tiles and detail data nobody has asked for in 60 seconds are released. Before, they only went once a 768 MB budget was full. From the disk cache they are back in 0.02 s.

World data in memoryBeforeAfter
Island maps−52%
337 MB
163 MB
Tiles and detail data−50%
809 MB
406 MB
Solo, spawn of the test world, 50 seconds after the loading screen. Islands are the height and climate maps, tiles the erosion detail and detail data around the player.

Small Things That Add Up

After that we went through the largest objects in the memory of a running game, one by one.

  • Plant records. For every placed plant the game remembers where it is, so you can harvest it, hit it and rebuild it. Each record held a transform in double precision and two fields nobody read: 160 bytes. Now it is 64. With 757,000 plants at the spawn that is 72 MB less.
  • Tree collision. Trees collide as a simple capsule. In the editor build the engine still made a full collision mesh from every tree’s render mesh, about 1 MB per tree. A shipped game never did, and now both behave the same. 96 test traces in a forest hit the same trees at the same distance as before.
  • Sea rings. The sea is made of eleven rings around the camera. Each ring had its own grid in memory and was sent to the graphics card again every frame. Now the rings share two grids built once at the start. The vertices sit exactly where they did before.
  • Plant textures. 46 opacity and roughness masks of the scanned plants were stored uncompressed. They have one channel, and a compressed one-channel format halves them without changing the edges of the leaves.

Forest floor with ferns, grasses and a fly agaric: the same leaf edges with masks half the size

Single memory itemsBeforeAfter
Plant records−60%
120 MB
48 MB
Tree collision13×
31.2 MB
2.4 MB
Sea rings14×
30.5 MB
2.2 MB
Plant textures−50%
94.1 MB
47.1 MB
Solo, spawn of the test world. Tree collision: editor build, 74 trees and stumps.

In the multiplayer test with a server and two clients in low video memory mode, a client now needs 7.2 to 7.3 GB of memory instead of 9.7 to 10.6 GB, and 1.8 instead of 2.3 GB of video memory.

The game thread had a find too. When you look at a plant, the game searches every frame for which one it is, so that the right prompt appears. That search went through every loaded piece of terrain and every plant in it. Now it only looks at the pieces your view passes through, and skips groups of 64 plants at once when their outline does not touch the view. It costs 0.11 ms per frame instead of 0.47.


What Did Not Pay Off

Not every idea survived the measurement.

  • Larger plant cells halve the number of components from 4,007 to 1,798 and the engine saves 9 MB. The frame time does not change, because Nanite needs no draw call per component anyway. Larger cells do mean larger rebuilds while you walk. The cells stay as they are.
  • By day MegaLights costs practically nothing, 0.01 ms. The 0.65 ms the profiler lists under “Lights” are the sun.
  • Turning off the hair simulation saves no measurable time.

There was some tidying as well: every time the ground under a settlement changed, the game made a backup of the save and never deleted it. The test world had 27 of them, and the world menu listed each as a world of its own. Now the three newest are kept, and the menu lists only real worlds.

What changed in the picture: nothing we could find in direct comparisons. That was the bar.

Skål!

Comments

  1. Loading comments...