A deterministic, chunk-based raycasting engine written in C++ with a focus on low-level control, fixed‑point math, and procedural world generation. The engine renders a Wolfenstein‑style 3D view while supporting infinite scrolling worlds through chunk streaming and cellular automata–based terrain generation.
This project is intentionally minimal and educational: no STL heavy abstractions, no floating point at runtime, and no external rendering libraries.
- Chunked world system (32x32 tiles per chunk)
- Infinite scrolling via chunk panning (no reallocations)
- Fast DDA raycasting with fixed‑point math
- Division‑free hot path (bitwise chunk/local tracking)
- Deterministic procedural generation (SplitMix64)
- Cellular Automata cave generation across chunk borders
- Software renderer (framebuffer based)
- Each chunk is
32x32tiles - Active world is a
GRID×GRIDwindow centered on the player - Chunks are addressed in two coordinate spaces:
Used for deterministic generation:
(cx, cy) ∈ ℤ
Used for fast lookup during rendering:
(gx, gy) ∈ [0, GRID)
Chunks are panned when the player crosses chunk boundaries:
- No reallocation
- No modulo during ray traversal
- Only edge chunks are regenerated
- Classic DDA (Digital Differential Analyzer)
- Fixed‑point math (
16.16) - Wall shading based on hit side
During DDA stepping:
- Track local tile coords (
0..31) - Track grid chunk indices (
gx, gy) - Adjust only when crossing chunk edges
No div32() or %32 in the hot loop
Each chunk is seeded deterministically:
seed = GLOBAL_SEED ^ f(cx, cy)This guarantees:
- Same world every run
- Infinite space
- No stored world state
Used to turn noise into caves/walls.
Rule (example):
- Count 8 neighbors
>= 5 walls → wall< 5 → empty
- Implement Raystepping with DDA
- Learn and try out fixed point representation for the fixed point look
- learn how to generating Deterministic worlds
mkdir build && cd build
emcmake cmake ..
cmake --build .Try in-browser demo: (https://arjan-p.github.io/raycaster-wasm)