At the end of my game's demo run the median frame took 21.9 ms. After one day of adding long caves and tunnels it took 24.1 ms. I blamed the new underground view, hid it, and the frame stayed at 23.5 to 24.4 ms. Then I removed 121 of its 2,093 draw calls, and the frame time on the test scene stayed where it was. Below are the three measurements, the 40 lines of GDScript that made the draw-call cut, and the explanation I cannot yet prove.
The game is a Godot 4 project where a small rover digs shafts into a hex-tile planet. The numbers come from the game's own test runs, one Windows PC, same build settings for each pair I compare. I read them from the log line the game prints at the end of a run (frames per second and median frame time).
What the "dig view" is
When the rover is down a shaft, the game cuts a cross-section out of the ground around it: the shaft walls, the neighbouring cave, ponds, glowing mushrooms, crystals, grass tufts and loose stones on the cave floor. On 11 November I made caves long (a hundred and fifty winding tunnels per planet instead of single rooms) and let the rover dig sideways. That is a lot of small things on a lot of floors.
Every mushroom, crystal, tuft and stone was its own MeshInstance3D. A cave cell with mushrooms had 31 to 42 nodes.
Measurement 1: the frame got slower
I run the whole level start to finish with a bot, once per playable race, and read the numbers at the end of the demo, when the player has dug the last shaft.
| Run (humans) | FPS at end | Median frame |
|---|---|---|
| Before the long caves | 44 | 21.9 ms |
| After the long caves | 40 | 24.1 ms |
The other two races landed in the same place: 40 fps and 23.7 ms, 41 fps and 23.9 ms. So it was not a one-off.
Measurement 2: hide the suspect
The obvious suspect was the dig view, because it was the new thing. I added a switch to the run that hides the dig view at the end of the demo, in pieces and then as a whole, and read the frame time each time.
Hidden piece by piece, hidden entirely: 23.5 to 24.4 ms. The same as with it visible. The dig view was not paying for the 2.2 ms, at least not at that moment of the run.
What had changed there, besides the caves, is that a cave now sits next to the last shaft, and at the end of the demo the camera turns toward it. A different side of the forest and the village comes into frame. A scene that simply contains more things looks the same as a feature that costs more, and a bot that always ends in the same place cannot tell them apart.
Measurement 3: the cheap fix I could verify
The part I could fix and verify was the node count. Godot draws each MeshInstance3D as its own draw call. Things that share a mesh and a material can be one MultiMeshInstance3D with many instances, one draw call for the lot. I had a note from an earlier run that the cave beside the last shaft added about 390 draw calls, roughly 2 ms. That is close enough to the 2.2 ms gap to be worth a try.
The change is a small collector. Callers say "put this mesh with this material here" and the collector groups by mesh and material, then makes one MultiMeshInstance3D per group at the end:
var _groups := {} # key -> {mesh, mat, shadow, xfs: [Transform3D], cols: [Color or null]} func add(mesh: Mesh, mat: Material, xf: Transform3D, col = null, shadow := true) -> void: var key := "%d/%d/%s" % [mesh.get_instance_id(), mat.get_instance_id(), "s" if shadow else "n"] if not _groups.has(key): _groups[key] = {"mesh": mesh, "mat": mat, "shadow": shadow, "xfs": [], "cols": []} _groups[key]["xfs"].append(xf) _groups[key]["cols"].append(col) func flush(parent: Node3D, layers: int) -> Array: var made: Array = [] for key in _groups: var g: Dictionary = _groups[key] var coloured := g["cols"].any(func(c): return c != null) var mm := MultiMesh.new() mm.transform_format = MultiMesh.TRANSFORM_3D mm.use_colors = coloured # before instance_count, or Godot ignores it mm.mesh = g["mesh"] mm.instance_count = g["xfs"].size() for i in g["xfs"].size(): mm.set_instance_transform(i, g["xfs"][i]) if coloured: mm.set_instance_color(i, g["cols"][i] if g["cols"][i] != null else Color.WHITE) var mi := MultiMeshInstance3D.new() mi.multimesh = mm mi.material_override = g["mat"] mi.layers = layers mi.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_ON if g["shadow"] \ else GeometryInstance3D.SHADOW_CASTING_SETTING_OFF parent.add_child(mi) made.append(mi) _groups.clear() return made (The listing is trimmed from the game's file; the real one is the same shape.) One trap is in the comment: use_colors must be set while the MultiMesh has no instances, or the per-instance colours silently do nothing. The pond reflections, which were another copy of every glowing thing, went through the same collector.
The result on the dig test scene, which I use because it is a fixed camera on the open cave:
| View | Draw calls before | After | Fewer |
|---|---|---|---|
| Overview | 2,093 | 1,972 | 121 (5.8 %) |
| Close up | 2,012 | 1,914 | 98 (4.9 %) |
Nodes per mushroom cell fell from 31 to 42 down to 7 to 14, counting the lights, halos, water and posts that stay separate. The picture of the mushrooms and grass is the same.
The frame time on that scene: 57 to 59 fps and a 17.8 ms median the day before, 54 to 60 fps and 16.7 to 18.0 ms after. That is inside the spread of the runs. Five percent fewer draw calls did not make a frame I could measure.
What I take from it, and what I do not
Fewer nodes is still the right direction for me. The scene has less to keep in memory, building a cave cell does less work, and the batching sets up the shadow and colour flags in one place. But I will not pretend it paid back the 2.2 ms. On this scene on this machine the GPU or something else was the limit, and the draw calls were not.
Three habits helped:
- Hide the suspect before you fix it. Measurement 2 took ten minutes and told me that my first theory was wrong.
- Keep one fixed test scene for each change. The full level run is too long and ends in a slightly different place every time.
- Write down what a number was measured on. The 390 draw calls and 2 ms were from a different run than the 2,093 and 17.8 ms, and I almost added them up.
The part I still do not know
I did not rerun the full level after batching. So I do not know whether the end-of-demo frame is back at 21.9 ms or still at 24.1. There are two explanations and my runs do not separate them:
- The cave props cost 2 ms and batching gets some of it back, but my test scene hides it because it is limited by something else.
- The 2.2 ms is the camera facing a denser part of the forest and village, and the caves have nothing to do with it.
If you have a way to tell "this feature costs frame time" from "this camera sees more" in a run that always ends in the same place, I would like to hear it. Do you move the camera to a neutral spot and compare, or render the same view with the feature removed? I have not decided which of those is the better control.




