Renderer, RHI & shaders
Shift Engine renders Colorado and every vehicle on one unified reverse-Z HDR pipeline spanning Vulkan 1.3, DirectX 12, Metal 3 (MoltenVK + Apple MetalFX), and WebGPU (42 WGSL shaders). Optional heavy targets allocate lazily only when enabled by the active preset.
Shift Engine 10-Stage HDR Frame Pipeline (Renderer::draw_frame, reverse-Z, lazy targets, kFramesInFlight=2): 1. Pre-Pass & Cull: per-frame UBOs, 24h Sky/ToD uniforms, clustered lights, amortized dynamic env cubemap + 3-band cockpit mirrors, WorldGpu frustum + Hi-Z occlusion culling (world_cull.comp, tree_cull.comp). 2. Cascaded Sun Shadows: 2/3-cascade D32 reverse-Z atlas with configurable Shadow Draw Distance (Low..Ultra/Extended), Far-cascade tree shadow cutouts, optional PCSS. 3. Main HDR Scene Pass: discard-free opaque world (early_fragment_tests), terrain/road blending, grass shells, kAnimTreeSway vegetation-only wind sway, reflective lake water, early-Z sky dome & 9,096 stars, instanced cars (PBR clearcoat, voxel damage, backlit gauges), TBDR transient 1x/2x/4x MSAA. 4. Hi-Z Pyramid & Soft Particles: hiz_gen.comp mip chain, soft tyre smoke, skidmarks, smashable debris, fireworks, lamp glows. 5. Modern Screen-Space (lazy): XeGTAO/SSAO, SSCS contact shadows, Hi-Z SSR, occluded volumetric sun shafts, motion vectors + McGuire tile motion blur. 6. Optional Hardware RT/PT: BLAS/TLAS updates, Tier-1 hybrid ray-query reflections/shadows/AO, Photo Mode / real-time path tracing with ReSTIR DI + SVGF denoiser. 7. HDR Post Chain: 6-level bloom pyramid, adaptive auto-exposure, retail 16x16x16 3D LUT color grading, filmic tonemapping. 8. Anti-Aliasing, Upscaling & Output: FXAA, CAS, FSR1, TAAU, Apple MetalFX (+ macOS 26+ Frame Interpolation), optional VRS, per-monitor HDR10/scRGB calibration. 9. UI4 Overlay Pass: single-pass instanced 96-byte ui::Instance quads, 4K VFont & 512x512 stroke SDF atlas, tilted dual-texture masks. 10. Queue Submit & Present: frame-tagged retirement ring (zero vkDeviceWaitIdle stalls), GPU timestamp queries. Multi-API RHI targets: Vulkan 1.3 (Windows/Linux/Android, split bindless 1x sampler + 4096 sampled images), DirectX 12 (Windows), Metal 3 via bundled MoltenVK (macOS), WebGPU (42 WGSL shaders from 56 GLSL/SPIR-V sources).
Key rendering subsystems#
Multi-API RHI (libs/rhi)
Explicit Device, Swapchain, CommandList, RenderGraph, clustered local lights, visibility buffer, and GPU Xenos detiling. Select with --backend auto|vulkan|dx12|metal or inspect via --list-backends.
GPU-driven WorldGpu & TBDR
Persistent world/tree arenas culled by compute frustum + Hi-Z occlusion using split bindless (1× sampler + 4096 images), transient on-chip MSAA for tile GPUs, persistent VkPipelineCache, and zero-stall retirement rings.
24h Sky, Terrain, Water & Shadows
Calibrated TimeOfDayA (110 curves, 16 zones, 22 retail 16³ LUTs, 9,096 stars), terrain/road blending, grass shells, LAKE_* water, vegetation-only kAnimTreeSway, and live Shadow Draw Distance (Low..Extended) including Far tree shadows.
Modern post & optional RT/PT
Lazy-allocated XeGTAO, SSCS, Hi-Z SSR, volumetric shafts, McGuire motion blur, optional Vulkan RT/PT (ReSTIR DI + SVGF), CAS/FSR1/TAAU/MetalFX, VRS, and per-monitor HDR10/scRGB output.
Platform notes#
| Platform | World culling | Pipeline / memory optimizations |
|---|---|---|
| Windows / Linux | GPU-driven WorldGpu + Hi-Z compute | Persistent VkPipelineCache, optional VRS (-18% GPU at 1080p on RTX 4080), optional Vulkan RT/PT. |
| macOS (Apple Silicon) | CPU-culled direct draws (gpu_world=0 avoids MoltenVK indirect bugs; 0.66–1.35 ms CPU p50 on M4 Pro) | Split offscreen/present queues, TBDR transient MSAA, persistent VkPipelineCache, Apple MetalFX (+ Frame Interpolation on macOS 26+). |
| Android (arm64) | Split bindless on Turnip; CPU-culled fallback on stock drivers | Bundled Mesa Turnip (rootless via libadrenotools), TBDR transient MSAA, VRS + ADPF presets. |
WebGPU (/play/) | CPU frustum culling into indexed draws | 42 native WGSL shaders, BC compressed textures, WASM SIMD128 + pthreads. |
Authoring & regenerating shaders#
Source GLSL lives in apps/carview/shaders/, prebuilt SPIR-V in apps/carview/shaders/prebuilt/ (56 shaders), and generated WGSL in apps/carview/webgpu/wgsl/ (42 shaders). After any shader edit, run all three checks before committing:
python tools/regenerate-shaders.py [--compiler /path/to/glslc]
python tools/generate-wgsl.py
python tools/check-shader-portability.py --check-manifest