Shift Engine Docs

These docs follow the main branch and can describe changes newer than v0.3.2. Release archives and checksums are published on GitHub Releases.

Asset formats & disc streaming

Shift Engine parses retail Xbox 360 Forza Horizon containers and asset formats directly using clean-room binary readers under libs/fh1data, libs/data, libs/cars, and libs/setup. Vehicles stream directly from disc and stock XMA2 audio decodes in-process, reducing initial setup to a compact colorado.index (~500 MB local footprint).

Zero-Bake Asset Overlay Precedence highest priority (top) → retail disc fallback (bottom) 1. ENABLED MODS (mods.toml / mod.toml) Live texture reload · in-memory gamedb.slt patches 2. TITLE UPDATE v4 & DLC (STFS) CON/LIVE/PIRS in state/ · Rally · 1000 Club · DLC cars 3. OPTIONAL .shiftbake CACHE Optional offline carbake / soundbake (not required) 4. RETAIL DISC (.iso GDFX or media/) Direct streaming: FH1 ZIP/LZX · .carbin · .xds · XMA2 colorado.index + NativeCache BVH4 (~500 MB local) Colorado "HEXY" PVS Ring & 4-Tier LOD Colorado_00.hex · R = 100 m · 91×60 grid · 1,434 zones N0 N1 N2 N3 N4 N5 ZONE 6-bit mask Spatial Lookup 1. world_to_hex(x, z) 2. 4-ring BFS fallback 3. PVSZLookup_00.dat 4. __R00ZNNNNN.pvsz 11 sections · .pgeo/.fiz 4-Tier LOD Bands (Xbox 360 D3D FLOAT16 distances) LOD0 0–20m LOD1 20–40m LOD2 40–60m LOD3 / Far Ring Sentinel -1.0 (0xBC00) → defaults [20, 40, 60] m · 0x7FFF = +131,008.0
Left: four-layer asset overlay stack from mods down to direct retail disc streaming. Right: Colorado's flat-top odd-q HEXY hex grid, 7-zone active ring, and 4-tier D3D FLOAT16 LOD bands.
Zero-Bake Disc Streaming & Colorado HEXY PVS / 4-Tier LOD:


Asset Overlay Precedence (highest to lowest):
1. Enabled mods (mods.toml / mod.toml): live texture reload and in-memory gamedb.slt patches.
2. Title Update v4 & DLC STFS packages (CON/LIVE/PIRS in state/): Horizon Rally, 1000 Club, DLC cars.
3. Optional .shiftbake cache (carbake / soundbake — not required).
4. Retail disc (.iso GDFX parser or extracted media/): direct streaming of FH1 ZIP/LZX, .carbin (with damage deformation tail), .xds (Xenos detiled), and in-process XMA2 audio. Local index: colorado.index + serialized NativeCache BVH4 (~500 MB).


Colorado HEXY PVS Hex Grid (Colorado_00.hex, magic "HEXY" v101):
- Flat-top odd-q hex grid, radius R = 100.0 m, origin (-6700.0, -6495.1904), 91 x 60 grid, 1,434 zones, per-zone 6-bit neighbor connectivity mask.
- HexGrid::lookup_zone(x, z) falls back to a 4-ring BFS minimizing squared distance; active_zone_ring() returns the primary zone + up to 6 connected neighbors (7-zone ring).
- PVSZLookup_00.dat + FilenameMap_00.dat map zone_id to 11-section __R00ZNNNNN.pvsz files (.pgeo scenery, .fiz collision).
- Per-placement 4-tier LOD distances use Xbox 360 D3D FLOAT16 (subnormals flushed to zero, no Inf/NaN, 0x7FFF = +131,008.0, 0xBC00 = -1.0 sentinel resolving to [20, 40, 60] m defaults).

Format parsers at a glance#

Disc, STFS & archive containers

Clean-room GDFX/XISO reader (4 MB streaming chunks on desktop, Android, and WebGPU OPFS), STFS (CON/LIVE/PIRS) extractor, concurrent FH1 ZIP/LZX (libmspack), and read-only SQLite gamedb.slt with in-memory TU v4 / DLC / mod patches.

Textures (.xds) & Xenos detiling

Decodes BC1/BC2/BC3, DXN/CTX1 normal maps, RGBA8/RGB565/L8/RGBA16F, and 16³ 3D LUTs with CPU worker or GPU compute (rhi/xenos_detile_gpu.h) macro/micro detiling and exact sRGB vs. linear handling.

Vehicles (.carbin) & damage tail

Streams LOD0–LOD5 hierarchies, suspension/wheel hardpoints, rotors/calipers, cockpit needles, lamps, paint/livery UVs, and per-vertex deformation offsets bound to drive::VoxelDamageGrid (mirroring Z from -Z to +Z forward on upload).

Colorado PVS & cached BVH4

Parses Colorado_00.hex ("HEXY" v101, 100 m radius, 1,434 zones), PVSZLookup_00.dat, and 11-section .pvsz files with Xbox 360 D3D FLOAT16 LOD distances; persists pre-built SIMD BVH4 collision blobs in NativeCache.

Validating parsers locally#

Unit tests run on synthetic bytes in CI; optional corpus tests validate every format parser against your own local disc (auto-skipping with exit code 77 when SHIFT_GAME_ROOT is unset):

ctest --test-dir build -LE corpus --output-on-failure
SHIFT_GAME_ROOT=/path/to/fh1/disc ctest --test-dir build -L corpus --output-on-failure
Headers in libs/fh1data/include/fh1data/: archive.h (FH1 ZIP/LZX via libmspack + inflate.h + xmem.h), xds.h & world_texture.h (Xbox 360 D3D textures: DXT1/3/5, DXN/CTX1, A8R8G8B8, R5G6B5, L8/A8L8, A16B16G16R16F, 16x16x16 3D LUTs, linear 288x160 strip tiles & car thumbnails, --texture-cap enforcement), carbin.h (LOD0-LOD5, hardpoints, cockpit gauges, lamps, deformation tail, -Z forward mirrored to +Z on upload), hex_pvs.h (Colorado_00.hex magic HEXY v101, hex_radius=100.0 m, origin=(-6700.0, -6495.1904296875), 91x60 grid, 1434 zones, 6-bit edge_masks, 4-ring BFS lookup_zone, active_zone_ring up to 7 zones; FilenameMap_00.dat, PVSZLookup_00.dat, PVSZoneSpeeds.dat; 11-section __R00ZNNNNN.pvsz with Xbox 360 D3D FLOAT16 distances where 0x7FFF=+131008.0 and 0xBC00=-1.0 resolves to [20, 40, 60] m defaults), placements.h, props.h, collision.h (.fiz & SurfaceTypes.xml), rmb.h, native_cache.h (serialized MeshGround BVH4 blobs alongside colorado.index), spa.h, stringtables.h, ui_scene.h, vfont.h, cjk_font.h, worker_pool.h. Source precedence in libs/cars: 1) enabled mods (mods.toml/mod.toml), 2) TU v4 & DLC STFS packages in state/, 3) optional .shiftbake cache, 4) direct retail disc (.iso GDFX or media/).