← All writing StarCraft Ghost / OpenNOD

Building a Toolset for StarCraft: Ghost

Turning reverse-engineered NOD formats into a GtkRadiant editor, a source-preserving level workflow, and native test maps for the surviving Xbox build.

OpenNOD SDK could show me what was inside a StarCraft: Ghost level. The recompilation work let me run the game. Neither answered the next question: could I open an existing level, change something, and hand it back to the game without breaking the parts I hadn’t decoded?

That question led to OpenNOD Radiant, a GtkRadiant fork backed by the SDK’s parsers and compilers. I used the original NOD editor, Embrace, as a workflow reference. The aim wasn’t to recreate every panel. It was to make a useful editor for repairing existing maps and, eventually, reconstructing missing ones where the surviving build already has an entry point.

Radiant's map views, the standalone NOT Editor, and a custom map running in StarCraft: Ghost Figure 1. Three views of the workflow: author the map in Radiant, inspect shared definitions in NOT Editor, and check the compiled result in the game.


A Level Is More Than Its Geometry

A Ghost level isn’t a single file. Three files can share a name and describe different parts of the same level:

File What it describes
.nil Level sectors, geometry, baked lighting, and collision.
.nsd Scene placements, instance modifiers, and native behavior data.
.npd Navigation waypoints and directed links.

Those files also refer to resources outside the level: materials in NSA archives, models in NOD files or NMB bundles, and object templates in NOT archives. A room can look right in the editor even if its floor has no usable collision or the entity in the corner resolves to the wrong template. A screenshot is a useful check, but it can’t tell me either of those things.


Miners Bunker: Change One Thing

I used Miners Bunker to test the import workflow. NODscene converts the native level into an editable .map and keeps the original NIL, NSD, and NPD bytes in a matching .nodsrc sidecar. The MAP is what I work on in Radiant. The sidecar is what lets the compiler preserve records it doesn’t know how to regenerate.

Imported Miners Bunker in Radiant with the Entities inspector open on a region Figure 2. An early Miners Bunker import. The viewport shows the level geometry and placements; the inspector shows properties from a selected region.

The useful baseline is a no-edit round trip: compile the imported map and compare the result byte for byte. Then change a supported field and check what changed. For example, I can edit a supported scene parameter or waypoint without asking a geometry compiler to recreate the original baked lighting and collision.

This path doesn’t compile arbitrary brush, material, or UV changes back into an imported level. It also doesn’t make the sidecar a file to share: it contains original game data. The game assets stay read-only, and edits and compiled output go into a separate workspace.


A Template Is Not an Instance

One of the important editor decisions was to use the game’s actual NOT templates as placeable objects. A template’s name identifies it; the runtime class it resolves to tells the game how to handle it. Those aren’t interchangeable. Two templates can use the same runtime class and still have different models or defaults.

Radiant's entity creation menu showing the carrier_prop template under Protoss props Figure 3. Browsing named NOT templates through Radiant’s entity creation menu.

Radiant loads the global definitions and the additional NOT archives in the map’s specified order. The inspector can show an inherited value, where it came from, and whether the selected instance overrides it. Removing an override reveals the inherited value again. It doesn’t write a new default to the shared template.

That separation makes it possible to start a blank MAP without borrowing an NSD from another level. Place a known template, position it, and override only what this instance needs. If a shared definition actually needs repair, that’s a separate edit in NOT Editor, on a workspace copy.


From Radiant Brushes to a NIL Level

In Radiant, a wall is a brush: a convex solid defined by planes. Each face has a material and a texture projection. When I move a wall or shift its texture, Radiant saves those authoring decisions in a text .map, alongside entity properties such as origins and light settings. The viewport can draw that source directly. Ghost can’t load it.

Radiant’s Bsp > Convert NOD level command hands the MAP to the SDK tools, not to Quake’s q3map2. Here is the world compiler path alongside the two companion exports:

Radiant .map
  |-- MAPtoNIL: brush half-spaces -> CSG boundary -> triangle mesh
  |                                              |-- original mesh for shadow rays
  |                                              `-- lighting subdivision, if enabled
  |                                                   |-- render groups + baked color
  |                                                   `-- collision mesh + MOPP
  |                                                        -> .nil with both streams
  |-- MAPtoNSD: placements + native behavior data -> .nsd
  `-- MAPtoNPD: waypoints + directed links        -> .npd

Brush reconstruction and CSG. Each brush is the intersection of its plane half-spaces. MAPtoNIL clips away the portions of faces that lie inside other solids and removes opposing faces at shared boundaries. Before triangulation it welds coincident seam points and inserts T-junction vertices. If one side of a seam has a vertex halfway along an edge, the other side needs the same split; otherwise the meshes can appear joined but disagree about where an edge begins and ends. The split fragments keep their source face, so new vertices get UVs from the original projection rather than a new projection fitted to each triangle.

Sector layout and collision. NIL fills the role of a compiled world file, but it isn’t a Quake BSP with a different extension. A Quake III BSP stores a partition tree with nodes and leaves, visibility data, and lightmaps. Ghost’s NIL v35 stores per-sector boundary planes, vertex pools, index buffers, and surfaces grouped by material. The current compiler emits one sector with no boundary planes, so its sector membership test covers all space. The physics bounds still enclose the collision geometry; they don’t act as sector boundaries.

The compiler emits a separate Havok triangle mesh and MOPP bytecode to accelerate collision queries. A collision hit returns a triangle key, not a render vertex or a byte offset. The group mappings use that key to recover the surface group, and collision material records use it to pick a sound type. Reordering the collision triangles without rebuilding those mappings could leave the floor looking and colliding correctly while returning the wrong surface or sound.


What the Lighting Pass Actually Bakes

I think of this as the job a lightmap pass does in a Quake toolchain: take the lights and the level geometry and work out what parts of the room should be bright or in shadow. But NIL v35 doesn’t store a separate lightmap texture atlas. It stores baked diffuse color on the world vertices, and the renderer interpolates those colors across each triangle.

Sampling density. Put a small lamp beside a large wall with only four corner vertices. The corners can all be dim even though the middle of the wall should be bright. You can’t recover the missing highlight by interpolating those four colors. The compiler splits long edges at a spacing controlled by nod_light_spacing and propagates the splits across adjacent triangles. Shadow rays still query the original, coarser mesh through a spatial index. Smaller spacing can resolve more detail, but it increases the triangle count and the number of lighting queries; the compiler reports when subdivision or ray work exceeds its budget.

Direct lighting. For a point-light sample, let d be the distance to the light, L the unit vector toward it, N the surface normal, and f the light’s falloff coefficient. With shadows enabled, a blocked ray contributes zero. Otherwise the compiler scales the light’s RGB by:

point weight = max(0, dot(N, L)) * intensity / (1 + f*d + 1.2*f*d*d)

The bake can average four nearby samples and add directional and ambient terms. It clamps the result and packs it into the D3DCOLOR field at byte 24 of each 36-byte primary vertex. The texture UVs remain material UVs; there’s no second set of coordinates to look up baked light. This is a direct-light bake, not an indirect-light or bounce solver.

A custom Ghost test room with magenta and green illumination across its gridded surfaces Figure 4. Colored lighting in a compiled test room, viewed in the game. The grid material makes the falloff across the walls easier to see.

The compiler also writes separate static-light records for moving objects. A wall can have correctly baked shading and still tell me nothing about how an NPC will be lit when it walks past. The NIL lighting notes explain why those are two different inputs. Moving a lamp in the MAP is a small edit; seeing its new light and shadow in the game requires rebuilding the affected data.


Testing a New Room

For a new test map there are no original level bytes to preserve. Alongside MAPtoNIL, MAPtoNSD writes placements and supported behavior data, and MAPtoNPD writes the authored navigation graph. NODtoNMB can build model bundles separately. The level compilers don’t automatically collect every resource the map refers to.

The mapping workspace gives those tools small problems to solve. One test map connects an objective region to a gate. Walk into the region, complete the objective, and see whether the gate opens. Putting that interaction in a small map makes it easier to tell whether a failure is in the trigger, the objective, or the receiving object.

The game runs the existing native handlers. Even NODScript expands supported sequences into native records; it doesn’t introduce a scripting runtime or new engine classes. The test maps use a separate game installation for validation. A successful export still isn’t proof that player startup, collision, audio, or a mission transition will behave as intended.

The 0.6.8 custom-map showcase shows those tests running in GhostPC. The simpler rooms isolate changes like the fog range or a sound trigger. Later maps combine doors, movers, spawning, and mission transitions. The Protoss courtyard is a prototype rather than a mission: it’s a place to try layouts and props without having to build a campaign around them.

Getting a custom map to play in Ghost was satisfying. One of the best moments, though, was opening the compiled level in my own OpenNOD Asset Viewer and seeing the room I had built. I had written the viewer to make sense of the original game data. Now it was reading data I’d generated from scratch.

OpenNOD Asset Viewer displaying the compiled Sky Ambient test room with its NIL details alongside the preview Figure 5. The compiled Sky Ambient test room in OpenNOD Asset Viewer.

The viewer gives me a check the game doesn’t: I can inspect the decoded geometry and material groups next to the rendered room. It doesn’t tell me whether a trigger will fire or the player can move through the level. For that I still need the game.

Seeing What Ghost Loaded

Finding Ghost’s built-in debug menu made the in-game check much more useful. The normal view shows the finished surface; wireframe shows how the compiler actually split it into triangles. The framedisp overlay reports world, model, and effect triangles separately, so I can look at the world count after changing the lighting subdivision without mixing it up with what the actors or effects are drawing.

Ghost's frame diagnostics overlay showing separate world, model, and effect triangle counts Figure 6. The framedisp overlay in GhostPC, with separate triangle counts for world geometry, models, and effects, plus a sector count.

The physics overlay gives me another view of the same room: outlines and volumes around the player and scene objects that aren’t visible in normal play. The individual modes and colors aren’t all decoded, so I use those outlines as clues, not as proof that collision is correct. The viewer tells me what the SDK read back; the debug overlays show what the running game is drawing; playing the map is still how I check what it does.


Where It Stands

The 0.6.8 preview puts the editor, SDK, and test maps into one workflow. That gives me a way to ask a smaller, more useful question than whether the entire toolchain works: can I make this specific change, keep the rest of the level intact, and observe the expected result in the game?

When I shared the mapping preview on Reddit, someone asked whether a team was planning to continue Ghost’s story. That’s not what I’m building. My part is the compiler and editor work that gives a mapper something to build with. It also follows years of discoveries by people who kept looking at the game long before these tools existed.

It’s not a replacement for Embrace, and it’s not a finished level-restoration pipeline. But the gap between looking at a Ghost level and making a controlled change to one is much smaller now.