A hybrid voxel rendering engine, written with C and OpenGL. The goal of this project is to make a voxel engine capable of rendering huge fully destructible scenes on reasonable desktop hardware. And maybe eventually a game.
This is achieved with OpenGL splatting, basically rendering quads and ray-aabb testing in a fragment shader. This reduces the vertex count to just 1 per voxel, but with a somewhat slow fragment shader. This is a real probelm with nearby voxels, so hybrid rendering is used: meshes for nearby, splatting farther away.
All voxels are stored in flat arrays, rle compressed when inactive. Level of detail is implemented by "mipmapping" visible voxels of a chunk and grouping geometry by lod level to an octree-like structure to reduce draw calls. LOD kicks in at 1024 voxels away, far enough that single voxels are about a single pixel in size at 1080p.
There was support a while back, see the album linked below. The splatter can do them just fine. But the meshing and rendering are already complex and messy enough to develop without textures, dropped support until those system are less temp-code. I also just like solidcolor voxels :)
Splatting method was inspired by this paper
Work in progress!
This is also my first large C project, there is a lot of code and a lot of it is ugly and temporary. Especially the mesher. Don't look at the mesher.
List of some launch options and their default values:
How much memory to allocate. You must adjust this for larger worlds.
Root of the chunks. You must use power of twos!
--world_size 2K 256 2K
Size of the world. Only power of twos!
Use OpenGL compatability mode. Might help if you have trouble running the engine.
- OpenGL splatting capable of drawing large scenes at high framerates
- Standard meshed rendering for nearby voxels for additional effects and speed
- Fast culler and mesher (a lot of it is still very WIP)
- 64^3 in 1-4 milliseconds singlethreaded on a Ryzen 1600 @ 3.8GHz
- Subtle level of detail (starts at 1024 voxels away)
- Block placement and removal
- Completetly fake shadows and ambient occlusion
- Custom world generator for pretty screenshots
- No hardcoded world or chunk size
- RLE compression
- Simple custom malloc implementation
- Ingame console (F12 to toggle)
- Builds on Linux and Windows (with MinGW)
More pretty pictures and history at https://imgur.com/a/6zwciLy
CMAKE Required. Libraries not included.
mkdir build; cd build; cmake ..; make;
build.sh are for development use.
mkdir build; cd build; cmake .. -G "MinGW Makefiles"; mingw32-make;
- glad (included)
- OpenMP and pthreads
No license - I wish to keep my rights to it for now.