this is a rust implementation of the infamous voxel space algorithm used by novalogic for their early comanche games and delta force 1 & 2
- load your own maps: you can pick custom colormap and heightmap images with a file picker
- sky gradient: "simulates" a sky that goes from light blue to darker blue near the horizon
- real-time controls: move around and change angles with your keyboard, giving you an interactive 3d experience
- optimized performance: uses frame-rate independent motion and other tweaks to make it smoother even on big maps
- rust (latest stable version)
- cargo (comes with rust)
this project uses a few crates:
- pixels for pixel rendering
- winit for managing windows and events
- image for handling image files
- rfd for the file picker (cross-platform)
add these dependencies to your cargo.toml
:
[dependencies]
pixels = "0.10"
winit = "0.27"
image = "0.23"
rfd = "0.11"
yes, i know they're not the latest
-
clone the repo:
git clone https://github.com/remivoire/voxelspacerust.git cd voxel-landscape-renderer
-
add default assets (optional):
- if you don’t want to pick your own images each time, place default images in an
assets
folder in the root of the project - use these filenames:
- colormap:
assets/map0.color.gif
- heightmap:
assets/map0.height.gif
- colormap:
- if you don’t want to pick your own images each time, place default images in an
-
run the app:
cargo run --release
pro tip: running in release mode is faster, so it’s recommended
when you launch the app, a file dialog will pop up for you to choose:
- colormap: an rgb image file (like
.png
,.jpg
, or.gif
) to give colors to the landscape - heightmap: a grayscale image file (also
.png
,.jpg
, or.gif
) to provide height info for the landscape
if you cancel either dialog, it’ll load the default assets from the assets
folder (if available)
use the following keys to move around and interact with the landscape:
key | action |
---|---|
up arrow |
move forward |
down arrow |
move backward |
left arrow |
rotate left |
right arrow |
rotate right |
w |
look up |
s |
look down |
e |
move camera higher |
d |
move camera lower |
esc |
exit the app |
a smooth sky gradient effect is applied automatically. it transitions from a light blue at the top to a darker blue near the horizon
main
function: sets up the window, file loading, camera, and starts the event loophandle_window_event
: processes keyboard input and window eventsupdate
: updates camera position and angles using delta time for smooth movementdraw
: handles rendering the landscape and sky gradient with some optimized ray marching for performance
- reduce depth:
zfar
depth is reduced to make rendering faster - bigger ray marching steps: instead of processing every depth layer it steps by 2 layers to cut down computations
- frame-rate independent motion: by using delta time, movement stays smooth regardless of the frame rate