<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://aknavj.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://aknavj.github.io/" rel="alternate" type="text/html" /><updated>2026-12-02T00:35:33+00:00</updated><id>https://aknavj.github.io/feed.xml</id><title type="html">aknavj</title><subtitle>Just a guy interested in graphics art, graphics programming, and game development.</subtitle><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><entry><title type="html">Refactoring Doom 3’s Path Tracer: CUDA, OpenCL, and Renderer Correctness</title><link href="https://aknavj.github.io/graphics/2026/11/28/Refactoring-Path-tracer-for-Doom3.html" rel="alternate" type="text/html" title="Refactoring Doom 3’s Path Tracer: CUDA, OpenCL, and Renderer Correctness" /><published>2026-11-28T00:00:00+00:00</published><updated>2026-11-28T00:00:00+00:00</updated><id>https://aknavj.github.io/graphics/2026/11/28/Refactoring-Path-tracer-for-Doom3</id><content type="html" xml:base="https://aknavj.github.io/graphics/2026/11/28/Refactoring-Path-tracer-for-Doom3.html"><![CDATA[<p>In the <a href="/graphics/2026/02/28/Implementing-Path-tracer-in-CUDA-for-Doom-3.html">first version</a>, Doom 3’s render backend handed its draw surfaces and lights directly to a CUDA renderer. That was enough to play the game, but the code that interpreted a Doom 3 material was tied to the code that uploaded it to the GPU. A second compute backend would either have to duplicate that interpretation or share it somewhere above the device code.</p>

<p>I used CUDA as the reference implementation: first get it running behind the new interface, then port the device pipeline to OpenCL without duplicating scene extraction. I handed the refactor itself to AI agents, which also did most of the work on material rendering. The first implementation was roughly <strong>70% my effort and 30% AI</strong>; across the refactor and follow-up work, I’d reverse those numbers. Those are estimates of effort, not measurements.</p>

<hr />

<h2 id="splitting-scene-extraction-from-gpu-execution">Splitting Scene Extraction from GPU Execution</h2>

<p>On <a href="https://github.com/aknavj/dhewm3-cupt/commits/pt-refactor"><code class="language-plaintext highlighter-rouge">pt-refactor</code></a>, <code class="language-plaintext highlighter-rouge">renderer_pt</code> takes over the engine-facing work. It flattens draw surfaces into triangles, evaluates material stages and light parameters, and collects pending textures in <code class="language-plaintext highlighter-rouge">idPathTracerScene</code>. The <a href="https://github.com/aknavj/dhewm3-cupt/blob/058ec20/neo/renderer_pt/pt_backend.h"><code class="language-plaintext highlighter-rouge">idPathTracerBackend</code> interface</a> then separates scene data from the parameters used to render a view:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>UploadScene(idPathTracerScene)   -&gt; upload scene data and rebuild the linear BVH (LBVH)
Render(ptRenderParams_t)         -&gt; trace, accumulate, optionally denoise, tone-map
ReadPixels(dest, width, height)  -&gt; copy the finished RGBA8 image for presentation
</code></pre></div></div>

<p>The backend owns device buffers and two distinct kinds of history: the raw running mean and the denoiser’s reprojectable history. <code class="language-plaintext highlighter-rouge">ResetAccumulation(false)</code> clears the mean without discarding the latter. That distinction matters when the camera moves: old samples no longer belong in the same pixel’s running mean, but the denoiser can still try to find the corresponding surface in the previous view.</p>

<p>I got CUDA working behind this interface before starting the <a href="https://github.com/aknavj/dhewm3-cupt/commit/d756997">OpenCL 1.2 port</a>. The second backend came together much faster than I expected: the agent had working CUDA kernels to compare against and didn’t have to touch the engine integration. Most of the pipeline carried over in the same order, but a few stages needed different implementations:</p>

<table>
  <thead>
    <tr>
      <th>Stage</th>
      <th>CUDA</th>
      <th>OpenCL 1.2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Texture storage</td>
      <td>Device pointers to texels</td>
      <td>One texel pool with descriptors locating each texture</td>
    </tr>
    <tr>
      <td>Morton-key sort</td>
      <td>CUB radix sort</td>
      <td>Stable least-significant-digit radix sort</td>
    </tr>
    <tr>
      <td>BVH bounds</td>
      <td><code class="language-plaintext highlighter-rouge">__threadfence()</code> before the atomic parent signal</td>
      <td>Publish bounds through atomics across work-groups</td>
    </tr>
  </tbody>
</table>

<p>The OpenCL backend checks shared struct layouts at startup. The <a href="https://github.com/aknavj/dhewm3-cupt/blob/058ec20/neo/renderer_pt/tests/pt_opencl_lbvh_test.cpp">LBVH test</a> checks the sort order against <code class="language-plaintext highlighter-rouge">std::stable_sort</code>, compares child indices with a CPU reference, and follows escape links to verify that each triangle is reachable exactly once. Those checks don’t establish image parity. On an Intel device, for example, <code class="language-plaintext highlighter-rouge">tan(pi/4)</code> returned the next representable float above <code class="language-plaintext highlighter-rouge">1.0</code>, shifting SVGF reprojection off the expected pixel grid. For a 90° field of view, computing the half-angle tangent as <code class="language-plaintext highlighter-rouge">tanpi(90 / 360.0)</code> gives exactly <code class="language-plaintext highlighter-rouge">1.0</code>.</p>

<h2 id="tracing-rays-through-the-bvh">Tracing Rays Through the BVH</h2>

<p>For a shadow ray, an eligible opaque hit can terminate traversal immediately; there’s no need to find the closest triangle. An alpha-tested hit still has to sample the cutout before it can count as a blocker. The <a href="https://github.com/aknavj/dhewm3-cupt/commit/0754abf">CUDA pass</a> that introduced this also replaced per-pixel <code class="language-plaintext highlighter-rouge">curand_init</code> with PCG and moved Morton-key sorting from Thrust to CUB with persistent scratch storage.</p>

<p>Together, the changes nearly halved the time it took to render a frame: from 74 to 39 milliseconds in one <code class="language-plaintext highlighter-rouge">alphalabs1</code> run at 320 × 240. That run doesn’t tell us how much of the gain came from shadow traversal alone.</p>

<p>A <a href="https://github.com/aknavj/dhewm3-cupt/commit/1da1eae">later pass</a> removed traversal stacks. Each node gained an escape link to the next node outside its subtree. On a miss, the ray follows that link, skipping every descendant without having to push and pop pending nodes.</p>

<p>The <a href="https://github.com/aknavj/dhewm3-cupt/commit/514bc45">LBVH bug</a> was in tree construction, not traversal. The smallest example is a scene with three triangles. After sorting them by Morton code, the root should cover indices <code class="language-plaintext highlighter-rouge">0</code> through <code class="language-plaintext highlighter-rouge">2</code>. The builder first doubles a search bound until it’s beyond the range, then works back down in powers of two to find the last index. Here the bound normally reaches <code class="language-plaintext highlighter-rouge">4</code>, so the second search starts by trying a step of <code class="language-plaintext highlighter-rouge">2</code>. An old safety clamp cut the bound back to <code class="language-plaintext highlighter-rouge">3</code>, leaving the second search with only a step of <code class="language-plaintext highlighter-rouge">1</code>. The third triangle never made it into the tree.</p>

<p>The fix was to remove the clamp. The lookup already returns <code class="language-plaintext highlighter-rouge">-1</code> for any index outside the triangle array, so it can test offset <code class="language-plaintext highlighter-rouge">4</code> without reading past the end.</p>

<h2 id="translating-a-draw-not-just-a-material-name">Translating a Draw, Not Just a Material Name</h2>

<p>Doom 3 evaluates stage conditions, colors, and texture transforms using shader registers supplied for the draw. Two entities can point to the same <code class="language-plaintext highlighter-rouge">idMaterial</code> and still supply different values. Caching the converted material by declaration alone conflates those draws. The scene converter instead keeps separate evaluated slots where those values differ. The intersection code also has to agree with the shading code: if the camera path transforms the UVs of a cutout but the shadow path tests the original UVs, the holes in the surface and its shadow no longer line up.</p>

<p>The flashlight beam is a useful example of what those stages can do. In OpenGL, one pass writes the beam mask into the framebuffer’s alpha channel without touching RGB. The dust pass then blends with <code class="language-plaintext highlighter-rouge">GL_DST_ALPHA, GL_ONE</code>, multiplying its color by the mask that’s already there:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>alpha_dst = mask
rgb_out   = rgb_dst + dust_rgb * alpha_dst
</code></pre></div></div>

<p>The path tracer had skipped the first pass because it didn’t write any color. That left the dust unmasked, making the outline of the beam mesh visible. The <a href="https://github.com/aknavj/dhewm3-cupt/blob/058ec20/neo/renderer_pt/pt_scene_material.cpp#L464">material converter</a> now carries the preceding mask texture, evaluated alpha, and UV transform into the additive stage. If it can’t find a supported resident mask, it warns and omits the overlay rather than drawing the full beam.</p>

<h2 id="why-rejecting-surface-history-also-disabled-fog-filtering">Why Rejecting Surface History Also Disabled Fog Filtering</h2>

<p>The SVGF implementation keeps separate diffuse and specular histories so a filter suited to diffuse lighting doesn’t smear reflections. Volumetric radiance is filtered separately too, but its eligibility originally depended on the surface depth guide. Transparent and mixed-material pixels could clear that depth to reject unreliable surface reprojection. The volume filter read that same zero as “do not filter,” even when the pixel still contained noisy fog.</p>

<p><img src="/assets/img/posts/d3pt-refactor/enpro-frame-00300-render.png" alt="Enpro frame 300 with noisy fog between two marines" />
<img src="/assets/img/posts/d3pt-refactor/enpro-frame-00300-coverage.png" alt="Denoiser coverage view of Enpro frame 300 highlighting the transparent region in red" />
<strong>Figure 1.</strong> Enpro frame 300 at 8 samples per pixel (spp) and its coverage diagnostic, not a before-and-after pair. Red marks transparent pixels, including the noisy region between the marines. Yellow marks dynamic pixels eligible for spatial filtering only; green marks static coverage.</p>

<p>The <a href="https://github.com/aknavj/dhewm3-cupt/commit/191e491">coverage fix</a> gave the volume pass its own <code class="language-plaintext highlighter-rouge">volumeDepth</code>, taken from the first visible layer. It also let compatible opaque mixtures use neighboring pixels without borrowing samples from previous frames.</p>

<p>The biggest improvement was in the transparent areas marked red in the diagnostic. Compared with the old filter, the new one cut the color error there by about 80%. Across the whole image, the error fell by about 25%.</p>

<p>For that comparison, I rendered the same frozen 800 × 600 view at 8 samples per pixel with each filter. I measured how far the pixel colors were from an unfiltered 128-sample reference using mean squared error, which gives larger differences more weight. With filtering turned off, both versions exported identical PNGs. The numbers tell us how closely the filters matched the reference on one frame, not how stable they were in motion.</p>

<p>In live gameplay, fresh spatial samples along mixed-material edges could shimmer without stable history. The final implementation leaves the sampling loop alone and gates the expanded coverage when it writes the guides: outside capture mode it clears <code class="language-plaintext highlighter-rouge">volumeDepth</code> and restores the accumulated fallback for mixed pixels. The same renderer can then use the broader filter for fixed-sample captures without imposing it on gameplay.</p>

<h2 id="doom-3s-demo1-path-traced">Doom 3’s <code class="language-plaintext highlighter-rouge">demo1</code>, Path-Traced</h2>

<p>For the benchmark I started with <code class="language-plaintext highlighter-rouge">demo1.demo</code>, the same recording I’d use to test the stock OpenGL renderer with <code class="language-plaintext highlighter-rouge">timedemo demo1</code>. I wanted to see how the path tracer handled a sequence I already knew as a benchmark, rather than record a new run for it. For example, <a href="https://github.com/aknavj/dhewm3-cupt/blob/058ec20/Benchmark.md"><code class="language-plaintext highlighter-rouge">r_ptBenchmark demo1.demo 32</code></a> replays <code class="language-plaintext highlighter-rouge">demo1</code> at 32 spp per recorded frame. That experiment became <a href="https://d3ptmark.github.io/">d3ptmark</a>.</p>

<p>The recording is the same; the work measured isn’t. Stock <code class="language-plaintext highlighter-rouge">timedemo</code> measures how fast OpenGL can draw the sequence. <code class="language-plaintext highlighter-rouge">r_ptBenchmark</code> holds each recorded view until the path tracer reaches the sample target, then advances. That lets me compare CUDA and OpenCL with the same demo, resolution, shading mode, and sample budget without treating the result as a stock <code class="language-plaintext highlighter-rouge">timedemo</code> score.</p>

<hr />

<h2 id="references">References</h2>

<ul>
  <li>Tero Karras, <a href="https://research.nvidia.com/publication/2012-06_maximizing-parallelism-construction-bvhs-octrees-and-k-d-trees">Maximizing Parallelism in the Construction of BVHs, Octrees, and k-d Trees</a>, High Performance Graphics, 2012. The radix-tree construction used by the LBVH builder.</li>
  <li>Christoph Schied et al., <a href="https://doi.org/10.1145/3105762.3105770">Spatiotemporal Variance-Guided Filtering: Real-Time Reconstruction for Path-Traced Global Illumination</a>, High Performance Graphics, 2017. The original SVGF method.</li>
  <li>Christoph Schied, <a href="https://github.com/cschied/q2vkpt">Q2VKPT — Quake II Vulkan Path Tracer</a>, 2019. A reference for separating lighting signals before denoising.</li>
  <li><strong>Project source:</strong> <a href="https://github.com/aknavj/dhewm3-cupt/tree/058ec20">dhewm3-cupt at <code class="language-plaintext highlighter-rouge">058ec20</code></a> — the CUDA and OpenCL implementations, regression tests, and benchmark code discussed here.</li>
  <li><strong>Benchmark:</strong> <a href="https://d3ptmark.github.io/">d3ptmark</a> — the Doom 3 path-tracing benchmark project.</li>
</ul>]]></content><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><category term="graphics" /><category term="path-tracing" /><category term="cuda" /><category term="opencl" /><category term="doom3" /><category term="idtech4" /><category term="graphics" /><category term="benchmarking" /><category term="ai" /><summary type="html"><![CDATA[A renderer case study covering the CUDA-to-OpenCL port, tree construction, Doom 3 material stages, and a controlled denoiser comparison.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aknavj.github.io/assets/img/posts/d3pt-refactor/compare_0003_pt_32spp.png" /><media:content medium="image" url="https://aknavj.github.io/assets/img/posts/d3pt-refactor/compare_0003_pt_32spp.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Building a Toolset for StarCraft: Ghost</title><link href="https://aknavj.github.io/reverse-engineering/2026/11/11/Creating-Toolset-For-StarCraft-Ghost.html" rel="alternate" type="text/html" title="Building a Toolset for StarCraft: Ghost" /><published>2026-11-11T00:00:00+00:00</published><updated>2026-11-11T00:00:00+00:00</updated><id>https://aknavj.github.io/reverse-engineering/2026/11/11/Creating-Toolset-For-StarCraft-Ghost</id><content type="html" xml:base="https://aknavj.github.io/reverse-engineering/2026/11/11/Creating-Toolset-For-StarCraft-Ghost.html"><![CDATA[<p><a href="/reverse-engineering/2026/07/14/What-the-Data-Remembers-NOD-Engine-Part-3.html">OpenNOD SDK</a> could show me what was inside a <em>StarCraft: Ghost</em> level. The <a href="/reverse-engineering/2026/10/10/Nova-signing-off.html">recompilation work</a> 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?</p>

<p>That question led to <strong>OpenNOD Radiant</strong>, a GtkRadiant fork backed by the SDK’s parsers and compilers. I used the original NOD editor, <strong>Embrace</strong>, 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.</p>

<p><img src="/assets/img/posts/scgmap/nodsdk-tools.jpg" alt="Radiant's map views, the standalone NOT Editor, and a custom map running in StarCraft: Ghost" />
<strong>Figure 1.</strong> Three views of the workflow: author the map in Radiant, inspect shared definitions in NOT Editor, and check the compiled result in the game.</p>

<hr />

<h2 id="a-level-is-more-than-its-geometry">A Level Is More Than Its Geometry</h2>

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

<table>
  <thead>
    <tr>
      <th>File</th>
      <th>What it describes</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">.nil</code></td>
      <td>Level sectors, geometry, baked lighting, and collision.</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">.nsd</code></td>
      <td>Scene placements, instance modifiers, and native behavior data.</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">.npd</code></td>
      <td>Navigation waypoints and directed links.</td>
    </tr>
  </tbody>
</table>

<p>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.</p>

<hr />

<h2 id="miners-bunker-change-one-thing">Miners Bunker: Change One Thing</h2>

<p>I used <strong>Miners Bunker</strong> to test the import workflow. <code class="language-plaintext highlighter-rouge">NODscene</code> converts the native level into an editable <code class="language-plaintext highlighter-rouge">.map</code> and keeps the original NIL, NSD, and NPD bytes in a matching <code class="language-plaintext highlighter-rouge">.nodsrc</code> 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.</p>

<p><img src="/assets/img/posts/scgmap/radiant-entity-templates.png" alt="Imported Miners Bunker in Radiant with the Entities inspector open on a region" />
<strong>Figure 2.</strong> An early Miners Bunker import. The viewport shows the level geometry and placements; the inspector shows properties from a selected region.</p>

<p>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.</p>

<p>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.</p>

<hr />

<h2 id="a-template-is-not-an-instance">A Template Is Not an Instance</h2>

<p>One of the important editor decisions was to use the game’s actual <strong>NOT templates</strong> 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.</p>

<p><img src="/assets/img/posts/scgmap/radiant-entity-templates-2.png" alt="Radiant's entity creation menu showing the carrier_prop template under Protoss props" />
<strong>Figure 3.</strong> Browsing named NOT templates through Radiant’s entity creation menu.</p>

<p>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.</p>

<p>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 <strong>NOT Editor</strong>, on a workspace copy.</p>

<hr />

<h2 id="from-radiant-brushes-to-a-nil-level">From Radiant Brushes to a NIL Level</h2>

<p>In Radiant, a wall is a <strong>brush</strong>: 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 <code class="language-plaintext highlighter-rouge">.map</code>, alongside entity properties such as origins and light settings. The viewport can draw that source directly. Ghost can’t load it.</p>

<p>Radiant’s <strong>Bsp &gt; Convert NOD level</strong> command hands the MAP to the SDK tools, not to Quake’s <code class="language-plaintext highlighter-rouge">q3map2</code>. Here is the world compiler path alongside the two companion exports:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Radiant .map
  |-- MAPtoNIL: brush half-spaces -&gt; CSG boundary -&gt; triangle mesh
  |                                              |-- original mesh for shadow rays
  |                                              `-- lighting subdivision, if enabled
  |                                                   |-- render groups + baked color
  |                                                   `-- collision mesh + MOPP
  |                                                        -&gt; .nil with both streams
  |-- MAPtoNSD: placements + native behavior data -&gt; .nsd
  `-- MAPtoNPD: waypoints + directed links        -&gt; .npd
</code></pre></div></div>

<p><strong>Brush reconstruction and CSG.</strong> Each brush is the intersection of its plane half-spaces. <code class="language-plaintext highlighter-rouge">MAPtoNIL</code> 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.</p>

<p><strong>Sector layout and collision.</strong> 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 <a href="https://github.com/aknavj/nodsdk-docs/blob/main/docs/formats/nil.md">NIL v35</a> 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.</p>

<p>The compiler emits a separate Havok triangle mesh and <strong>MOPP</strong> bytecode to accelerate collision queries. A collision hit returns a triangle key, not a render vertex or a byte offset. The <a href="https://github.com/aknavj/nodsdk-docs/blob/main/docs/implementation/nil-collision.md#surface-and-sound-lookups">group mappings</a> 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.</p>

<hr />

<h2 id="what-the-lighting-pass-actually-bakes">What the Lighting Pass Actually Bakes</h2>

<p>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 <strong>NIL v35 doesn’t store a separate lightmap texture atlas</strong>. It stores baked diffuse color on the world vertices, and the renderer interpolates those colors across each triangle.</p>

<p><strong>Sampling density.</strong> 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 <code class="language-plaintext highlighter-rouge">nod_light_spacing</code> 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.</p>

<p><strong>Direct lighting.</strong> For a point-light sample, let <code class="language-plaintext highlighter-rouge">d</code> be the distance to the light, <code class="language-plaintext highlighter-rouge">L</code> the unit vector toward it, <code class="language-plaintext highlighter-rouge">N</code> the surface normal, and <code class="language-plaintext highlighter-rouge">f</code> the light’s falloff coefficient. With shadows enabled, a blocked ray contributes zero. Otherwise the compiler scales the light’s RGB by:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>point weight = max(0, dot(N, L)) * intensity / (1 + f*d + 1.2*f*d*d)
</code></pre></div></div>

<p>The bake can average four nearby samples and add directional and ambient terms. It clamps the result and packs it into the <code class="language-plaintext highlighter-rouge">D3DCOLOR</code> 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.</p>

<p><img src="/assets/img/posts/scgmap/scghost-lightmap-calc-2.png" alt="A custom Ghost test room with magenta and green illumination across its gridded surfaces" />
<strong>Figure 4.</strong> Colored lighting in a compiled test room, viewed in the game. The grid material makes the falloff across the walls easier to see.</p>

<p>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 <a href="https://github.com/aknavj/nodsdk-docs/blob/main/docs/implementation/nil-lighting.md">NIL lighting notes</a> 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.</p>

<hr />

<h2 id="testing-a-new-room">Testing a New Room</h2>

<p>For a new test map there are no original level bytes to preserve. Alongside <code class="language-plaintext highlighter-rouge">MAPtoNIL</code>, <code class="language-plaintext highlighter-rouge">MAPtoNSD</code> writes placements and supported behavior data, and <code class="language-plaintext highlighter-rouge">MAPtoNPD</code> writes the authored navigation graph. <code class="language-plaintext highlighter-rouge">NODtoNMB</code> can build model bundles separately. The level compilers don’t automatically collect every resource the map refers to.</p>

<p>The <a href="https://github.com/aknavj/scghost-mapping">mapping workspace</a> 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.</p>

<p>The game runs the existing native handlers. Even <strong>NODScript</strong> 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.</p>

<p>The <a href="https://www.youtube.com/watch?v=WfjIk45mKME">0.6.8 custom-map showcase</a> shows those tests running in <a href="https://github.com/Tamamo-no-Bae/GhostPC">GhostPC</a>. 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.</p>

<p>Getting a custom map to play in <em>Ghost</em> was satisfying. One of the best moments, though, was opening the compiled level in my own <strong>OpenNOD Asset Viewer</strong> 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.</p>

<p><img src="/assets/img/posts/scgmap/tool-validation.png" alt="OpenNOD Asset Viewer displaying the compiled Sky Ambient test room with its NIL details alongside the preview" />
<strong>Figure 5.</strong> The compiled Sky Ambient test room in OpenNOD Asset Viewer.</p>

<p>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.</p>

<h3 id="seeing-what-ghost-loaded">Seeing What Ghost Loaded</h3>

<p>Finding <a href="https://github.com/aknavj/nodsdk-docs/blob/main/docs/game/debug-tools.md">Ghost’s built-in debug menu</a> 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 <code class="language-plaintext highlighter-rouge">framedisp</code> 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.</p>

<p><img src="/assets/img/posts/scgmap/scghost-debug-frame-toggled.png" alt="Ghost's frame diagnostics overlay showing separate world, model, and effect triangle counts" />
<strong>Figure 6.</strong> The <code class="language-plaintext highlighter-rouge">framedisp</code> overlay in GhostPC, with separate triangle counts for world geometry, models, and effects, plus a sector count.</p>

<p>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.</p>

<hr />

<h2 id="where-it-stands">Where It Stands</h2>

<p>The <strong>0.6.8 preview</strong> 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?</p>

<p>When I shared the <a href="https://www.reddit.com/r/StarCraft_Ghost/comments/1xeeyw9/starcraft_ghost_mapping_sdk_preview_release/">mapping preview on Reddit</a>, 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.</p>

<p>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.</p>

<ul>
  <li><a href="https://github.com/aknavj/nodsdk-radiant">OpenNOD Radiant</a> for the editor and Ghost profile.</li>
  <li><a href="https://github.com/aknavj/nodsdk-scghost">OpenNOD SDK</a> for the parsers, native editors, and compilers.</li>
  <li><a href="https://github.com/aknavj/nodsdk-docs/blob/main/docs/FORMAT_REFERENCE.md">Format reference</a>, <a href="https://github.com/aknavj/nodsdk-docs/blob/main/docs/IMPLEMENTATION.md">implementation notes</a>, and <a href="https://github.com/aknavj/nodsdk-docs/tree/main/docs/mapping">mapping guides</a> for the format details and supported authoring workflows.</li>
</ul>]]></content><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><category term="reverse-engineering" /><category term="reverse-engineering" /><category term="starcraft" /><category term="ghost" /><category term="nod-engine" /><category term="gtkradiant" /><category term="level-editing" /><category term="preservation" /><summary type="html"><![CDATA[Turning reverse-engineered NOD formats into a GtkRadiant editor, a source-preserving level workflow, and native test maps for the surviving Xbox build.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aknavj.github.io/assets/img/posts/scgmap/nodsdk-tools.jpg" /><media:content medium="image" url="https://aknavj.github.io/assets/img/posts/scgmap/nodsdk-tools.jpg" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Nova, Signing Off: One Last Shot at StarCraft Ghost</title><link href="https://aknavj.github.io/reverse-engineering/2026/10/10/Nova-signing-off.html" rel="alternate" type="text/html" title="Nova, Signing Off: One Last Shot at StarCraft Ghost" /><published>2026-10-10T00:00:00+00:00</published><updated>2026-10-10T00:00:00+00:00</updated><id>https://aknavj.github.io/reverse-engineering/2026/10/10/Nova-signing-off</id><content type="html" xml:base="https://aknavj.github.io/reverse-engineering/2026/10/10/Nova-signing-off.html"><![CDATA[<p>The asset viewer could show Nova’s model and the Mar Sara canyon. It could not run their gameplay. For that, I needed the original code to execute and receive the platform behavior it expected.</p>

<p>XboxRecomp offered a way to try it: translate the Xbox executable into code compiled for Windows, then supply a compatibility runtime. Could I get the surviving Ghost prototype through its menu and into a level?</p>

<hr />

<h2 id="one-last-shot">One Last Shot</h2>

<p>The <a href="/reverse-engineering/2026/07/14/What-the-Data-Remembers-NOD-Engine-Part-3.html">earlier investigation</a> had left me with Starev’s architecture skeleton and an asset viewer, OpenNOD SDK. Neither was a reconstructed runtime capable of playing Ghost.</p>

<p>Later, I came across <strong>XboxRecomp</strong>, a fresh project bringing original Xbox titles to modern platforms. Its existence was the spark: it looked worth trying as a wild experiment, using what I had learned without waiting for a manual source reconstruction to be complete.</p>

<p>This time, the result I wanted was a running game, not a reconstruction of what its files described.</p>

<p>I returned to IDA and the notes from my earlier architecture and file-format work. This was my first XboxRecomp approach, growing naturally from those investigations rather than another retry of the same port. The scope was the existing Xbox prototype running as a native Windows executable, not finishing the cancelled game.</p>

<p>It was also a chance to test XboxRecomp’s capabilities and push my own boundaries with recompilation. My usual area of expertise is elsewhere, so digging into emulation and the low-level mechanics behind this runtime was a learning process, not familiar ground. That made each working piece especially rewarding.</p>

<p><strong>The targets were specific:</strong></p>

<ul>
  <li>XInput support, tested with an Xbox One controller.</li>
  <li>Translate the Xbox’s NV2A graphics commands into Direct3D 11.</li>
  <li>Aim for a correctly rendered, sustained <strong>30 FPS</strong>.</li>
  <li>Leave keyboard controls, a second debug controller, and extra features out of scope.</li>
</ul>

<p>No new missions. No attempt to turn the prototype into the game Blizzard never shipped. Just let Nova walk around what is already there.</p>

<hr />

<h2 id="recompilation-not-recovered-source">Recompilation, Not Recovered Source</h2>

<p>XboxRecomp reads an <strong>XBE</strong>, the original Xbox executable format, disassembles its code, recovers function boundaries and calling conventions, and generates C that can be compiled for Windows. A compatibility runtime supplies the Xbox kernel and hardware behavior that the generated code still expects.</p>

<p>That distinction matters. This is not the original NOD source code, cleaned up and rebuilt with a newer compiler. The game still thinks it lives on an Xbox. Its memory layout, device registers, graphics commands, and callbacks all have to make sense in the new environment.</p>

<p>Ghost was an interesting test case: an early Nihilistic-era development build, built against <strong>Xbox SDK 5659</strong>, with the custom NOD engine rather than something widely used like RenderWare. The lack of optimization helps when reading the code, but it does not make the platform dependencies disappear.</p>

<p>Within about an hour of following the initial guide, I had something getting through the boot sequence. The first problem was file paths. Fixing those felt reassuringly ordinary.</p>

<p>Then the rest of the game arrived.</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Intro movies -&gt; Splash -&gt; Main menu -&gt; Level loading
                                           |
                                      Cinematic
                                           |
                                        Gameplay
                                           |
                            Pause / death / next level
</code></pre></div></div>

<p>Every arrow is another place where the game can wait for hardware, reach an undiscovered callback, or submit something the renderer does not understand. Getting through boot was not the same as getting through any of those transitions.</p>

<p>The intro had a separate presentation path: the game decoded the video and packed it as YUY2, a format storing brightness and shared color information, then programmed the NV2A’s PVIDEO overlay. Capturing the draw surface before that overlay was composited produced a black image even when the window showed video. The runtime needed to read the live overlay registers and composite the guest-decoded frame. A black intermediate buffer was not proof that decoding had failed.</p>

<hr />

<h2 id="the-missing-menu-scene">The Missing Menu Scene</h2>

<p>NOD already manages entities, visibility, animation, and material selection. I did not need to replace those systems. The graphics backend needed to reproduce what the game submitted.</p>

<p>The Xbox graphics path is not a collection of desktop Direct3D 8 calls waiting to be renamed. The game writes command buffers for the <strong>NV2A</strong>, and the backend has to interpret those commands and reproduce their behavior through D3D11. Texture layouts, fixed-function lighting, blending, stencil, clipping, and shader combinations all matter. So does keeping GPU output consistent with memory the game can read or modify.</p>

<p>The most useful lesson came from the main menu. The logo and <em>Press Start</em> were visible, but Nova and most of the room were missing. It looked like a renderer problem.</p>

<p><strong>It was a CPU translation problem.</strong></p>

<p>The x86 instruction <code class="language-plaintext highlighter-rouge">LAHF</code> copies status flags into the <code class="language-plaintext highlighter-rouge">AH</code> register. In the generated code, it had been translated as a no-op. Ghost’s camera math used the comparison results carried through those flags to choose a branch. Instead, it read stale bits and built the wrong camera matrix.</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Comparison -&gt; Status flags -&gt; LAHF -&gt; Branch -&gt; Camera matrix
                               |
                         Translated as no-op
</code></pre></div></div>

<p>Repairing one set of floating-point comparisons brought Nova and the room back. Repairing the other put the camera the right way up.</p>

<p>Those were two different instruction paths: SSE comparisons and x87 comparisons that transfer their results into the CPU flags. Before the repair, the camera matrix was already wrong when it reached D3D11, giving scene geometry a negative homogeneous <code class="language-plaintext highlighter-rouge">W</code> value. That value participates in clipping and perspective division, so valid draw submissions could still leave the scene missing. This was why counting successful draws did not locate the fault.</p>

<p>Changing the renderer’s projection matrix would have treated the symptom. Repairing the flag handling let the original camera code choose the intended branch.</p>

<hr />

<h2 id="a-controller-a-level-and-some-sound">A Controller, a Level, and Some Sound</h2>

<p>Input had its own version of the same problem. Mapping XInput buttons was only part of it: several original Xbox USB controller callbacks had not been discovered during translation. Recovering those routines and fixing transfer completion handling got the original input path moving. The physical Xbox One controller now works well, although its face buttons cannot reproduce the pressure-sensitive buttons of the original Xbox controller.</p>

<p>Recovering the callbacks also changed allocation order and exposed an audio assumption: a diagnostic DSP acknowledgement used a fixed guest address for its command mailbox. The correct location came from the programmed scratch-memory mapping, not a constant that happened to work earlier. Resolving that mapping fixed the initialization wait. It was still an acknowledgement passthrough, not execution of the Xbox’s audio DSP.</p>

<p>Level loading exposed more missing pieces. A broken translation of <code class="language-plaintext highlighter-rouge">memmove</code> produced an access violation. An audio command acknowledgement could leave loading stuck. Once those were repaired, the renderer reached line and point submissions it did not yet support.</p>

<p>The copy failure began in instruction discovery. Resynchronizing after a switch table had left supposed instruction starts inside other decoded instructions. The repair removed those overlapping starts and regenerated the affected copy routine, rather than replacing it with a workaround for this level.</p>

<p>These were separate dependencies in the loading path, not one renderer bug. Repairing them let execution reach the next unsupported operation.</p>

<p>Eventually, <strong>Scattered Forces</strong>, the Mar Sara canyon level, got through its briefing and into rendered gameplay. Not proof that every level works. But a substantial step beyond looking at its geometry in my asset viewer.</p>

<p>Sound was less cooperative.</p>

<p>The intro became audible, but gameplay effects were still largely absent. The Windows audio output kept receiving packets, which looked healthy in the logs. That did not mean the game was actually starting the sounds.</p>

<p>The missing gameplay cues came down to another translation error: a state transition used an unassigned comparison result and rejected the requested starts. Restoring the original transition rules brought gameplay sounds back.</p>

<p>A separate register-access bug explained some of the broken streaming. A native 64-bit access covered two adjacent Xbox audio registers, but the device bridge handled only the first half. Reading and writing both halves improved the sound considerably.</p>

<p>The access width was part of the device behavior, not just a C type detail. Both adjacent 32-bit registers needed their own operation, and paired writes needed to hold the audio-device lock across both. Otherwise the audio worker could observe a half-updated pair even after the missing second write was restored.</p>

<p><strong>Audible does not mean finished.</strong> Occasional crackles remain, and the Xbox audio DSP effects are not fully implemented. A continuously fed Windows audio queue is not proof of a correct soundtrack.</p>

<hr />

<h2 id="reducing-work-measuring-the-right-thing">Reducing Work, Measuring the Right Thing</h2>

<p>The performance work was mostly less glamorous than shader translation: stop recreating resources, stop uploading unchanged data, and stop doing diagnostic work inside hot loops.</p>

<p>In one comparable Debug replay, reusing texture resources and updating their contents changed the number of objects created:</p>

<table>
  <thead>
    <tr>
      <th>Metric</th>
      <th>Before</th>
      <th>After</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Texture objects created</td>
      <td>17,096</td>
      <td>82</td>
    </tr>
  </tbody>
</table>

<p>A separate gameplay replay avoided just over half of the constant-buffer uploads by checking whether the data had changed. These measurements describe reduced API work. Neither is a frame-rate result.</p>

<p>Tracing also checked an environment variable for every graphics command parameter, even when disabled. Moving that lookup out of the hot path removed diagnostic work from ordinary execution.</p>

<p>But the <strong>30 FPS target is still not achieved</strong>. Early steady-menu measurements were in single digits, and later intervals from lighter scenes cannot honestly be presented as proof that the whole game is now playable at the target speed.</p>

<p>Correctness stays ahead of the frame counter. Skipping a synchronization point or ignoring an unsupported draw might make the numbers nicer, but it would also make them meaningless.</p>

<hr />

<h2 id="working-with-an-agent">Working with an Agent</h2>

<p>Agentic pair programming helped a lot with this effort: tracing generated code, narrowing down access violations, writing focused repairs, and keeping the repetitive work manageable.</p>

<p>I usually knew which problem to tackle next. The agent accelerated the cycle of investigating a failure, implementing a repair, and testing again. That was a substantial change in how quickly I could reach a functional demo, not a substitute for checking its correctness.</p>

<p>It did not replace the loop of checking the original instructions in IDA, comparing behavior with Cxbx-Reloaded, and looking at what actually appeared on screen. The missing menu scene was a good reminder: thousands of successful draws can still produce the wrong picture. Audio packets can still carry silence.</p>

<p>The useful loop was:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Observe a failure
  -&gt; Inspect the original and generated code
  -&gt; Form an explanation
  -&gt; Implement a focused repair
  -&gt; Check the running game
</code></pre></div></div>

<p>The agent helped with investigation and implementation. The original instructions and the game’s behavior remained the checks on the result.</p>

<hr />

<h2 id="someone-else-continued">Someone Else Continued</h2>

<p>Once I had a functional demo, I made my changes available as open source. Within days, a fellow developer picked up where I had left off, introduced enhancements, and shared their updates while crediting the initial work.</p>

<p>That handoff was one of the most rewarding results. Another developer could start from a working baseline instead of repeating the investigation. It is a concrete reason I value open source: my stopping point does not have to be the project’s stopping point.</p>

<hr />

<h2 id="the-code">The Code</h2>

<p>The effort lives in two repositories:</p>

<ul>
  <li><strong><a href="https://github.com/aknavj/xboxrecomp/tree/impl-scghost">XboxRecomp fork</a></strong> — use the <code class="language-plaintext highlighter-rouge">impl-scghost</code> branch, which contains the runtime and recompilation changes for Ghost.</li>
  <li><strong><a href="https://github.com/aknavj/scghost-recomp">scghost-recomp</a></strong> — the game-specific recompilation project.</li>
</ul>

<p>Keep both checkouts side by side under the same parent directory, not nested inside one another:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>    my-dir
    |
    +-- xboxrecomp       (branch: impl-scghost)
    |
    +-- scghost-recomp
</code></pre></div></div>

<p>From your chosen parent directory, you can clone that layout with:</p>

<div class="language-powershell highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="n">git</span><span class="w"> </span><span class="nx">clone</span><span class="w"> </span><span class="nt">--branch</span><span class="w"> </span><span class="nx">impl-scghost</span><span class="w"> </span><span class="nx">https://github.com/aknavj/xboxrecomp.git</span><span class="w"> </span><span class="nx">xboxrecomp</span><span class="w">
</span><span class="n">git</span><span class="w"> </span><span class="nx">clone</span><span class="w"> </span><span class="nx">https://github.com/aknavj/scghost-recomp.git</span><span class="w"> </span><span class="nx">scghost-recomp</span><span class="w">
</span></code></pre></div></div>

<p>To recompile the game yourself, follow the README and supporting documentation included in both projects for prerequisites, setup, and build instructions.</p>

<p>These are the code repositories, not a bundled copy of the game. Recompilation requires the Xbox prototype’s executable and assets separately. That build surfaced through an unofficial leak, not an authorized release; these projects do not include or distribute it.</p>

<p>For a look at the demo and the work shared around it:</p>

<ul>
  <li><strong><a href="https://lnkd.in/dbSFK2bN">Video demo</a></strong></li>
  <li><strong><a href="https://lnkd.in/dbPWs-RE">Community discussion</a></strong></li>
  <li><strong><a href="https://lnkd.in/dfMw8HVt">Pull request</a></strong></li>
</ul>

<hr />

<h2 id="signing-off">Signing Off</h2>

<p>As of October 4, the result is:</p>

<table>
  <thead>
    <tr>
      <th>Area</th>
      <th>Observed state</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Intro and menu</td>
      <td>Visible video and restored 3D menu</td>
    </tr>
    <tr>
      <td>Input</td>
      <td>Working Xbox One controller</td>
    </tr>
    <tr>
      <td>Gameplay</td>
      <td>Scattered Forces reaches rendered gameplay</td>
    </tr>
    <tr>
      <td>Audio</td>
      <td>Audible gameplay sounds, with occasional glitches</td>
    </tr>
    <tr>
      <td>Rendering</td>
      <td>Compatibility failures remain</td>
    </tr>
    <tr>
      <td>Performance</td>
      <td>Sustained 30 FPS target not achieved</td>
    </tr>
    <tr>
      <td>Completion</td>
      <td>No verified full playthrough</td>
    </tr>
  </tbody>
</table>

<p>That is the honest state of it. This is a working recompilation effort, not a finished PC port, and certainly not a completed <em>StarCraft Ghost</em>. The game data is still required separately; none of this makes Blizzard’s assets mine to redistribute.</p>

<p>When I began studying the binary, I just wanted to understand how Nihilistic had built it. The architecture skeleton and viewer each made part of that understanding tangible. Recompilation took a different route and finally brought the original gameplay into the experiment.</p>

<p>There are more things to fix. There always will be.</p>

<p>But the goal was never to spend the rest of my life finishing somebody else’s cancelled game. It was to give this particular prototype one last chance to run, and to learn something along the way.</p>

<p>Nova, signing off.</p>]]></content><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><category term="reverse-engineering" /><category term="reverse-engineering" /><category term="starcraft" /><category term="ghost" /><category term="nod-engine" /><category term="recompilation" /><category term="xbox" /><category term="directx" /><summary type="html"><![CDATA[Taking StarCraft Ghost from an Xbox prototype to a native Windows executable with XboxRecomp, a Direct3D 11 backend, and one last round of late-night debugging.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aknavj.github.io/assets/img/posts/scgmap/scghost-debug-frame-toggled.png" /><media:content medium="image" url="https://aknavj.github.io/assets/img/posts/scgmap/scghost-debug-frame-toggled.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">A Summer Internship in Linux: Building a LAN Arcade</title><link href="https://aknavj.github.io/engineering/2026/08/31/A-Summer-Internship-in-Linux.html" rel="alternate" type="text/html" title="A Summer Internship in Linux: Building a LAN Arcade" /><published>2026-08-31T00:00:00+00:00</published><updated>2026-08-31T00:00:00+00:00</updated><id>https://aknavj.github.io/engineering/2026/08/31/A-Summer-Internship-in-Linux</id><content type="html" xml:base="https://aknavj.github.io/engineering/2026/08/31/A-Summer-Internship-in-Linux.html"><![CDATA[<p>When school let out in 2026, I volunteered to look after my fourteen-year-old brother for the summer. Around his age, back in 2003, my childhood friend Ivo and I were figuring out how to get games running on the machines we had. I wanted my brother to have some of that experience, with the tools available now.</p>

<p>The real goal was to introduce him to <strong>Linux</strong>. I had a list of things I wanted him to learn, but a blank terminal and twenty commands to copy would have made it feel like another school assignment. We started with a better test: could he join a Minecraft server he had set up himself?</p>

<hr />

<h2 id="week-1-fedora-and-a-reason-to-open-the-terminal">Week 1: Fedora and a Reason to Open the Terminal</h2>

<p>We installed Fedora, got oriented in the filesystem, and used the package manager to install what we needed. We then set up both sides of Minecraft: the game client and the dedicated server.</p>

<p>The game gave every dry part of the exercise a reason to exist. Which directory were we in? Where did the server keep its files? What did it need before it could start? Getting into the world from the client told us more than seeing the server process in a list.</p>

<p>We did the basics without ChatGPT, Gemini, or another assistant. Later I let him try one. Some answers sounded convincing and still sent him in the wrong direction. By then he had enough context to check a suggestion against what was actually installed and what the machine was telling him.</p>

<hr />

<h2 id="week-2-edit-a-file-reload-the-page">Week 2: Edit a File, Reload the Page</h2>

<p>Next we configured <strong>Apache</strong> and pointed a <strong>Samba</strong> share at the web server’s document root. That let us edit the site from another machine and see the result in a browser. We started with plain HTML and added CSS once there was something to style.</p>

<p>It was a small site, but it made the distinction between two services concrete. Samba gave us a way to edit the file over the network. Apache served that same file to the browser. The browser didn’t need to know how the file got there.</p>

<hr />

<h2 id="week-3-four-vms-and-two-dedicated-servers">Week 3: Four VMs and Two Dedicated Servers</h2>

<p>We installed <strong>Proxmox</strong> on bare metal and created four experimental VMs with graphical desktops: two Windows guests and two Linux guests. One Windows VM hosted <strong>Half-Life Deathmatch</strong>. The Linux guests were for <strong>Quake III Arena</strong> and <strong>Minecraft</strong>. I no longer remember what I had planned for the fourth VM, which says something about how well we documented the first pass.</p>

<p><img src="/assets/img/posts/summer-internship/public/first-proxmox-instance.png" alt="Proxmox summary showing the four experimental virtual machines" />
<strong>Figure 1.</strong> The first Proxmox installation, with two Linux guests and two Windows guests.</p>

<p>Starting a dedicated server and joining it were separate tests. In Half-Life and Quake III, we could see the client in a real match, not just a server window claiming it had started.</p>

<p><img src="/assets/img/posts/summer-internship/public/first-proxmox-hlded.png" alt="Half-Life Deathmatch scoreboard during a dedicated server test" />
<strong>Figure 2.</strong> A match on the Windows Half-Life dedicated server.</p>

<p><img src="/assets/img/posts/summer-internship/public/first-proxmox-q3ded.png" alt="Quake III Arena match alongside the ioquake3 server console" />
<strong>Figure 3.</strong> The Quake III client next to the Linux dedicated server log.</p>

<hr />

<h2 id="week-4-hello-again-firewall-and-selinux">Week 4: Hello Again, Firewall and SELinux</h2>

<p>The <strong>MaNGOS</strong> World of Warcraft server was a bigger exercise. Getting one process to start was no longer enough. We had to understand which services depended on one another, how they were configured, and which values lived in SQL tables rather than configuration files.</p>

<p><code class="language-plaintext highlighter-rouge">localhost</code> also stopped being an abstract term. It was useful for services talking on the same VM, but it meant something different to a game client on another machine. We had to distinguish local connections, LAN addresses, and addresses that could eventually work from outside the house.</p>

<p>The last time I had set up MaNGOS was during <em>The Burning Crusade</em> era. Some of the instructions we found were about as current as my memory of the setup. The useful part was in the gaps: read what the services reported, check the firewall and SELinux, and work out which assumptions in the guide no longer held.</p>

<p><img src="/assets/img/posts/summer-internship/public/first-proxmox-wow-mangos.png" alt="World of Warcraft running beside output from the MaNGOS server" />
<strong>Figure 4.</strong> In the world at last, with the server still printing diagnostics beside the client.</p>

<hr />

<h2 id="weeks-5-9-rebuild-it-for-a-lan-party">Weeks 5-9: Rebuild It for a LAN Party</h2>

<p>We scrapped the first Proxmox setup and started over. This time we had a scenario: a winter LAN party for <strong>10-15 friends and family</strong>, with enough variety that we could change games without rebuilding the host between rounds.</p>

<p>Our shortlist included <em>Aliens versus Predator 2</em> and <em>Aliens vs. Predator</em> (2010), the <em>Duke Nukem Forever 2001 Restoration Project</em> and the 2011 release, <em>Half-Life</em> and <em>Half-Life 2</em>, <em>Unreal Tournament</em> (1999), <em>Jedi Outcast</em>, <em>Jedi Academy</em>, <em>Minecraft</em>, <em>Urban Terror 4</em>, and <em>World of Warcraft: Classic</em> and <em>The Burning Crusade</em>. That was the planning list, not a claim that every title was ready for guests.</p>

<p>We used a spreadsheet to map each game’s OS, CPU, memory, storage, and network requirements to a VM. For the shooters, the baseline was a recognizable <strong>Aknavj Arcade</strong> server name, up to 16 players, 20-minute rounds, no frag limit, and no friendly fire or bots where those settings applied. We kept each game’s map rotation and message of the day in its own configuration.</p>

<p><img src="/assets/img/posts/summer-internship/public/second-proxmox.png" alt="Proxmox guest list after the arcade rebuild" />
<strong>Figure 5.</strong> The second Proxmox setup, with guests assigned to specific arcade services.</p>

<p>The spreadsheet described what we wanted. It couldn’t rebuild a VM. We turned the useful parts of our shell history into separate setup, run, and update scripts, with game-specific settings kept apart from the scripts. We also configured startup rules so the servers wouldn’t depend on someone leaving a console window open.</p>

<p>The work lives on the <a href="https://github.com/aknavj/gssh/branches">gssh branches</a>, not on <code class="language-plaintext highlighter-rouge">main</code>. The <a href="https://github.com/aknavj/gssh/tree/hl1">Half-Life branch</a> is one example of that layout in practice. I used AI to help put together the <a href="https://github.com/aknavj/gssh/tree/www">Arcade dashboard</a>, which was meant to answer the questions the spreadsheet didn’t answer for a guest: <em>Is the server reachable? Which client do I need? How do I join?</em></p>

<hr />

<h2 id="what-was-ready-and-what-wasnt">What Was Ready, and What Wasn’t</h2>

<p>By the end of the summer, we had working game servers on the LAN, SMB shares for moving configuration files, and startup rules. We limited firewall access to the ports the services needed, disabled direct root SSH login on the guests, and kept SSH administration on the local network with password login disabled.</p>

<p>We did <strong>not</strong> make the Arcade publicly reachable. Public DNS and forwarding of game ports were still on the list, the per-game connection guide was only partly written, and we hadn’t tested the full setup with friends and family. Two people joining from inside the house was a good test. It wasn’t the same as a LAN party.</p>

<p>I wanted my brother to leave the summer knowing more than a handful of commands. By the time we rebuilt Proxmox, we were asking different questions: what does this server depend on, how do we know it works, and could we put it back together if the machine died? We still owe ourselves that LAN party. But I’d take those questions over a perfectly memorized list of Linux commands.</p>]]></content><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><category term="engineering" /><category term="linux" /><category term="fedora" /><category term="proxmox" /><category term="homelab" /><category term="game-servers" /><category term="networking" /><summary type="html"><![CDATA[Nine weeks of teaching my fourteen-year-old brother Linux, from a first Minecraft server on Fedora to an old-school LAN arcade on Proxmox.]]></summary></entry><entry><title type="html">Reversing a Dead Legend: Inside StarCraft Ghost’s NOD Engine - PART 3</title><link href="https://aknavj.github.io/reverse-engineering/2026/07/14/What-the-Data-Remembers-NOD-Engine-Part-3.html" rel="alternate" type="text/html" title="Reversing a Dead Legend: Inside StarCraft Ghost’s NOD Engine - PART 3" /><published>2026-07-14T00:00:00+00:00</published><updated>2026-07-14T00:00:00+00:00</updated><id>https://aknavj.github.io/reverse-engineering/2026/07/14/What-the-Data-Remembers-NOD-Engine-Part-3</id><content type="html" xml:base="https://aknavj.github.io/reverse-engineering/2026/07/14/What-the-Data-Remembers-NOD-Engine-Part-3.html"><![CDATA[<p>Reconstructing the source structure gave me a map of the engine. It did not give me a quick way to check whether I understood the files the engine loaded.</p>

<p>A viewer was a smaller target. If I could read a model, display its texture, and place it in a level, I could test part of that understanding without first rebuilding the game.</p>

<hr />

<h2 id="from-reconstruction-to-a-testable-tool">From Reconstruction to a Testable Tool</h2>

<p><a href="/reverse-engineering/2026/03/31/NOD-Engine-Architecture-Deep-Dive.html">Part 2</a> described Starev’s architecture skeleton. Completing the systems beneath it would be a large task, and a mistake in a file loader could remain hidden behind many unrelated failures.</p>

<p>I wanted a shorter feedback loop:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Study a loader and its data
  -&gt; Implement an independent parser
  -&gt; Inspect the decoded structure
  -&gt; Display the result
  -&gt; Revisit the interpretation when it disagrees
</code></pre></div></div>

<p>That became <strong>OpenNOD SDK</strong>, in the <code class="language-plaintext highlighter-rouge">nodsdk-scghost</code> project. Its immediate purpose is to inspect the data, not execute Ghost’s gameplay.</p>

<p>The viewer gives practical evidence for individual parts of the reconstruction. It is not proof that the whole architecture is correct, but it makes specific mistakes easier to find.</p>

<hr />

<h2 id="keep-parsing-separate-from-presentation">Keep Parsing Separate from Presentation</h2>

<p>The project has three main pieces:</p>

<table>
  <thead>
    <tr>
      <th>Component</th>
      <th>Purpose</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>C++17 parser library</td>
      <td>Read asset structures without requiring the original runtime</td>
    </tr>
    <tr>
      <td>OpenGL viewer with an ImGui interface</td>
      <td>Browse files, inspect fields, and preview supported content</td>
    </tr>
    <tr>
      <td>Blender import plugin</td>
      <td>Bring supported models, levels, and animations into another tool</td>
    </tr>
  </tbody>
</table>

<p>Separating the parsers from the viewer matters. The interpretation of a model file should not depend on the browser panel that displays it. The same understanding can support inspection, conversion, or another community tool.</p>

<p>The browser also gives access to more than images. Some files are better understood as lists of tracks, material properties, scene records, or audio entries.</p>

<hr />

<h2 id="start-with-something-you-can-see">Start with Something You Can See</h2>

<p>A model is a useful test because a wrong interpretation often leaves a visible result. Mesh layout, material assignment, skeleton information, and coordinate conventions all affect what appears on screen.</p>

<p>Textures provide another check. The viewer supports DDS and TGA images as well as Xbox packed texture resources. Showing the decoded image makes errors easier to recognize than reading header values alone.</p>

<p>But a plausible preview is not enough by itself. An interpretation still needs to agree with the record layout and work across more than one example. The display supplements the structural inspection; it does not replace it.</p>

<p>This is why the inspector and preview belong together. One shows what the parser read. The other shows what those values mean when used.</p>

<hr />

<h2 id="a-level-tests-the-connections">A Level Tests the Connections</h2>

<p>The next useful test is not a larger model. It is a group of files that depend on one another.</p>

<p>Level geometry describes the environment. Materials refer to textures. Scene data describes placements and entity types. Models supply visible objects.</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Level geometry -&gt; Material properties -&gt; Texture
Scene records  -&gt; Entity/model resolution -&gt; Placed object
</code></pre></div></div>

<p><img src="/assets/img/posts/scg_img0.png" alt="Asset browser rendering the Mar Sara canyon level" />
<strong>Figure 1.</strong> The Mar Sara environment displayed outside the original engine.</p>

<p>Bringing these pieces together tests more than whether each file opens. It tests whether references, transforms, and material relationships have been interpreted consistently.</p>

<p>The Mar Sara canyon is a useful example: terrain and structures provide a recognizable environment, while placed objects give positions and orientations something concrete to match against.</p>

<p>The current viewer uses entity-type resolution to find models it knows how to place. That is not the same as reproducing the game’s complete template and entity-construction path. Unresolved references and non-visual records remain useful information in the inspector.</p>

<p>In particular, a scene record can describe a script target or a trigger rather than something with a model. An inspector should make that distinction visible instead of treating every record as missing geometry.</p>

<hr />

<h2 id="animation-needs-more-than-a-file-name">Animation Needs More Than a File Name</h2>

<p>An animation inspector exposes duration, bone-track information, and the keys associated with each track. Those fields let me compare the parser’s output with the structure inferred from the loader.</p>

<p><img src="/assets/img/posts/scg_img2.png" alt="NAD animation inspector showing 1_1_g_Nova.nad" />
<strong>Figure 2.</strong> Inspecting Nova’s animation tracks rather than treating the clip as an opaque file.</p>

<p>Previewing supported animation adds another check: tracks need to correspond to the intended skeleton, and their values need to produce meaningful motion.</p>

<p>The Blender plugin provides a separate route into that data. It imports supported model and level formats, and imports NAD animation onto an active armature. That is useful for inspection in a familiar authoring environment, without requiring the original editor.</p>

<p>It does not reconstruct a complete cinematic. Actor animation is only one part of a sequence that can also require camera data, events, sound, and runtime behavior.</p>

<hr />

<h2 id="not-every-useful-preview-is-3d">Not Every Useful Preview Is 3D</h2>

<p>Scene inspection shows entity types and placement data. Material inspection exposes properties and resource names. Cutscene inspection can expose actor and event records without pretending to play the finished scene.</p>

<p>Audio banks benefit from the same approach. Listing entries and playing supported waves makes their organization easier to understand. Decoding a wave is separate from reproducing the game’s cue handling, mixing, and effects.</p>

<p>This is the broader purpose of the browser: give each format a view that makes its structure understandable. A table can be as useful as a rendered mesh.</p>

<hr />

<h2 id="what-the-viewer-proves">What the Viewer Proves</h2>

<p>The project documents format relationships and implements parsers, but support is not uniform. Reading a header, decoding a useful subset, and reproducing every field are different levels of understanding.</p>

<p>Likewise, displaying a scene is not running the game. The viewer does not recreate AI, physics, objectives, or mission scripting.</p>

<p>What it does provide is a way to test the boundary between stored data and the systems that consume it. If the same assumptions produce sensible geometry, references, and placements across files, they become more credible. When the result disagrees, there is a smaller problem to investigate than an entire reconstructed engine.</p>

<p>The earlier NOD SDK for <em>Vampire</em> helps as a comparison, but Ghost’s formats must be checked against this build. Similar names do not guarantee identical layouts or behavior.</p>

<hr />

<h2 id="a-foundation-for-community-tools">A Foundation for Community Tools</h2>

<p>The longer-term value is not limited to viewing Ghost’s assets. Documented formats and reusable parsers could support future modding work or help bring back parts of the NOD SDK toolchain for community development.</p>

<p>An inspector and importer are steps toward that goal, not a finished replacement for the original tools. Editing, exporting, and validating content for the runtime require more work.</p>

<p>Still, making the data readable is a useful beginning. It lets someone investigate a scene or animation without repeating every step of the original disassembly effort.</p>

<p>The tools also remain separate from the proprietary game data. Understanding a format does not confer permission to redistribute the assets stored in it.</p>

<hr />

<h2 id="the-progression-so-far">The Progression So Far</h2>

<p>The work had moved from curiosity to an architecture skeleton, then to a viewer that could test parts of the file-format understanding:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Read the binary -&gt; Map the architecture -&gt; Test the data in tools
</code></pre></div></div>

<p>These were related investigations, not planned stages of a complete engine rewrite.</p>

<p>Later, discovering XboxRecomp offered another experiment: use the original Xbox code through recompilation rather than wait for a manual source reconstruction to be complete. <a href="/reverse-engineering/2026/10/10/Nova-signing-off.html">The next article</a> follows that change of approach.</p>

<hr />

<h2 id="project-material">Project Material</h2>

<ul>
  <li><a href="https://github.com/aknavj/nodsdk-scghost">OpenNOD SDK source code (nodsdk-scghost)</a>: parser library, asset viewer, and Blender import plugin</li>
  <li>OpenNOD SDK format reference and implementation documentation</li>
  <li>Starev: the architecture reconstruction that preceded the viewer</li>
  <li>NOD Engine SDK v1.0, Nihilistic Software, 2000</li>
</ul>]]></content><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><category term="reverse-engineering" /><category term="reverse-engineering" /><category term="starcraft" /><category term="ghost" /><category term="nod-engine" /><category term="nihilistic" /><category term="asset-formats" /><category term="tooling" /><summary type="html"><![CDATA[Building OpenNOD SDK to test the understanding of Ghost's custom file formats and make the data accessible without reconstructing the entire engine.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aknavj.github.io/assets/img/posts/scg_img0.png" /><media:content medium="image" url="https://aknavj.github.io/assets/img/posts/scg_img0.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Reversing a Dead Legend: Inside StarCraft Ghost’s NOD Engine - PART 2</title><link href="https://aknavj.github.io/reverse-engineering/2026/03/31/NOD-Engine-Architecture-Deep-Dive.html" rel="alternate" type="text/html" title="Reversing a Dead Legend: Inside StarCraft Ghost’s NOD Engine - PART 2" /><published>2026-03-31T00:00:00+00:00</published><updated>2026-03-31T00:00:00+00:00</updated><id>https://aknavj.github.io/reverse-engineering/2026/03/31/NOD-Engine-Architecture-Deep-Dive</id><content type="html" xml:base="https://aknavj.github.io/reverse-engineering/2026/03/31/NOD-Engine-Architecture-Deep-Dive.html"><![CDATA[<p>The hardest part of reconstructing an engine is not finding a function to translate. It is knowing where that function belongs and what the surrounding code expects from it.</p>

<p>After the spare-time investigation described in <a href="/reverse-engineering/2026/02/03/Reversing-Dead-Legend.html">Part 1</a>, I stopped trying to expand in every direction. Starev needed a coherent outline before it needed more subsystem internals.</p>

<hr />

<h2 id="treating-the-engine-as-a-black-box">Treating the Engine as a Black Box</h2>

<p>I used the engine’s boundaries as a starting point. What enters a system? What does it call? Which resources does it need, and when does it release them?</p>

<p>This is a black-box view of the architecture, informed by disassembly. I can inspect the code, but do not need to understand every internal algorithm before identifying a module’s role.</p>

<p>For example, a physics startup call establishes that physics participates in application initialization. It does not establish how collision detection works. Recording the call and its surrounding dependencies is useful even while the physics implementation remains outside the reconstruction’s scope.</p>

<p>The process was to follow a known entry point, inspect its immediate calls, and turn those relationships into declarations and basic code structure. When a dependency led into a large subsystem, I recorded the boundary rather than treating a partial reading as a completed reconstruction.</p>

<p>The result is deliberately limited. <strong>Starev describes the shape of the application more completely than it implements the game.</strong></p>

<hr />

<h2 id="the-application-boundary">The Application Boundary</h2>

<p>The PC path begins in <code class="language-plaintext highlighter-rouge">WinMain</code>. It establishes the window and platform handles, starts the application through <code class="language-plaintext highlighter-rouge">tSequence</code>, and enters the Windows message loop.</p>

<p>Window handling and frame handling are related but separate responsibilities:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>WinMain
  -&gt; Establish the window and platform context
  -&gt; Start the application through tSequence
  -&gt; Process window messages
  -&gt; When active and no messages are pending:
       call tSequence::MainLoop
</code></pre></div></div>

<p>The window procedure handles events such as activation and input-device reacquisition. The sequence handles the application’s engine work.</p>

<p>This division gave the reconstruction a useful outer boundary. Win32 owns the message mechanism; the engine decides what to do during a frame. It also explains why the PC entry path should not be described as the Xbox implementation.</p>

<hr />

<h2 id="startup-happens-in-stages">Startup Happens in Stages</h2>

<p>In the current reconstruction, <code class="language-plaintext highlighter-rouge">tSequence</code> does not bring the entire engine online in its constructor. Startup is divided between <code class="language-plaintext highlighter-rouge">StartApplication</code> and <code class="language-plaintext highlighter-rouge">StartApplication2</code>.</p>

<p>The first stage establishes services and the initial presentation path. It opens memory support, reads options, starts debug and file services, and enters platform and renderer initialization. It also reaches input, camera and control startup, audio, effects, and the shell.</p>

<p>Resource handling appears in that path too: menu bundles are loaded, or resource logging is enabled instead. Initialization therefore involves both services and content.</p>

<p>The main loop then handles the initial video/state transition and reaches the second startup stage. That stage calls into UI, the game library, saves, scripting, additional simulation services, world rendering, and animation-related support before marking the application initialized.</p>

<p>The useful relationship is:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>StartApplication
  -&gt; Initial services, resources, and presentation

MainLoop
  -&gt; Initial video/state handling
  -&gt; StartApplication2
       -&gt; Additional game-facing services
       -&gt; Initialized state
</code></pre></div></div>

<p>This is an outline of the reconstructed path, not a claim that all those services are complete in Starev. It also makes the dependencies more concrete than saying “the engine starts everything.”</p>

<hr />

<h2 id="the-main-loop-is-a-dispatcher">The Main Loop Is a Dispatcher</h2>

<p>The next layer is <code class="language-plaintext highlighter-rouge">tSequence::MainLoop</code>. Its job is to coordinate work, not perform every subsystem’s work itself.</p>

<p>The current reconstruction advances timing, handles initial state, and checks flags before dispatching input, cutscene, sound, simulation, rendering, and UI work. It also performs video-related work, effect updates, and sequence updates.</p>

<p>The flags matter. A frame is not an unconditional list of “input, physics, draw, sound.” Some work is enabled only in the relevant application state; the skip-render path also bypasses input and presentation portions of this reconstruction.</p>

<table>
  <thead>
    <tr>
      <th>Boundary</th>
      <th>Responsibility visible from the loop</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Input</td>
      <td>Refresh the input path when enabled</td>
    </tr>
    <tr>
      <td>Cutscene</td>
      <td>Advance the active cutscene path</td>
    </tr>
    <tr>
      <td>Sound</td>
      <td>Dispatch audio work</td>
    </tr>
    <tr>
      <td>Simulation</td>
      <td>Dispatch game-state updates</td>
    </tr>
    <tr>
      <td>Rendering</td>
      <td>Update presentation and full-screen effects</td>
    </tr>
    <tr>
      <td>Shell and UI</td>
      <td>Update and draw the interface</td>
    </tr>
    <tr>
      <td>End of frame</td>
      <td>Present through the renderer when appropriate</td>
    </tr>
  </tbody>
</table>

<p>The table describes what the coordinator asks for. It does not describe the algorithms inside those systems.</p>

<p>This was a manageable way to reconstruct the first few layers: establish the conditions and calls at the top, then preserve the interfaces below them.</p>

<hr />

<h2 id="the-services-underneath">The Services Underneath</h2>

<p>The foundation gives the higher layers common operations: memory management, debugging, file access, timing, input, and resource lookup. Math code supplies shared calculations rather than belonging to one gameplay subsystem.</p>

<p>These services matter because calls to them recur throughout the application. Understanding file lookup once is more useful than treating every model or sound load as an unrelated operation.</p>

<p>Rendering has another boundary: higher-level model and animation handling sits above the Direct3D-facing code. A request involving a model does not belong at the same level as a device or texture operation, even if both ultimately contribute to the same frame.</p>

<p>The game-facing layer brings together worlds, scenes, entities, and templates. Simulation, AI, effects, and mission logic connect to that layer. In my work, these connections were primarily a map of responsibilities and interfaces; the deeper implementations were not comprehensively reconstructed.</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Platform and application sequence
              |
      Subsystem entry points
       /        |         \
 Presentation  Game state  Interface
       \        |         /
      Shared foundation and math
</code></pre></div></div>

<p>This is a responsibility map, not a complete dependency graph. The actual code has cross-system calls that need to be followed individually.</p>

<hr />

<h2 id="a-skeleton-is-useful-but-not-a-running-engine">A Skeleton Is Useful, but Not a Running Engine</h2>

<p>Source reconstruction has several different levels of progress:</p>

<ul>
  <li>A name and source path can identify a module.</li>
  <li>A declaration can record an interface.</li>
  <li>A reconstructed function can preserve a piece of control flow.</li>
  <li>A working implementation must also satisfy its dependencies and behave correctly.</li>
</ul>

<p>Starev contains work at different points along that progression. A source tree with files for physics, AI, or scripts should not be read as a completed implementation of those systems. Some files preserve little more than structure.</p>

<p>The skeleton helped me stop restarting. I could return to a known boundary and extend it in small steps instead of reopening the whole engine as an undifferentiated problem.</p>

<p>It did not make the remaining task small. Restoring the internals of a game library, renderer, simulation, and mission system would be a much larger effort than mapping their entry points.</p>

<hr />

<h2 id="a-smaller-way-to-test-the-understanding">A Smaller Way to Test the Understanding</h2>

<p>The reconstruction also raised questions about the custom files those systems consume. A plausible loader in pseudo-code is not enough to know that I have interpreted its data correctly.</p>

<p>Rather than wait for a reconstructed engine to run, I could test that understanding independently: read a model, inspect an animation, or assemble a level in a viewer.</p>

<p>That became the next step. <a href="/reverse-engineering/2026/07/14/What-the-Data-Remembers-NOD-Engine-Part-3.html">Part 3</a> describes OpenNOD SDK, a tool for making those file structures and relationships visible.</p>

<hr />

<h2 id="basis-for-this-reconstruction">Basis for This Reconstruction</h2>

<ul>
  <li>The development build’s <code class="language-plaintext highlighter-rouge">Star_d.exe</code>, studied through disassembly and decompiled pseudo-code</li>
  <li><a href="https://github.com/aknavj/scghost-rev">Starev source code (scghost-rev)</a>: reconstructed platform entry, <code class="language-plaintext highlighter-rouge">tSequence</code>, and surrounding subsystem interfaces</li>
  <li>NOD Engine SDK v1.0 for <em>Vampire: The Masquerade - Redemption</em>, used as historical context rather than an exact specification for Ghost</li>
</ul>]]></content><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><category term="reverse-engineering" /><category term="reverse-engineering" /><category term="starcraft" /><category term="ghost" /><category term="nod-engine" /><category term="nihilistic" /><category term="disassembly" /><summary type="html"><![CDATA[Mapping NOD as a black box: how Starev reconstructs the application boundary, staged startup, main loop, and connections between engine subsystems.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aknavj.github.io/assets/img/posts/scg_img0.png" /><media:content medium="image" url="https://aknavj.github.io/assets/img/posts/scg_img0.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Implementing a CUDA Path Tracer Inside Doom 3</title><link href="https://aknavj.github.io/graphics/2026/02/28/Implementing-Path-tracer-in-CUDA-for-Doom-3.html" rel="alternate" type="text/html" title="Implementing a CUDA Path Tracer Inside Doom 3" /><published>2026-02-28T00:00:00+00:00</published><updated>2026-02-28T00:00:00+00:00</updated><id>https://aknavj.github.io/graphics/2026/02/28/Implementing-Path-tracer-in-CUDA-for-Doom-3</id><content type="html" xml:base="https://aknavj.github.io/graphics/2026/02/28/Implementing-Path-tracer-in-CUDA-for-Doom-3.html"><![CDATA[<blockquote>
  <p>I’ve wanted to do this since 2004. It turned out to be both easier and harder than I expected.</p>
</blockquote>

<hr />

<h2 id="introduction">Introduction</h2>

<p>This is a writeup of a GPU path tracer I built into <strong>id Software</strong>’s <em>Doom 3</em>, using the <a href="https://dhewm3.org/">dhewm3</a> source port as a base. The renderer hooks into dhewm3’s backend, takes the geometry and lights the engine submits each frame, builds a bounding volume hierarchy on the GPU, and path traces the scene instead of rasterizing it. idTech 4 was obviously never designed for any of this, which is part of why I wanted to try.</p>

<p>I first played <em>Doom 3</em> on an AMD Duron 700 MHz with a Radeon 9250, a machine I still keep in a closet. The unified per-pixel lighting and stencil shadows made a lasting impression on me, and by 2008 I was writing hobby engines against the <em>Doom 3</em> SDK. A year later I put together my first path tracer — spheres only, closely modeled on <a href="http://www.kevinbeason.com/smallpt/">smallpt</a> and <a href="https://github.com/JarkkoPFC/tokaspt">tokaspt</a>. The code wasn’t good, but it convinced me the technique was within reach.</p>

<p>Combining the two had been on my list for a long time. Schied’s <a href="https://github.com/cschied/q2vkpt">Q2VKPT</a> showed in 2019 that real-time path tracing inside a classic id engine was practical, and <em>Doom 3</em> is arguably an even better candidate than <em>Quake 2</em>: the source is GPL, there are no baked lightmaps, and every light in the game is an explicit entity carrying position, color, radius, and projection parameters. dhewm3 adds a modern CMake build on top of that.</p>

<p>The approach is deliberately conservative: intercept what the engine submits each frame, upload it to CUDA, build a BVH, trace, and blit the result back through OpenGL. There is no engine rewrite and no new asset pipeline — the whole thing lives in a <code class="language-plaintext highlighter-rouge">renderer_cuda/</code> directory next to the stock <code class="language-plaintext highlighter-rouge">renderer/</code>, enabled by a single CMake flag.</p>

<!-- TODO(timeline): 
- **TODO date** — Scene extraction; triangles visible via the BVH debug mode.
- **TODO date** — LBVH build and traversal working at interactive rates.
- **TODO date** — Material conversion layer and direct lighting.
- **TODO date** — Cook-Torrance shading, indirect bounce, soft shadows.
- **TODO date** — Volumetric scattering and the artist-faithfulness passes.
-->

<p><strong>Source code:</strong> <a href="https://github.com/aknavj/dhewm3-cupt">github.com/aknavj/dhewm3-cupt</a></p>

<hr />

<h2 id="system-architecture">System Architecture</h2>

<p>dhewm3 renders a frame by calling <code class="language-plaintext highlighter-rouge">RB_DrawView()</code>, which rasterizes every visible surface. The path tracer replaces this call with <code class="language-plaintext highlighter-rouge">RB_CUDA_DrawView()</code>, which reads the same data structures but feeds them through six stages of its own. Figure 1 compares the two paths.</p>

<p><strong>Figure 1.</strong> Frame-level control flow — original GL rasterizer (left) and CUDA path tracer replacement (right).</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> DOOM 3 FRAME                              CUDA PATH TRACER
 ===========================               ===========================

 idSession::Frame()
       |
       v
 idRenderWorld::
   GenerateAllInteractions()
       |
       v
 idRenderBackend::
   ExecuteBackEnd()
       |
       v
 +---RB_DrawView()---+                     RB_CUDA_DrawView()
 |  (GL rasterizer)  | --- replaced by ---&gt;       |
 |                    |                     +------+------+
 | for each drawSurf  |                     |             |
 |   GL_DrawElements  |                  iterate       iterate
 | for each light     |                  drawSurfs     viewLights
 |   stencil shadows  |                     |             |
 |   light pass       |                     v             v
 +--------------------+               AddTriangle()  AddLight()
       |                              GetOrSetMaterial()
       v                                    |
 GL SwapBuffers                             v
                                      EndFrame()
                                        | cudaMemcpy --&gt; device
                                        | build LBVH
                                        v
                                      RenderView()
                                        | primary rays
                                        | BVH traversal
                                        | material eval
                                        | direct light + shadows
                                        | indirect bounce
                                        v
                                      ToneMap()
                                        | HDR --&gt; LDR
                                        v
                                      CopyToBackbuffer()
                                        | cudaMemcpy --&gt; host
                                        v
                                      glDrawPixels()
                                        |
                                        v
                                      [screen]
</code></pre></div></div>

<p><strong>Scene extraction.</strong> The first stage walks <code class="language-plaintext highlighter-rouge">backEnd.viewDef-&gt;drawSurfs</code> — the same list the GL renderer would consume — and copies vertex positions, normals, tangents, UVs, and indices into flat arrays. Entity transforms are baked into world space on the CPU. Materials are sourced from idTech 4’s <code class="language-plaintext highlighter-rouge">idMaterial</code> shader stages and flattened into a <code class="language-plaintext highlighter-rouge">cudaMaterial_t</code> struct. Lights are extracted from <code class="language-plaintext highlighter-rouge">backEnd.viewDef-&gt;viewLights</code>, with point, directional, and projected types mapped to a unified <code class="language-plaintext highlighter-rouge">cudaLight_t</code>.</p>

<p><strong>GPU upload.</strong> Scene data is transferred to device memory with <code class="language-plaintext highlighter-rouge">cudaMemcpy</code>. Materials and textures are pointer-cached across frames, so only new entries get uploaded. Lights are rebuilt every frame because they animate.</p>

<p><strong>BVH construction.</strong> A Linear BVH is built entirely on the GPU using the Karras (2012) algorithm — four custom kernels plus a Thrust radix sort. This is detailed in the Acceleration Structure section.</p>

<p><strong>Path tracing.</strong> One thread per pixel, launched in 16×16 tiles. Each thread fires a primary ray with sub-pixel jitter, traverses the BVH, evaluates materials, samples direct lighting, and optionally bounces for indirect illumination. Results accumulate into a <code class="language-plaintext highlighter-rouge">float4</code> HDR framebuffer. Listing 1 shows the core of the per-pixel kernel — primary ray generation through the bounce loop.</p>

<p><strong>Listing 1.</strong> Per-pixel path tracing with sub-pixel jitter and iterative bounce evaluation.</p>

<div class="language-cuda highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// per-pixel RNG seeded from pixel position + frame index</span>
<span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span> <span class="n">pixelSeed</span> <span class="o">=</span>
    <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span><span class="p">)(</span><span class="n">y</span> <span class="o">*</span> <span class="n">width</span> <span class="o">+</span> <span class="n">x</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1000003ULL</span>
    <span class="o">+</span> <span class="p">(</span><span class="kt">unsigned</span> <span class="kt">long</span> <span class="kt">long</span><span class="p">)</span><span class="n">frameIndex</span> <span class="o">*</span> <span class="mi">999983ULL</span><span class="p">;</span>
<span class="n">curandState</span> <span class="n">randState</span><span class="p">;</span>
<span class="n">curand_init</span><span class="p">(</span><span class="n">pixelSeed</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">randState</span><span class="p">);</span>

<span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">sample</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">sample</span> <span class="o">&lt;</span> <span class="n">samplesPerPixel</span><span class="p">;</span> <span class="n">sample</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
    <span class="c1">// primary ray with sub-pixel jitter</span>
    <span class="kt">float</span> <span class="n">jitterX</span> <span class="o">=</span> <span class="n">curand_uniform</span><span class="p">(</span><span class="o">&amp;</span><span class="n">randState</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.5</span><span class="n">f</span><span class="p">;</span>
    <span class="kt">float</span> <span class="n">jitterY</span> <span class="o">=</span> <span class="n">curand_uniform</span><span class="p">(</span><span class="o">&amp;</span><span class="n">randState</span><span class="p">)</span> <span class="o">-</span> <span class="mf">0.5</span><span class="n">f</span><span class="p">;</span>
    <span class="kt">float</span> <span class="n">u</span> <span class="o">=</span> <span class="p">((</span><span class="kt">float</span><span class="p">)(</span><span class="n">x</span><span class="p">)</span> <span class="o">+</span> <span class="mf">0.5</span><span class="n">f</span> <span class="o">+</span> <span class="n">jitterX</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="kt">float</span><span class="p">)</span><span class="n">width</span>  <span class="o">*</span> <span class="mf">2.0</span><span class="n">f</span> <span class="o">-</span> <span class="mf">1.0</span><span class="n">f</span><span class="p">;</span>
    <span class="kt">float</span> <span class="n">v</span> <span class="o">=</span> <span class="p">((</span><span class="kt">float</span><span class="p">)(</span><span class="n">y</span><span class="p">)</span> <span class="o">+</span> <span class="mf">0.5</span><span class="n">f</span> <span class="o">+</span> <span class="n">jitterY</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="kt">float</span><span class="p">)</span><span class="n">height</span> <span class="o">*</span> <span class="mf">2.0</span><span class="n">f</span> <span class="o">-</span> <span class="mf">1.0</span><span class="n">f</span><span class="p">;</span>

    <span class="n">cudaRay_t</span> <span class="n">ray</span><span class="p">;</span>
    <span class="n">ray</span><span class="p">.</span><span class="n">origin</span>    <span class="o">=</span> <span class="n">cameraPos</span><span class="p">;</span>
    <span class="n">ray</span><span class="p">.</span><span class="n">direction</span> <span class="o">=</span> <span class="n">normalize</span><span class="p">(</span><span class="n">cameraForward</span>
                   <span class="o">+</span> <span class="n">u</span> <span class="o">*</span> <span class="n">cameraRight</span> <span class="o">*</span> <span class="n">tanHalfFovX</span>
                   <span class="o">+</span> <span class="n">v</span> <span class="o">*</span> <span class="n">cameraUp</span>    <span class="o">*</span> <span class="n">tanHalfFovY</span><span class="p">);</span>

    <span class="kt">float</span> <span class="n">pathThroughput</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span> <span class="p">};</span>
    <span class="kt">float</span> <span class="n">pathRadiance</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>   <span class="o">=</span> <span class="p">{</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span> <span class="p">};</span>

    <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">iteration</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">iteration</span> <span class="o">&lt;</span> <span class="n">maxPasses</span> <span class="o">&amp;&amp;</span> <span class="n">depth</span> <span class="o">&lt;</span> <span class="n">maxDepth</span><span class="p">;</span>
         <span class="n">iteration</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">cudaHitInfo_t</span> <span class="n">hitInfo</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="n">IntersectBVH</span><span class="p">(</span><span class="n">ray</span><span class="p">,</span> <span class="n">vertices</span><span class="p">,</span> <span class="n">triangles</span><span class="p">,</span> <span class="n">bvhNodes</span><span class="p">,</span>
                          <span class="n">triIndices</span><span class="p">,</span> <span class="n">materials</span><span class="p">,</span> <span class="n">hitInfo</span><span class="p">))</span> <span class="p">{</span>
            <span class="c1">// sky or miss — accumulate and break</span>
            <span class="k">break</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="c1">// evaluate material, sample direct light, bounce...</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre></div></div>

<p>The outer <code class="language-plaintext highlighter-rouge">sample</code> loop runs the configured samples-per-pixel count. The inner <code class="language-plaintext highlighter-rouge">iteration</code> loop handles both bounces and transparent passes — alpha-tested surfaces, decals, and glass don’t increment the bounce depth, so a ray can pass through many transparent layers before it spends a bounce.</p>

<p><strong>Tone mapping.</strong> A post-processing kernel converts HDR to LDR using one of three selectable operators — Reinhard, ACES, or Uncharted 2 — followed by gamma correction.</p>

<p><strong>Blit.</strong> The final pixel buffer is copied back to host memory and drawn with <code class="language-plaintext highlighter-rouge">glDrawPixels</code>. There is no GL-CUDA interop yet; this was the simplest output path to get working, and it has stayed in place longer than it probably deserves to.</p>

<p>The renderer exposes eight selectable visualization modes via the <code class="language-plaintext highlighter-rouge">r_cuMode</code> CVar, each isolating a different pipeline stage. Figures 2 through 7 show the same frame rendered across these modes.</p>

<p><img src="/assets/img/posts/d3pt_bhvdebug.png" alt="r_cuMode 1 — BVH debug: ray cast with random per-triangle coloring" />
<strong>Figure 2.</strong> <code class="language-plaintext highlighter-rouge">r_cuMode 1</code> — BVH traversal debug visualization with random per-triangle coloring.</p>

<p><img src="/assets/img/posts/d3pt_albedo.png" alt="r_cuMode 4 — Albedo texture" />
<strong>Figure 3.</strong> <code class="language-plaintext highlighter-rouge">r_cuMode 4</code> — Albedo texture output.</p>

<p><img src="/assets/img/posts/d3pt_normal.png" alt="r_cuMode 5 — Normal map visualization" />
<strong>Figure 4.</strong> <code class="language-plaintext highlighter-rouge">r_cuMode 5</code> — Normal map visualization.</p>

<p><img src="/assets/img/posts/d3pt_specular.png" alt="r_cuMode 6 — Specular map visualization" />
<strong>Figure 5.</strong> <code class="language-plaintext highlighter-rouge">r_cuMode 6</code> — Specular map visualization.</p>

<p><img src="/assets/img/posts/d3pt_raytraced.png" alt="r_cuMode 7 — Whitted ray tracing: direct lighting, Blinn-Phong specular, mirror reflections" />
<strong>Figure 6.</strong> <code class="language-plaintext highlighter-rouge">r_cuMode 7</code> — Whitted-style ray tracing with direct lighting, Blinn-Phong specular, and mirror reflections.</p>

<p><img src="/assets/img/posts/d3pt_pathtraced.png" alt="r_cuMode 0 — Full PBR path tracing (converged, ~32 frames accumulated)" />
<strong>Figure 7.</strong> <code class="language-plaintext highlighter-rouge">r_cuMode 0</code> — Full PBR path tracing, converged at approximately 32 accumulated frames.</p>

<hr />

<h2 id="acceleration-structure">Acceleration Structure</h2>

<p><em>Doom 3</em> levels run to a few hundred thousand triangles, and because entities move, the BVH has to be rebuilt every frame. Building it on the CPU and uploading the result turned out to be roughly an order of magnitude too slow, so the construction runs entirely on the GPU, following Karras’s 2012 paper. It breaks down into five phases — four custom kernels, plus a sort delegated to Thrust.</p>

<p><strong>Morton codes.</strong> Each triangle’s centroid is normalized to $[0, 1]$ within the scene’s axis-aligned bounding box and encoded into a 30-bit Morton code — 10 bits per axis, interleaved via <code class="language-plaintext highlighter-rouge">expandBits</code>. This maps three-dimensional spatial proximity to a one-dimensional sort key along a space-filling Z-curve.</p>

<p><strong>Radix sort.</strong> Thrust’s <code class="language-plaintext highlighter-rouge">sort_by_key</code> sorts the Morton codes and their associated triangle indices in parallel. This is the most expensive phase and the one that forces a host synchronization — the CUDA stream has to drain before Thrust takes over the default stream. I considered writing a custom radix sort to avoid the sync and decided against it; Thrust’s is a production-grade primitive, and beating it is not a fight worth picking here.</p>

<p><strong>Radix tree.</strong> An internal node kernel determines the split position for each node using the delta function — <code class="language-plaintext highlighter-rouge">__clz</code> applied to XOR’d Morton codes, with index-based tiebreaking for duplicates. Each internal node receives left and right child pointers. Parent pointers are stored for the subsequent bottom-up pass.</p>

<p><strong>Leaf init.</strong> A separate kernel writes leaf nodes containing per-triangle bounding boxes, epsilon-padded to prevent grazing-ray intersection misses.</p>

<p><strong>Bottom-up AABBs.</strong> Starting from every leaf, each thread walks up the parent chain. An atomic counter per internal node ensures that the second child to arrive computes the union AABB while the first child exits immediately. This guarantees that every internal node is visited exactly once.</p>

<p>The custom kernels run on a dedicated CUDA stream. Thrust’s <code class="language-plaintext highlighter-rouge">sort_by_key</code>, however, forces a stream sync and runs on the default stream. I spent a while trying to work around this before accepting it as the one host-side stall in the build pipeline.</p>

<p><strong>Traversal.</strong> At render time, each thread performs a stack-based BVH walk with front-to-back child ordering. The thread maintains a 128-entry local stack and pushes the nearer child last so it is popped first. Listing 2 shows the traversal loop.</p>

<p><strong>Listing 2.</strong> Stack-based BVH traversal with front-to-back ordering.</p>

<div class="language-cuda highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kt">int</span> <span class="n">stack</span><span class="p">[</span><span class="mi">128</span><span class="p">];</span>
<span class="kt">int</span> <span class="n">stackPtr</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="n">stack</span><span class="p">[</span><span class="n">stackPtr</span><span class="o">++</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>  <span class="c1">// root</span>

<span class="k">while</span> <span class="p">(</span><span class="n">stackPtr</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="o">&amp;&amp;</span> <span class="n">stackPtr</span> <span class="o">&lt;</span> <span class="mi">128</span><span class="p">)</span> <span class="p">{</span>
    <span class="kt">int</span> <span class="n">nodeIndex</span> <span class="o">=</span> <span class="n">stack</span><span class="p">[</span><span class="o">--</span><span class="n">stackPtr</span><span class="p">];</span>
    <span class="k">const</span> <span class="n">cudaBVHNode_t</span><span class="o">&amp;</span> <span class="n">node</span> <span class="o">=</span> <span class="n">nodes</span><span class="p">[</span><span class="n">nodeIndex</span><span class="p">];</span>

    <span class="c1">// slab test against node AABB</span>
    <span class="kt">float</span> <span class="n">tmin</span> <span class="o">=</span> <span class="n">ray</span><span class="p">.</span><span class="n">tMin</span><span class="p">;</span>
    <span class="kt">float</span> <span class="n">tmax</span> <span class="o">=</span> <span class="n">foundHit</span> <span class="o">?</span> <span class="n">hitInfo</span><span class="p">.</span><span class="n">t</span> <span class="o">:</span> <span class="n">ray</span><span class="p">.</span><span class="n">tMax</span><span class="p">;</span>
    <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="mi">3</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
        <span class="kt">float</span> <span class="n">invD</span> <span class="o">=</span> <span class="mf">1.0</span><span class="n">f</span> <span class="o">/</span> <span class="n">ray</span><span class="p">.</span><span class="n">direction</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
        <span class="kt">float</span> <span class="n">t0</span> <span class="o">=</span> <span class="p">(</span><span class="n">node</span><span class="p">.</span><span class="n">bounds</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">-</span> <span class="n">ray</span><span class="p">.</span><span class="n">origin</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">*</span> <span class="n">invD</span><span class="p">;</span>
        <span class="kt">float</span> <span class="n">t1</span> <span class="o">=</span> <span class="p">(</span><span class="n">node</span><span class="p">.</span><span class="n">bounds</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">ray</span><span class="p">.</span><span class="n">origin</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">*</span> <span class="n">invD</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">invD</span> <span class="o">&lt;</span> <span class="mf">0.0</span><span class="n">f</span><span class="p">)</span> <span class="p">{</span> <span class="kt">float</span> <span class="n">tmp</span> <span class="o">=</span> <span class="n">t0</span><span class="p">;</span> <span class="n">t0</span> <span class="o">=</span> <span class="n">t1</span><span class="p">;</span> <span class="n">t1</span> <span class="o">=</span> <span class="n">tmp</span><span class="p">;</span> <span class="p">}</span>
        <span class="n">tmin</span> <span class="o">=</span> <span class="n">fmaxf</span><span class="p">(</span><span class="n">tmin</span><span class="p">,</span> <span class="n">t0</span><span class="p">);</span>
        <span class="n">tmax</span> <span class="o">=</span> <span class="n">fminf</span><span class="p">(</span><span class="n">tmax</span><span class="p">,</span> <span class="n">t1</span><span class="p">);</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">tmax</span> <span class="o">&lt;=</span> <span class="n">tmin</span><span class="p">)</span> <span class="k">goto</span> <span class="n">skip_node</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="k">if</span> <span class="p">(</span><span class="n">node</span><span class="p">.</span><span class="n">leftChild</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1">// leaf — test triangles</span>
        <span class="k">for</span> <span class="p">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="n">node</span><span class="p">.</span><span class="n">firstPrimitive</span><span class="p">;</span>
             <span class="n">i</span> <span class="o">&lt;</span> <span class="n">node</span><span class="p">.</span><span class="n">firstPrimitive</span> <span class="o">+</span> <span class="n">node</span><span class="p">.</span><span class="n">primitiveCount</span><span class="p">;</span> <span class="n">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">IntersectTriangle</span><span class="p">(</span><span class="n">ray</span><span class="p">,</span> <span class="n">vertices</span><span class="p">,</span> <span class="n">triangles</span><span class="p">[</span><span class="n">triIndices</span><span class="p">[</span><span class="n">i</span><span class="p">]],</span>
                                  <span class="n">materials</span><span class="p">,</span> <span class="n">hitInfo</span><span class="p">))</span> <span class="p">{</span>
                <span class="n">hitInfo</span><span class="p">.</span><span class="n">triangleIndex</span> <span class="o">=</span> <span class="n">triIndices</span><span class="p">[</span><span class="n">i</span><span class="p">];</span>
                <span class="n">foundHit</span> <span class="o">=</span> <span class="nb">true</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="p">}</span>
    <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
        <span class="c1">// push children — nearer child on top</span>
        <span class="kt">float</span> <span class="n">leftDot</span>  <span class="o">=</span> <span class="n">dot</span><span class="p">(</span><span class="n">leftNode</span><span class="p">.</span><span class="n">center</span>  <span class="o">-</span> <span class="n">ray</span><span class="p">.</span><span class="n">origin</span><span class="p">,</span> <span class="n">ray</span><span class="p">.</span><span class="n">direction</span><span class="p">);</span>
        <span class="kt">float</span> <span class="n">rightDot</span> <span class="o">=</span> <span class="n">dot</span><span class="p">(</span><span class="n">rightNode</span><span class="p">.</span><span class="n">center</span> <span class="o">-</span> <span class="n">ray</span><span class="p">.</span><span class="n">origin</span><span class="p">,</span> <span class="n">ray</span><span class="p">.</span><span class="n">direction</span><span class="p">);</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">leftDot</span> <span class="o">&lt;</span> <span class="n">rightDot</span><span class="p">)</span> <span class="p">{</span>
            <span class="n">stack</span><span class="p">[</span><span class="n">stackPtr</span><span class="o">++</span><span class="p">]</span> <span class="o">=</span> <span class="n">node</span><span class="p">.</span><span class="n">rightChild</span><span class="p">;</span>  <span class="c1">// far</span>
            <span class="n">stack</span><span class="p">[</span><span class="n">stackPtr</span><span class="o">++</span><span class="p">]</span> <span class="o">=</span> <span class="n">node</span><span class="p">.</span><span class="n">leftChild</span><span class="p">;</span>   <span class="c1">// near (popped first)</span>
        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
            <span class="n">stack</span><span class="p">[</span><span class="n">stackPtr</span><span class="o">++</span><span class="p">]</span> <span class="o">=</span> <span class="n">node</span><span class="p">.</span><span class="n">leftChild</span><span class="p">;</span>
            <span class="n">stack</span><span class="p">[</span><span class="n">stackPtr</span><span class="o">++</span><span class="p">]</span> <span class="o">=</span> <span class="n">node</span><span class="p">.</span><span class="n">rightChild</span><span class="p">;</span>
        <span class="p">}</span>
    <span class="p">}</span>
    <span class="nl">skip_node:</span><span class="p">;</span>
<span class="p">}</span>
</code></pre></div></div>

<p>Front-to-back ordering lets early hits tighten <code class="language-plaintext highlighter-rouge">tmax</code> quickly, which prunes large subtrees before any triangle test runs. In my measurements this roughly halved traversal cost compared to pushing children in arbitrary order — about what you’d expect in <em>Doom 3</em>’s heavily occluded interiors.</p>

<hr />

<h2 id="material-conversion">Material Conversion</h2>

<p>I underestimated the material system badly. <em>Doom 3</em>’s <code class="language-plaintext highlighter-rouge">idMaterial</code> isn’t a texture-per-surface mapping — it’s a multi-stage shader pipeline where a single material can declare bump, diffuse, specular, and ambient interaction stages, blend modes, alpha tests, vertex colors, and animated texture registers. The path tracer wants something much flatter: albedo, normal, roughness, metallic, and a handful of behavioral flags. So there is a conversion layer that walks each material’s stages and extracts whatever it can make sense of.</p>

<p><strong>Diffuse stages</strong> are the easy case: one albedo texture, one color multiplier.</p>

<p><strong>Bump stages</strong> provide normal maps. <em>Doom 3</em> uses the RXGB encoding — the X component occupies the alpha channel, Y green, Z blue. The kernel reconstructs tangent-space normals accordingly. When the tangent frame is degenerate, the kernel fabricates an orthonormal basis from the geometric surface normal.</p>

<p><strong>Specular stages</strong> provide a specular intensity map. Roughness and metallic are derived heuristically from specular luminance — brighter specular means lower roughness and more metallic weight. Any PBR artist would wince at this, and fairly. But the goal here is reproducing how <em>Doom 3</em>’s surfaces were meant to look, not authoring correct PBR data, and the heuristic gets the visual weight right for most of the game’s materials.</p>

<p>Beyond the stages, the coverage type sets alpha test thresholds for perforated materials (grates, fences) and blend modes for glass and additive particles. Emission is inferred: materials with no interaction stages — light panels, screens, GUI surfaces — are treated as emissive. Vertex colors pass through for particles and decals, and texture transforms (scale, rotate, scroll) are read from shader registers and applied during UV computation.</p>

<p>Materials are pointer-cached using an <code class="language-plaintext highlighter-rouge">idHashIndex</code> keyed on the <code class="language-plaintext highlighter-rouge">idMaterial</code> pointer. A material is converted once and reused across frames until a texture overflow forces a full cache flush.</p>

<hr />

<h2 id="shading-model">Shading Model</h2>

<p>The shading model is a Cook-Torrance microfacet BRDF with the GGX distribution — the same combination Karis described for Unreal Engine 4 in 2013, and by now the default choice for PBR pipelines. It consumes the albedo, roughness, and metallic values produced by the material conversion, and covers the range from rough diffuse to sharp metallic reflection without special cases — which is exactly what a scene full of scratched metal and painted concrete needs.</p>

<p><strong>Normal distribution function.</strong> The GGX (Trowbridge-Reitz) distribution defines the microfacet orientation probability:</p>

\[D(\mathbf{h}) = \frac{\alpha^2}{\pi\left((\mathbf{n} \cdot \mathbf{h})^2(\alpha^2 - 1) + 1\right)^2} \tag{1}\]

<p>where $\alpha$ is the roughness parameter and $\mathbf{h}$ is the half-vector. GGX has heavier tails than Blinn-Phong, so specular highlights stay broad at grazing angles — which is most of what makes <em>Doom 3</em>’s metal floors look wet under the base’s overhead lights.</p>

<p><strong>Geometry term.</strong> Smith’s method with the Schlick-GGX approximation accounts for microfacet self-shadowing and masking:</p>

\[G(\mathbf{n}, \mathbf{v}, \mathbf{l}) = G_1(\mathbf{n} \cdot \mathbf{v}) \cdot G_1(\mathbf{n} \cdot \mathbf{l}) \tag{2}\]

<p>This is what keeps rough surfaces from blowing out at steep viewing angles.</p>

<p><strong>Fresnel term.</strong> The Schlick approximation models reflectance variation with viewing angle:</p>

\[F(\theta) = F_0 + (1 - F_0)(1 - \cos\theta)^5 \tag{3}\]

<p>The diffuse component uses energy-conserving Lambertian reflectance: $k_d = (1 - F)(1 - \text{metallic})$, scaled by $\frac{\text{albedo}}{\pi}$. Metallic surfaces receive no diffuse contribution — all color is carried through specular reflection.</p>

<p><strong>Specular correction.</strong> One detail here cost me about a week. <em>Doom 3</em>’s interaction shaders double the specular term — literally <code class="language-plaintext highlighter-rouge">result = diffuse + specular * 2</code> — and every surface in the game was tuned against that. My physically correct evaluation produced frames where the math checked out and every metal surface looked dead. The fix is a CVar, <code class="language-plaintext highlighter-rouge">r_cuSpecularBoost</code>, defaulting to 2.0×. It matches what the artists saw, not what the textbook says, and I consider that the right call.</p>

<hr />

<h2 id="light-evaluation">Light Evaluation</h2>

<p>idTech 4 defines three light types: point, parallel (directional), and projected (spotlight with a texture frustum). All three are extracted from the engine’s <code class="language-plaintext highlighter-rouge">viewLight_t</code> list each frame and evaluated during path tracing.</p>

<p><strong>Point lights.</strong> Attenuation follows a windowed quadratic function using <em>Doom 3</em>’s axis-aligned light radius as the falloff boundary:</p>

\[A(d) = \left(1 - \left(\frac{d}{r}\right)^2\right)^2 \tag{4}\]

<p>This falls off smoothly to zero at the radius boundary, avoiding both a hard cutoff and the inverse-square singularity at $d = 0$.</p>

<p><strong>Projected lights.</strong> Each projected light carries four frustum planes (<code class="language-plaintext highlighter-rouge">lightProject[4]</code>) that define a textured light volume. The tracer evaluates these planes to get UV coordinates within the projection, samples the light texture there, and applies a falloff gradient along the frustum depth. Cone angle and edge softness come out of the frustum geometry. I got this wrong several times before it stabilized, and the failure mode is always the same: every spotlight in the game turns into a featureless white cone.</p>

<p><strong>Direct light sampling.</strong> For each shading point, shadow rays are cast toward up to <code class="language-plaintext highlighter-rouge">r_cuMaxLightSamples</code> randomly selected lights, weighted by $\frac{N_{\text{lights}}}{N_{\text{samples}}}$ to maintain an unbiased estimator. The shadow test is transparency-aware: it walks through alpha-tested, transmissive, and blended surfaces, attenuating the shadow ray per-material rather than treating every intersection as fully opaque. This produces correct shadows through chain-link fences, tinted glass, and particle effects.</p>

<p><strong>Soft shadows</strong> come from jittering the light sample position within the light’s spatial extent — point lights within their <code class="language-plaintext highlighter-rouge">lightRadius3</code> bounds, spotlights along their right and up axes. The jitter scale is exposed as <code class="language-plaintext highlighter-rouge">r_cuSoftShadowScale</code>.</p>

<p><strong>Indirect illumination.</strong> A single-bounce GI pass fires one cosine-weighted hemisphere sample from the primary hit point. The indirect ray walks through transparent surfaces (up to four steps) until it hits something opaque, evaluates direct lighting there — shadow test included — and returns that as incident radiance. The bounce fires at a configurable probability (<code class="language-plaintext highlighter-rouge">r_cuIndirectProb</code>). This one bounce does a lot of work: it supplies the ambient light that makes <em>Doom 3</em>’s corridors read as connected spaces rather than isolated pools of light. Seeing light bleed around a door frame that the original renderer leaves pitch black was the moment I stopped doubting the approach.</p>

<hr />

<h2 id="volumetric-scattering">Volumetric Scattering</h2>

<p>I’ll admit this feature has no justification beyond wanting it. <em>Doom 3</em> never shipped with volumetric lighting, and ray-marched scattering is expensive. But the flashlight beam cutting through a dark corridor is the image everyone remembers from this game, and I wanted to render it properly at least once.</p>

<p>The kernel ray-marches from the camera to the first surface hit. At each step it casts a shadow ray toward the light, computes distance attenuation, evaluates a Henyey-Greenstein phase function for directional scattering, and accumulates in-scattered radiance weighted by Beer’s law transmittance. Spotlights get a minimum forward scattering bias ($g \geq 0.7$) so their beams read as cones instead of dissolving into fog.</p>

<p>Projected light textures are sampled during the march too, so a light with a colored gel tints the medium it passes through, not just the surfaces it lands on. It is the single most expensive feature in the renderer. I have no plans to remove it.</p>

<!-- TODO(figure): volumetric scattering screenshot — flashlight or spotlight beam in a dark corridor. Better image than filename: /assets/img/posts/d3pt_volumetric.png
![Volumetric scattering — spotlight beam through participating medium](/assets/img/posts/d3pt_volumetric.png)
**Figure 8.** Ray-marched volumetric scattering with Henyey-Greenstein phase function — TODO: describe scene/map shown.
-->

<hr />

<h2 id="artist-faithful-rendering">Artist-Faithful Rendering</h2>

<p>The path tracing math is the well-documented part of this project. The harder problem was making the result look like <em>Doom 3</em> — not a generic PBR renderer that happens to load <em>Doom 3</em> assets, but the actual game, with its artistic decisions intact.</p>

<p><strong>No ambient fill.</strong> The tracer trusts the placed lights and nothing else — no environment map, no sky bleed, no constant ambient term. A corridor with no <code class="language-plaintext highlighter-rouge">idLight</code> entities renders black, because that darkness is <em>Doom 3</em>’s visual signature. Adding a hemispheric ambient term would take five minutes and ruin the game.</p>

<p><strong>Blend-mode classification per hit.</strong> The original renderer handles alpha-tested grates, additive particles, modulate-blended decals, and translucent glass through draw-order blending. A path tracer has no draw order, so each intersection gets classified instead: pass-through (attenuate throughput), additive (add energy), modulate (multiply throughput), or bounce. Transparent classifications don’t consume bounce budget, so a ray can traverse twenty decal layers as one logical bounce. Opaque <code class="language-plaintext highlighter-rouge">noShadows</code> decals — blood splatters, bullet marks — need their own special case: light the decal, composite it over the throughput, and continue the ray. Before I added this classification, every decal in the game was an opaque wall.</p>

<p>The guiding rule throughout: match what the original renderer <em>did</em>, not what a physically based renderer <em>should</em> do. The artists at <strong>id Software</strong> tuned every surface against a specific rendering architecture, and none of those assumptions transfer automatically. The interesting design constraint was honoring them while adding the things the original couldn’t do — soft shadows, indirect light, volumetrics.</p>

<hr />

<h2 id="limitations-and-runtime-characteristics">Limitations and Runtime Characteristics</h2>

<p>This is an interactive path tracer for a game engine, not a production renderer, and the design reflects that at every level.</p>

<p><strong>One-bounce indirect illumination.</strong> The GI pass takes a single hemisphere sample at the primary hit and evaluates direct lighting wherever it lands. There is no recursive multi-bounce GI, no photon mapping, no irradiance caching. In <em>Doom 3</em>’s tight, heavily occluded corridors, one bounce supplies most of the perceptible ambient; further bounces would multiply the ray count for a difference I doubt anyone would notice.</p>

<p><strong>Cosine-weighted hemisphere sampling.</strong> Bounce directions are drawn proportional to $\cos\theta$, the simplest defensible importance sampling strategy. There is no BRDF importance sampling and no multiple importance sampling. MIS is standard in production renderers for good reason — without it, glossy highlights converge slowly and caustics never resolve at all. I traded that variance reduction for implementation simplicity: one sampling strategy, one PDF, no weight bookkeeping.</p>

<p>Other standard features are absent for similar reasons. All computation is RGB, so there is no spectral dispersion. Surfaces are opaque at the shading point, so no subsurface scattering for skin or wax. Paths trace exclusively from the camera, so specular-to-diffuse transport (caustics) is invisible. In a game made of metal corridors and concrete, none of these omissions show.</p>

<p><strong>No denoiser.</strong> Noise is handled by brute-force temporal accumulation: each frame adds into a persistent HDR buffer, the tone mapper divides by the accumulated frame count, and camera movement resets everything. At 4 SPP the first frame is grainy but legible, direct lighting cleans up after about 50 frames, and soft shadows take a few hundred. Russian roulette terminates low-energy paths with the usual inverse-probability compensation, and a firefly clamp keeps single hot samples from dominating a pixel’s average.</p>

<p>Scene capacity is fixed at compile time — 1M triangles, 2K textures, 512 lights, 2M BVH nodes, all <code class="language-plaintext highlighter-rouge">cudaMalloc</code>‘d once at startup. Transparency-aware shadow rays give up after 8 surfaces. Every pixel gets the same SPP regardless of local variance. These limits are comfortable for <em>Doom 3</em>; they would not survive contact with an open-world scene.</p>

<p><strong>Runtime configuration.</strong> Everything is gated behind a CMake flag (<code class="language-plaintext highlighter-rouge">-DCUDA_PATHTRACER=ON</code>) and a runtime CVar (<code class="language-plaintext highlighter-rouge">r_cuDraw 1</code>); with the flag off, dhewm3 builds and runs its stock OpenGL renderer unmodified. Around 50 CVars expose SPP, bounce depth, Russian roulette thresholds, soft shadow scale, fog density, tone mapping operator, and so on — all adjustable from the <em>Doom 3</em> console mid-game, which made tuning far less painful than recompiling would have been. At the default 0.5× render scale the renderer runs at interactive rates on RTX hardware.</p>

<!-- TODO(performance): measure and replace the vague claim above. For eg. table — one representative map (e.g. mars_city1), noting GPU model:

| Metric | Value |
|---|---|
| GPU | TODO (e.g. RTX 3080) |
| Resolution / render scale | TODO (e.g. 1920×1080 @ 0.5×) |
| Triangles (typical view) | TODO |
| LBVH build | TODO ms |
| Trace + shade (1 SPP, direct only) | TODO ms |
| Trace + shade (4 SPP + GI + volumetrics) | TODO ms |
| Readback + blit | TODO ms |
-->

<p>What it produces is plausible images at interactive rates — enough to walk through <em>Doom 3</em> and watch real light transport interact with real geometry. The missing features listed above aren’t a roadmap; most of them would require rewriting the kernel around a different architecture. The project set out to answer one question — what does <em>Doom 3</em> look like under physically based light transport — and I tried to resist answering any others.</p>

<hr />

<h2 id="discussion">Discussion</h2>

<p>Most of the difficult bugs in this project shared a trait: the renderer kept producing images, and the images were wrong in ways I could only detect by A/B comparison against the GL backend. Three examples stayed with me.</p>

<p><strong>Specular energy loss.</strong> Early builds rendered physically plausible frames in which every metal surface looked matte. The Cook-Torrance code was correct; the problem was the 2× specular multiplier described earlier, hiding in the original interaction shaders. What made this bug nasty is that the broken output didn’t look broken — it looked conservative. Only a side-by-side of the same brushed-steel panel under both renderers made it obvious. Correct math producing wrong pictures because the data was authored against different math turned out to be the recurring theme of the whole project.</p>

<!-- TODO(figure): GL vs CUDA side-by-side comparison — same viewpoint, stock renderer left, path tracer right. Ideally the brushed-steel panel referenced above. Similar to filename: /assets/img/posts/d3pt_gl_vs_cuda.png
![Side-by-side comparison — original GL renderer (left) and CUDA path tracer (right)](/assets/img/posts/d3pt_gl_vs_cuda.png)
**Figure 9.** The same viewpoint under the stock GL renderer (left) and the path tracer (right) — TODO: describe map and what to look for.
-->

<p><strong>Tangent frame degeneracy.</strong> Some func_static entities — pipes and trim geometry, mostly — rendered with inverted or scrambled normals. I spent three days assuming a BVH intersection bug, because dark splotches on curved surfaces look like an intersection bug. The actual cause was in the assets: some meshes ship with zero-length or collinear tangent/bitangent pairs, which the GL renderer tolerates because it derives tangent space differently. Once diagnosed, the fix was one function — detect the degenerate frame, build an orthonormal basis from the geometric normal instead.</p>

<p><strong>Projected light UV precision.</strong> The <code class="language-plaintext highlighter-rouge">lightProject[4]</code> planes produce UV coordinates through four dot products, and floating-point error in the frustum depth calculation showed up as hard banding rings in what should have been smooth spotlight falloff. The GL renderer never hit this because its stencil-and-blend pipeline never evaluates the projection as a continuous function. Normalizing the depth interpolation and adding an epsilon floor fixed it.</p>

<p>All three bugs point at the same underlying fact: <em>Doom 3</em>’s data and its renderer had an implicit contract that nobody ever needed to write down, because both sides were developed together. Swapping out the renderer broke every clause of that contract at once. In practice, much of this project was less about implementing light transport and more about reverse-engineering twenty-year-old assumptions from the render output.</p>

<hr />

<h2 id="future-work">Future Work</h2>

<p>The immediate plan is an OpenCL port. The project is currently locked to NVIDIA hardware, which limits both who can run it and what I can test against. Nothing in the design is actually CUDA-specific — the kernel structure, BVH layout, and material pipeline would carry over — so the translation is mostly mechanical: launch syntax, allocation APIs, math intrinsics. The real casualty is Thrust’s <code class="language-plaintext highlighter-rouge">sort_by_key</code>, which would need replacing with a custom radix sort or something like CLRadixSort.</p>

<p>After that, the optimization backlog becomes worth touching: a two-level acceleration structure so static geometry stops being rebuilt every frame, GL interop to kill the <code class="language-plaintext highlighter-rouge">glDrawPixels</code> round trip, and better importance sampling. None of it changes what the renderer draws — only how long a frame takes.</p>

<hr />

<h2 id="references">References</h2>

<ul>
  <li><strong>Project source:</strong> <a href="https://github.com/aknavj/dhewm3-cupt">aknavj/dhewm3-cupt</a> — the full CUDA path tracing fork of dhewm3</li>
  <li>Christoph Schied, <a href="https://github.com/cschied/q2vkpt">Q2VKPT — Quake 2 Vulkan Path Tracer</a>, 2019</li>
  <li>Tero Karras, <a href="https://research.nvidia.com/publication/2012-06_maximizing-parallelism-construction-bvhs-octrees-and-k-d-trees">Maximizing Parallelism in the Construction of BVHs, Octrees, and k-d Trees</a>, NVIDIA Research, HPG 2012</li>
  <li><a href="https://dhewm3.org/">dhewm3 — Doom 3 GPL Source Port</a></li>
  <li>id Software, <a href="https://github.com/id-Software/DOOM-3">Doom 3 GPL Source Code</a>, 2011</li>
  <li>Matt Pharr, Wenzel Jakob, Greg Humphreys, <em>Physically Based Rendering: From Theory to Implementation</em>, 4th Edition</li>
  <li>Brian Karis, <a href="https://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf">Real Shading in Unreal Engine 4</a>, SIGGRAPH 2013</li>
  <li>James T. Kajiya, <a href="https://dl.acm.org/doi/10.1145/15886.15902">The Rendering Equation</a>, SIGGRAPH 1986</li>
  <li>Turner Whitted, <a href="https://dl.acm.org/doi/10.1145/358876.358882">An Improved Illumination Model for Shaded Display</a>, Communications of the ACM, 1980</li>
</ul>]]></content><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><category term="graphics" /><category term="cuda" /><category term="path-tracing" /><category term="doom3" /><category term="idtech4" /><category term="rendering" /><category term="dhewm3" /><summary type="html"><![CDATA[How Doom 3's submitted geometry and lights become a CUDA path-tracing scene, from GPU BVH construction to lighting and material conversion.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aknavj.github.io/assets/img/posts/d3pt_pathtraced.png" /><media:content medium="image" url="https://aknavj.github.io/assets/img/posts/d3pt_pathtraced.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Reversing a Dead Legend: Inside StarCraft Ghost’s NOD Engine - PART 1</title><link href="https://aknavj.github.io/reverse-engineering/2026/02/03/Reversing-Dead-Legend.html" rel="alternate" type="text/html" title="Reversing a Dead Legend: Inside StarCraft Ghost’s NOD Engine - PART 1" /><published>2026-02-03T00:00:00+00:00</published><updated>2026-02-03T00:00:00+00:00</updated><id>https://aknavj.github.io/reverse-engineering/2026/02/03/Reversing-Dead-Legend</id><content type="html" xml:base="https://aknavj.github.io/reverse-engineering/2026/02/03/Reversing-Dead-Legend.html"><![CDATA[<p>I wanted to know how <em>StarCraft: Ghost</em> had been built. Not how to finish it, port it, or replace its engine. Just how the thing worked.</p>

<p>The leaked development build offered an unusual starting point: alongside the Xbox prototype was a PC debug executable, <code class="language-plaintext highlighter-rouge">Star_d.exe</code>. It did not run correctly out of the box, but its disassembly and decompiled pseudo-code made parts of the engine’s organization visible.</p>

<p>That was enough to keep me coming back for about two years.</p>

<hr />

<h2 id="the-game-behind-the-binary">The Game Behind the Binary</h2>

<p>Ghost was announced in September 2002 as a third-person stealth-action game featuring Nova, a Terran ghost operative. Its original developer, Nihilistic Software, brought forward the <strong>NOD engine</strong> used in <em>Vampire: The Masquerade - Redemption</em>.</p>

<p>Nihilistic’s work ended in 2004, and development moved to Swingin’ Ape Studios. Blizzard later acquired that studio. The game was indefinitely postponed in 2006 and eventually acknowledged as cancelled.</p>

<p>The build that surfaced in 2020 belongs to the Nihilistic period. It is not a record of everything the later team did. The surviving Xbox prototype and PC executable give us a view of one stage of development, not the final state of the project.</p>

<p>The production history is covered elsewhere, notably in <a href="https://www.polygon.com/2016/7/5/11819438/starcraft-ghost-what-went-wrong">Polygon’s retrospective</a>. My interest here is narrower: what can be learned by reading this particular implementation?</p>

<hr />

<h2 id="two-years-in-spare-time">Two Years, in Spare Time</h2>

<p>Those two years were not a full-time reverse-engineering job. There was no schedule, milestone plan, or clear destination. I studied the disassembly and pseudo-code in my free time, out of curiosity.</p>

<p>I started over numerous times. Each attempt made some part of the layout easier to recognize, but it was easy to lose direction when every call led into another unfamiliar system.</p>

<p>Eventually I had enough of restarting. I continued in smaller steps instead: map the basic layout, follow the entry point, identify the main loop, and reconstruct the first few layers around it.</p>

<p>That work became <strong>Starev</strong>. The name describes a reconstruction effort, not a recovered copy of Nihilistic’s source code.</p>

<p>There was a personal reason for choosing Ghost. In 2004, its E3 trailer persuaded me to start saving for a PS2. Some of my early graphics experiments tried to recreate its environments. Years later, I finally had a chance to inspect the real implementation.</p>

<hr />

<h2 id="what-the-debug-build-gave-me">What the Debug Build Gave Me</h2>

<p>The useful material was not just executable instructions. Function names, diagnostic strings, source paths, and recognizable library calls helped put those instructions into context.</p>

<p>A source path can suggest which module owns a routine. A startup call can reveal a dependency. Repeated references to the same object can help identify who coordinates its lifetime.</p>

<p>Pseudo-code makes these relationships easier to read, but it is still a decompiler’s interpretation. Types, ownership, and control flow need checking against the disassembly. Turning that output into readable C++ is not the same as recovering the original code.</p>

<p>The PC executable was particularly helpful for identifying Win32 entry points and the Direct3D 8 path. Those details describe the PC side of the build; they should not be mistaken for the Xbox platform implementation.</p>

<hr />

<h2 id="finding-the-outline">Finding the Outline</h2>

<p>Rather than understand every function, I needed a map that told me where to look next.</p>

<p>The broad outline was:</p>

<div class="language-text highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Platform entry and window handling
  -&gt; Application sequence and state
      -&gt; Input, timing, and other foundation services
      -&gt; Rendering and resource interfaces
      -&gt; Menu and UI
      -&gt; Game, simulation, and mission-system boundaries
</code></pre></div></div>

<p>The important discovery was the role of <code class="language-plaintext highlighter-rouge">tSequence</code>. It gave me a place to follow startup and the calls made during a frame. From there, the lower-level services and higher-level game systems stopped looking like unrelated groups of functions.</p>

<p>This was a map of responsibilities, not proof that the whole engine had been reconstructed.</p>

<hr />

<h2 id="what-i-actually-reconstructed">What I Actually Reconstructed</h2>

<p>The practical result was a basic engine architecture skeleton: the entry path, main-loop organization, and the first two or three layers of calls around them.</p>

<p>Foundation code and the interfaces between modules gave that skeleton structure. Other files existed to record a boundary or a declaration while their implementation remained incomplete.</p>

<p>I did <strong>not</strong> deeply reconstruct physics, AI, the game library, or mission scripting. I followed those systems along the surface where the main flow called into them. Knowing where an AI update is dispatched is different from understanding how its behavior works internally.</p>

<p>That distinction matters when reading the rest of the series. Starev was a way to organize and preserve what I understood. It was not a functioning replacement engine or a finished PC version of Ghost.</p>

<hr />

<h2 id="what-reuse-does-and-does-not-tell-us">What Reuse Does, and Does Not, Tell Us</h2>

<p>NOD’s earlier use in an RPG explains some of its history. It does not establish that its architecture was unsuitable for an action game.</p>

<p>Rendering, file access, resource lookup, and timing can serve many kinds of games. Player movement and mission behavior are much more specific. The interesting question is where those responsibilities meet, and which assumptions have to change when the game changes.</p>

<p>My surface-level reconstruction was not enough to measure the cost of that adaptation. An inherited filename or an old interface is a trace of history, not evidence that engine reuse caused Ghost’s cancellation.</p>

<p>For someone interested in a genre-agnostic engine, this work offers an example to inspect, not a design recipe. The useful distinction is between shared services and game-specific behavior, rather than between an “RPG engine” and an “action engine.”</p>

<hr />

<h2 id="the-next-step">The Next Step</h2>

<p>Once I had an outline, the next question was how to turn it into a coherent reconstruction without pretending to understand everything below it.</p>

<p><a href="/reverse-engineering/2026/03/31/NOD-Engine-Architecture-Deep-Dive.html">Part 2</a> follows that work through Starev: the application boundary, staged startup, main-loop dispatch, and the subsystem interfaces left to reconstruct.</p>

<p><a href="/reverse-engineering/2026/07/14/What-the-Data-Remembers-NOD-Engine-Part-3.html">Part 3</a> takes a smaller, testable piece of the problem: reading the custom asset formats in a viewer.</p>

<p>These are accounts of an investigation, not step-by-step tutorials.</p>

<hr />

<h2 id="references">References</h2>

<ul>
  <li><a href="https://www.polygon.com/2016/7/5/11819438/starcraft-ghost-what-went-wrong">StarCraft: Ghost - What Went Wrong</a>, Polygon, July 2016</li>
  <li>Jason Schreier, <em>Play Nice: The Rise, Fall, and Future of Blizzard Entertainment</em>, Grand Central Publishing, 2024</li>
  <li>Starev - architecture and code-reconstruction work based on the development executable</li>
</ul>]]></content><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><category term="reverse-engineering" /><category term="reverse-engineering" /><category term="starcraft" /><category term="ghost" /><category term="nod-engine" /><category term="nihilistic" /><category term="disassembly" /><summary type="html"><![CDATA[Two years of spare-time investigation into StarCraft Ghost's development build, and the small architecture reconstruction that grew out of it.]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://aknavj.github.io/assets/img/posts/scg_img0.png" /><media:content medium="image" url="https://aknavj.github.io/assets/img/posts/scg_img0.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Grabbing models and textures from games</title><link href="https://aknavj.github.io/3d/2019/06/10/Grabbing-models-and-textures-from-game-or-3D-application.html" rel="alternate" type="text/html" title="Grabbing models and textures from games" /><published>2019-06-10T00:00:00+00:00</published><updated>2019-06-10T00:00:00+00:00</updated><id>https://aknavj.github.io/3d/2019/06/10/Grabbing-models-and-textures-from-game-or-3D-application</id><content type="html" xml:base="https://aknavj.github.io/3d/2019/06/10/Grabbing-models-and-textures-from-game-or-3D-application.html"><![CDATA[<blockquote>
  <p>A summary of methods and techniques for extracting 3D models and textures from games and 3D applications — from GPU rippers to photogrammetry.</p>
</blockquote>

<h2 id="introduction">Introduction</h2>

<p>There are several ways to grab models and textures from a running game. I split them into two groups:</p>

<ul>
  <li><a href="#lethal-way">Lethal way</a> — breaks the EULA
    <ul>
      <li><a href="#graphics-analyzers">Graphics analyzers</a></li>
      <li><a href="#ripper-tools">Ripper tools</a></li>
      <li><a href="#comparing-data">Comparing data</a></li>
    </ul>
  </li>
  <li><a href="#non-lethal-way">Non-lethal way</a> — no reverse engineering involved
    <ul>
      <li><a href="#photogrammetry">Photogrammetry</a></li>
    </ul>
  </li>
</ul>

<p>Why would you want to do this?</p>

<ul>
  <li><strong>For fun</strong> — just mess around with the assets.</li>
  <li><strong>Study how GFX is made</strong> — topology, UV layouts, level design.</li>
  <li><strong>Study how the engine works</strong> — see Adrian Courrèges’ <a href="http://www.adriancourreges.com/blog/2015/11/02/gta-v-graphics-study/">GTA V rendering study</a> for a great example.</li>
  <li><strong>Learn programming</strong> — nobody wants to stare at a textured cube forever. Use real assets.</li>
  <li><strong>Speedrun optimization</strong> — some tools expose trigger volumes and collision boxes. Useful for finding exploits.</li>
  <li><strong>3D printing</strong> — <a href="https://www.instructables.com/id/3D-Printing-Models-from-video-game/">guide here</a>.</li>
  <li><strong>3D edits / cinematics</strong> — e.g. <a href="https://www.youtube.com/watch?v=R-fq8o4Do3g">CS:GO 3D-Edit</a>.</li>
  <li><strong>Total conversions</strong> — e.g. <a href="https://www.youtube.com/watch?v=BDSUeD-WErY">Duke Nukem 3D ‘Forever’ in Serious Sam 3</a>.</li>
</ul>

<hr />

<h2 id="lethal-way">Lethal way</h2>

<p>This breaks every legal agreement with the vendor. You’re not supposed to reverse engineer or redistribute their intellectual property. But it’s fun, most hardcore fans don’t care, and as long as you don’t share ripped content commercially — nobody is going to come after you.</p>

<h3 id="tools">Tools</h3>

<p><strong>File extraction tools</strong> — purpose-built reverse engineering tools that crack proprietary formats.</p>
<ul>
  <li><a href="https://forum.xentax.com/">Xentax Forum</a> — large community focused on game file format RE.</li>
</ul>

<p><strong>Graphics analyzers / profilers</strong> — capture everything the GPU processes in a single frame: geometry, textures, shaders, draw calls.</p>
<ul>
  <li><a href="https://software.intel.com/en-us/gpa">Intel GPA</a></li>
  <li><a href="https://gpuopen.com/archive/gpu-perfstudio/">AMD GPU PerfStudio</a></li>
  <li><a href="https://developer.nvidia.com/nsight-graphics">NVIDIA Nsight</a></li>
  <li><a href="https://renderdoc.org/">RenderDoc</a></li>
</ul>

<p><strong>Ripper tools</strong> — grab geometry directly from the video buffer. Same principle as analyzers, but focused on asset extraction.</p>
<ul>
  <li><a href="http://www.deep-shadows.com/hax/3DRipperDX.htm">3D Ripper DX</a> — old but works for DX6/8/9 titles.
    <blockquote>
      <p>Installation password: <strong>ripper</strong></p>
    </blockquote>
  </li>
  <li><a href="https://gamebanana.com/tools/5638">Ninja Ripper</a> — DX9, 10, 11 and newer. <a href="https://github.com/riccochicco/ninjaripper">Source on GitHub</a>.
    <ul>
      <li><a href="http://cgig.ru/en/2012/10/ho-to-use-ninja-ripper/">Official guide</a> · <a href="https://nerotips.tumblr.com/post/159024040760/ninja-ripper-guide">Nero’s guide</a></li>
    </ul>
  </li>
  <li><a href="http://www.mediafire.com/file/0a4104rb1ukczas/GameAssassin.zip">GameAssassin</a> — <a href="https://forum.xentax.com/viewtopic.php?t=5913">Xentax usage guide</a></li>
</ul>

<h3 id="before-you-start">Before you start</h3>

<p>A few things to keep in mind before using any ripper or analyzer:</p>

<ol>
  <li><strong>Know which Graphics API the game uses.</strong> If the tool doesn’t support it, it won’t work.
    <blockquote>
      <p>Some games ship with anti-RE protection that blocks profilers or disassemblers entirely.</p>
    </blockquote>
  </li>
  <li>
    <p><strong>Frame capture freezes the application.</strong> You can’t capture in real-time — every grab pauses the game for seconds or even minutes.</p>
  </li>
  <li><strong>Everything you grab comes through the rendering engine.</strong> The engine manages all vertex data, polygons, UVs, and textures before sending them to the GPU. You’re intercepting that pipeline.</li>
</ol>

<p>Because of this, you’ll also capture hidden data that exists in video memory but isn’t visually shown:</p>
<ul>
  <li>Light cones (volumetric effects)</li>
  <li>Portal volumes (indoor/outdoor culling)</li>
  <li>Trigger areas (boxes, null axes)</li>
  <li>LOD meshes</li>
  <li>Collision shapes (boxes, cylinders, spheres)</li>
</ul>

<h3 id="example-alien-isolation--dead-space-2">Example: Alien Isolation + Dead Space 2</h3>

<p>I picked these titles not out of love, but because they lack community extraction tools. This proves the approach works even without dedicated format support.</p>

<ul>
  <li><strong>Graphics analyzer</strong> — <a href="https://store.steampowered.com/app/214490/Alien_Isolation/">Alien: Isolation</a> (DX11, Creative Assembly)</li>
  <li><strong>Ripper tools</strong> — <a href="https://store.steampowered.com/app/47780/Dead_Space_2/">Dead Space 2</a> (DX9, Visceral Games / EA)</li>
</ul>

<h4 id="graphics-analyzers">Graphics Analyzers</h4>

<p><a href="https://renderdoc.org/">RenderDoc</a> was used to capture frames from Alien: Isolation. It intercepts DX/GL/VK calls and lets you inspect every draw call, texture, shader, and buffer in the captured frame.</p>

<h4 id="ripper-tools">Ripper Tools</h4>

<p>Software used:</p>
<ul>
  <li><a href="https://store.steampowered.com/app/47780/Dead_Space_2/">Dead Space 2</a> — Steam version</li>
  <li><a href="http://www.deep-shadows.com/hax/3DRipperDX.htm">3D Ripper DX</a></li>
  <li><a href="https://gamebanana.com/tools/5638">Ninja Ripper</a></li>
  <li>Autodesk 3D Studio Max 2010 — import/export</li>
  <li>Maxon Cinema 4D — viewing</li>
</ul>

<h5 id="3d-ripper-dx">3D Ripper DX</h5>

<p>Grabs frame data — models, textures, and shaders. Models are saved as <code class="language-plaintext highlighter-rouge">.3DR</code> files, which require 3D Studio Max 2009–2014 with the included import plugin. Textures come as DDS, shaders as plain text.</p>

<blockquote>
  <p>Shaders are in compiled bytecode. To read them you need to understand the DX9 HLSL fixed-function instruction set. See <a href="https://drivers.amd.com/misc/samples/dx9/FixedFuncShader.pdf">this reference</a>.</p>
</blockquote>

<p>For detailed usage, follow <a href="http://cgig.ru/en/2012/10/ho-to-use-ninja-ripper/">this guide</a>.</p>

<p><img src="/assets/img/posts/gmt_3dripper-first.png" alt="3D Ripper DX capture" /></p>

<h5 id="ninja-ripper">Ninja Ripper</h5>

<p>Same principle as 3D Ripper DX, but no wireframe mode. Outputs <code class="language-plaintext highlighter-rouge">.RIP</code> files — importable via a Python plugin for 3D Studio Max (included in the <code class="language-plaintext highlighter-rouge">/tool</code> directory).</p>

<p>For detailed usage, follow <a href="http://www.deep-shadows.com/hax/3DRipperDX.htm#quickstartguide">this guide</a>.</p>

<p><img src="/assets/img/posts/gmt_ninjaripper-first.png" alt="Ninja Ripper capture" /></p>

<h4 id="comparing-data">Comparing Data</h4>

<p>The key difference: <strong>Ninja Ripper</strong> captures the scene <em>before</em> GPU shader transforms — characters stay in T-pose, geometry has no deformation or rotation applied. <strong>3D Ripper DX</strong> captures what’s on screen after all transforms.</p>

<p><img src="/assets/img/posts/gmt_compare-first.png" alt="Comparison" /></p>

<h4 id="conclusion">Conclusion</h4>

<p>Each tool has its use case. Need a “diorama” with models in motion? <strong>3D Ripper DX</strong>. Need clean, undeformed assets in their bind pose? <strong>Ninja Ripper</strong>.</p>

<hr />

<h2 id="non-lethal-way">Non-lethal way</h2>

<h3 id="photogrammetry">Photogrammetry</h3>

<p>Take hundreds of screenshots from different camera angles, feed them into a reconstruction tool, and get a textured 3D model out. Simple concept, heavy on compute time. See the <a href="https://www.agisoft.com/pdf/photoscan-pro_1_3_en.pdf">Agisoft guide</a> (page 8, chapter 2) for the theory.</p>

<blockquote>
  <p>You’re not reverse engineering anything or cracking file formats — you’re just taking screenshots.</p>
</blockquote>

<h5 id="software">Software</h5>
<ul>
  <li><a href="https://www.agisoft.com/">Agisoft Metashape</a> — used in the examples below</li>
  <li><a href="https://www.3dflow.net/3df-zephyr-free/">3DF Zephyr Free</a></li>
  <li><a href="https://www.autodesk.com/solutions/123d-apps">Autodesk 123D Catch</a></li>
  <li><a href="https://github.com/openMVG/openMVG">OpenMVG</a></li>
  <li><a href="http://ccwu.me/vsfm/">VisualSFM</a></li>
</ul>

<h4 id="example-doom-2016">Example: Doom 2016</h4>

<blockquote>
  <p>New to Metashape? Follow <a href="https://www.youtube.com/watch?v=Uny9nTr22go">this video guide</a>.</p>
</blockquote>

<p>I used <a href="https://store.steampowered.com/app/379720/DOOM/">Doom 2016</a> (Steam) with the built-in Photo Mode. Around 300 screenshots from the free camera. Most are slightly blurred because I forgot to disable motion blur — still worked fine.</p>

<p><img src="/assets/img/posts/gmt_game_screenshot.jpg" alt="Game screenshot" /></p>

<p><img src="/assets/img/posts/gmt_grabbed_screenshots.png" alt="Captured screenshots" /></p>

<p>Drop the photos into Agisoft Metashape and run <strong>Photo Alignment</strong> to generate a point cloud:</p>

<p><img src="/assets/img/posts/gmt_image_alignment.png" alt="Photo alignment" /></p>

<p>Then <strong>Build Mesh</strong> from the point cloud:</p>

<p><img src="/assets/img/posts/gmt_output.jpg" alt="Mesh output" /></p>

<p>For higher texture resolution, run <strong>Build Texture</strong> at a larger size. I used 8K (4× the source resolution of 1920×1080):</p>

<p><img src="/assets/img/posts/gmt_screenshoted_path.png" alt="Screenshot path" />
<img src="/assets/img/posts/gmt_output_recomputed_textures_8k.png" alt="Recomputed 8K textures" /></p>

<p>Final quality comparison:</p>

<p><img src="/assets/img/posts/gmt_comparsion.png" alt="Comparison" /></p>

<p>For mesh optimization, use <a href="https://www.simplygon.com/">Simplygon</a>, <a href="https://instalod.com/">InstaLOD</a>, or Cinema 4D’s built-in <a href="http://www.maxon.net">Polygon Reduction</a>:</p>

<p><img src="/assets/img/posts/gmt_reduced_polygons_c4d.png" alt="Reduced polygons in C4D" /></p>

<h4 id="summary">Summary</h4>

<table>
  <thead>
    <tr>
      <th>Data</th>
      <th>Pros</th>
      <th>Cons</th>
      <th>Note</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Models</td>
      <td>Generated</td>
      <td>Single mesh</td>
      <td>Can be large, needs optimization</td>
    </tr>
    <tr>
      <td>Textures</td>
      <td>Generated</td>
      <td>Single atlas</td>
      <td>May have incorrect UVs</td>
    </tr>
    <tr>
      <td>Shaders</td>
      <td>Baked into texture</td>
      <td>Not extracted</td>
      <td>Lighting is baked in</td>
    </tr>
    <tr>
      <td>Legal</td>
      <td>No EULA violation</td>
      <td>—</td>
      <td>Just screenshots</td>
    </tr>
  </tbody>
</table>]]></content><author><name>Ondrej Vanka</name><email>ondrej.vanka@proton.me</email></author><category term="3d" /><category term="grabbing" /><category term="models" /><category term="3d" /><category term="application" /><category term="textures" /><summary type="html"><![CDATA[A summary of methods and techniques for extracting 3D models and textures from games and 3D applications — from GPU rippers to photogrammetry.]]></summary></entry></feed>