godotwright-gameoptimizer

Performance optimizer for Godot 4 games, built for coding agents: audit, world c

This is a fork of laaielichter/godotwright-gameoptimizer, kept for reference and contributions. It is not an original project.

Godotwright Game Optimizer: find what slows your Godot 4 game, fix it, prove it with a benchmark

CI MIT license Godot 4.3+ Node 20+ MCP server Zero dependencies

Website · Quick start · Measured · Install · Tools · Limits · Godotwright

Godotwright Game Optimizer

The performance optimizer for Godot 4 games, built for coding agents. It reads a project, tells the agent what
holds the frame rate, memory and load times back, applies the fixes itself, and proves each one with a benchmark and
a screenshot comparison. Made for heavy open worlds; works on any 3D project.

By laaielichter. MIT. Node 20+, zero dependencies, no build step.
Part of the Godotwright family: Godotwright keeps your agent's Godot
code correct, the Game Optimizer makes the game fast. Use them together.

Terminal output of gameoptimizer audit on the demo world: score 9/100, high findings such as 16k identical meshes as separate nodes and 260 lights that never fade out, each with a fix command, and the plan.

Quick start

Try it on the heavy demo world in under a minute, no Godot needed:

npx -y github:laaielichter/godotwright-gameoptimizer demo ./world
npx -y github:laaielichter/godotwright-gameoptimizer audit ./world
npx -y github:laaielichter/godotwright-gameoptimizer costmap ./world

On your own game: audit path/to/project. To let your agent do the whole loop, add the MCP server.

World cost map of the 2.4 km demo world: 16 by 16 cells, hot in the centre, with eight numbered benchmark stations on a dashed route. Worst view 3.9 million triangles.

What it solves

Godot 4 renders beautifully, but a large world runs into the same walls every time. Each row is a problem the
engine leaves to you, and what this tool does about it.

Problem in Godot 4 What the optimizer does
No world streaming. A scene is loaded, instantiated and kept in memory as a whole. partition cuts a world scene into chunk scenes on a grid. GOStreamer loads them around the camera on a thread, attaches nodes within a per-frame time budget and loads ahead of the camera's movement.
No HLOD. Unload a chunk and its buildings vanish from the skyline. Every chunk gets a stand-in scene: one MultiMesh per mesh of only the parts large enough to be seen from far, with no physics, lights or scripts. It is drawn while the chunk is not loaded, so the picture stays the same.
Only a far plane. A pebble 2 km away is still an instance to cull. ranges gives every object a visibility range computed from its own size on screen (invisible below 6 pixels by default), and takes tiny objects out of the shadow passes.
A MultiMesh is culled as one box. One MultiMesh for a forest is always drawn in full; a node per blade of grass drowns the scene tree. instancing merges identical meshes into one MultiMesh per world cell, each with its own visibility range. A trade (see Measured): the plan marks it optional unless the node count is high.
No texture streaming. Every texture of a loaded scene sits in VRAM in full; projects built outside the editor never get VRAM compression. textures sets VRAM compression and mipmaps for the textures 3D materials use (4 to 8 times less memory). Streaming then makes texture memory follow what is loaded.
No dynamic resolution, no quality presets. Project settings are read at start. GOQuality: five tiers (low to cinematic) applied at run time: FSR 1/2 and scale, AA, shadows, GI, SSAO, SSR, fog, LOD bias. GOGovernor holds a target frame rate by moving the resolution scale, then a ladder of settings.
Hitches from main-thread loading. load, instantiate and add_child block the frame. GOSpawnQueue loads on a thread and attaches within a time budget. The audit finds the loops that do it the slow way.
Shader compilation stutter for content that arrives after the loading screen. GOPrewarm draws every material and vertex format once behind the loading screen. The probe counts pipeline compilations per frame, so you can see it work.
Lights that never switch off. Every shadowed omni light renders the scene six times. lights sets distance fade from each light's range; optional dual-paraboloid shadows.
The world is built from code, or the game only exists as a .pck: there is no scene file to read. The live census starts the game, lets the world build and counts what is really in the tree: nodes per script that made them, repeated meshes, a mesh or a material per object, objects without a visibility range, textures that sit uncompressed in VRAM, nodes that process every frame. GOWorldPolicy then gives every mesh and light a visibility range, shadow rule and distance fade as it enters the tree.
Where is it slow? You find out by flying around. The world cost map predicts triangles, draw calls and shadowed lights per cell from the files, finds the hotspots and writes a benchmark route through them.
Did the optimization break the look? bench takes a screenshot at every station; compare checks them pixel by pixel next to the numbers. Runs use a fixed time step, so the sun and animations are in the same state in both.
Importing on a machine without a GPU hangs on VRAM-compressed textures (the GPU compressor runs on a software driver). import and bench select the CPU compressor for the length of the import.

Everything an agent changes is journaled: undo restores every byte.

Measured

Two runs on the demo world (gameoptimizer demo), every number from bench and compare. The machine is a
4-core container without a GPU: rendering is Mesa's software Vulkan driver (llvmpipe), so milliseconds only compare
with each other. Counts and memory are exact.

The 2.4 km world, 19 371 nodes, flown through headless (script, scene and streaming cost, no rendering):

Before After install settings textures lights ranges partition
Frame time p50 (CPU side) 8.19 ms 1.31 ms
Frame time p99 19.66 ms 5.31 ms
Hitches during the flight 66 5
Nodes in the tree (max) 19 371 7 877
Static memory 91 MB 85 MB

A 900 m world, rendered at 8 stations, step by step, each compared with the step before:

Step Nodes Objects drawn Draw calls Picture Verdict of compare
baseline 3 127 2 033 117
settings, textures, lights, ranges 3 130 1 658 99 changed on purpose: mipmaps end the shimmer better
+ partition with stand-ins 1 662 810 335 same (0.4% of pixels) fewer nodes and culled objects; more draw calls
instancing instead (tried, undone) 928 422 264 same (0.0%) regression on this renderer: undone

What the numbers say, without rounding in our favour:

Reproduce: gameoptimizer demo /tmp/world, then the loop below.

Before and after, station 2 of a 900 m world (1280x720, Godot 4.7.2, same machine, run on 28 November 2026), the
safe steps only: install settings textures lights ranges.

Before After
Baseline: the ground and the tree crowns shimmer with a moire pattern After: mipmapped textures, the ground and the crowns are smooth
Over all 8 stations Before After
Draw calls (avg) 133 111 -16%
Objects drawn (avg) 3 804 3 205 -16%
Texture memory (max) 200 MB 177 MB -11%
Video memory (max) 221 MB 202 MB -8%
Frame time p50 (software renderer) 629 ms 672 ms +7%, worse

compare called this run a regression, and it was right to: on the software renderer the frame time went up. We
have not isolated the cause; texture filtering (mipmaps plus 16x anisotropic), which a CPU rasterizer pays for in
full, is the likely suspect. The picture changed on purpose (up to 6% of pixels): mipmaps end the moire on the
ground and in the leaves. On a GPU, measure again and keep what wins there.

Install for your agent

The server speaks MCP over stdio. One command, no install step:

npx -y github:laaielichter/godotwright-gameoptimizer mcp

Claude Code

claude mcp add gameoptimizer -- npx -y github:laaielichter/godotwright-gameoptimizer mcp

Codex (~/.codex/config.toml)

[mcp_servers.gameoptimizer]
command = "npx"
args = ["-y", "github:laaielichter/godotwright-gameoptimizer", "mcp"]

Gemini CLI, Cursor, VS Code, Windsurf, Cline and other MCP clients (mcpServers in their JSON config)

{
  "mcpServers": {
    "gameoptimizer": {
      "command": "npx",
      "args": ["-y", "github:laaielichter/godotwright-gameoptimizer", "mcp"]
    }
  }
}

On Windows, if npx does not start from the client: "command": "cmd", "args": ["/c", "npx", "-y", ...].

No MCP? Every tool is a CLI command with --json. AGENTS.md and llms.txt describe the
loop; skills/gameoptimizer is the same as an agent skill.

Measuring needs Godot 4 (4.3 or newer; developed against 4.7.2): pass godot or set GODOT. The audit, the cost
map and every fix work without it.

Use it with Godotwright

Godotwright (website)
is the coding toolkit for Godot agents: the real Godot 4.7 API offline, a scored review of every script that catches
Godot 3 habits, scenes that merge in git, and bisect to find the commit that broke it. Godotwright makes sure what
the agent writes is right; the Game Optimizer makes sure it runs well. Both are MCP servers, so one agent can use both:

claude mcp add godotwright -- npx -y godotwright mcp
claude mcp add gameoptimizer -- npx -y github:laaielichter/godotwright-gameoptimizer mcp

A good order: godotwright review until the scripts are clean, then optimizer_audit and the measure-fix-compare loop.

Worlds built from code

gameoptimizer census path/to/project            # or: --pack game.pck
gameoptimizer fix policy path/to/project
gameoptimizer census path/to/project --label after

On the demo built by a script (gameoptimizer demo /tmp/w --procedural, 1 101 mesh instances) the first census
reports 1 100 objects without a visibility range, 300 materials used by one object each and a 1024 px texture made
at run time, all traced to world_builder.gd. After fix policy the second census counts 1 object without a range
(the ground), no tiny shadow casters and no lights without a fade.

The loop

optimizer_audit                         findings + plan                      no Godot
optimizer_bench   label=baseline        frame times, hitches, draws, memory, screenshots
optimizer_fix     fix=<step>            one step of the plan (dry_run to preview)
optimizer_bench   label=<step>
optimizer_compare run=<step>            better / same / worse, picture same / changed
        keep it, or optimizer_undo

Tools

Tool CLI What it does
optimizer_audit audit Findings with evidence and the plan. Reads scenes, models, textures, import files, settings, scripts and shaders.
optimizer_costmap costmap Predicted cost per world cell, hotspots, a text picture of the map, a benchmark route.
optimizer_census census Starts a scene (project or --pack game.pck), lets it build, counts the live tree and reports findings. For worlds built from code.
optimizer_textures textures GPU memory per texture, largest first.
optimizer_fix fix <name> install, policy, settings, textures, lods, lights, ranges, instancing, partition. dry_run supported.
optimizer_undo undo [id] Takes a fix back; --list shows the journal.
optimizer_bench bench Runs the game with the probe: percentiles, hitches with position and cause, monitors, screenshots. stations or fly.
optimizer_compare compare <run> Baseline against a run, per metric, per station and per screenshot. Exit code 1 on a regression.
optimizer_import import Godot's import, also on machines without a GPU.
optimizer_explain explain <topic> Why a finding costs performance in Godot, how the fix works, what to check after.
optimizer_demo demo <dir> Writes the heavy open-world demo project.

What the audit looks at

The runtime kit

fix install copies addons/gameoptimizer/ into the game and registers its autoloads. Plain GDScript, no
GDExtension, Godot 4.3+.

GOQuality.apply_tier(GOQuality.auto_detect())   # low, medium, high, ultra, cinematic
GOQuality.set_value("scaling_3d_scale", 0.67)   # one key, for a settings menu
GOGovernor.start(60)                             # hold 60 fps with dynamic resolution
GOSpawnQueue.instantiate_async("res://enemy.tscn", parent, func(node): ...)
await prewarm.run(["res://world/world_chunks/Town/c_0_0.tscn"])   # GOPrewarm, behind the loading screen

GOStreamer nodes are placed by partition. The full API is in
runtime/addons/gameoptimizer/README.md.

Limits

Development

npm test                      # no dependencies, no Godot
GO_TEST_GODOT=1 npm test      # also runs the runtime kit and a full optimize-and-measure in Godot

See AGENTS.md for the layout and the rules, and CONTRIBUTING.md for how to help.
Issues and pull requests are welcome; a finding that was wrong on your project, or a compare report from a real
GPU, helps the most.

If the optimizer saved you a profiling session, a star helps other Godot developers find it.

License

MIT, see LICENSE.