nightpeak

A 3D game engine I wrote in Rust, and four places I built with it: a lounge, a diner, a manor and a mountain road.

Rust / wgpu / WGSL
8,500lines of Rust and shader code
640 × 360render resolution
4places you can walk or drive through

nightpeak is a 3D engine I wrote in Rust. It uses wgpu to talk to the graphics card and has no game engine underneath. It does the rendering, shadows, fog, collision for walking around, a drivable car, and model loading.

Each frame is rendered at 640×360 and then reduced to a small fixed set of colours. Where a surface falls between two of those colours, the engine mixes them in a fine pixel pattern. That pattern is called dithering and it gives the pictures their grainy look.

The levels are written in code. Each place is a Rust file that puts down the walls, lights and furniture. The pictures on this page are screenshots from the engine.

Lighting produces a palette shade with a fractional part, plus a warmth value: the share of light that came from lamps. A post pass dithers both into the fixed palette. Shadows use a depth map with comparison sampling. Fog has density, scattering and a boost near low ground.

--shot renders named camera views to PNG without opening a window. --check sends a bot along every walkable route to catch blocked doors and bad collision.

The lounge

The diner and the road

The manor

Voxel objects

The engine can also build objects out of voxels, which are small cubes on a 3D grid. I used soda cans as the test object because the curved surface and the printed label make mistakes easy to see.

A voxel volume is a dense grid of material codes. It is turned into a mesh by emitting only the faces between filled and empty cells. A separate project of mine is a voxel path tracer written as a WGSL compute shader: rays step through a three-level sparse grid and skip empty 64³ and 8³ regions in one step each.