r/VoxelGameDev • u/charlieatron • 2d ago
Media Early showcase of my GPU-based voxel project I'm working on in Unity
Finally getting around to sharing this here! I've been working on this Unity project for a while. The concept is still pretty barebones as I figure out what I want this to be, but one of my central focuses is taking Minecraft and adding or changing things based on what I find interesting (so far that's been rendering with URP, first-person viewmodel, geology & world generation, among other small things)
On a technical level, I've been using my experience in writing shaders to build this project with a GPU-accelerated approach. This takes the form of two main parts of my voxel system:
- Terrain Generation: when the world generates, I dispatch a compute shader to compute the multiple levels of terrain height, plus additional features like stone layers and mixing between different stone & soil types. This is done in a couple of passes, all on the GPU, then the data is read back to the CPU as a list of integers, where it is converted into proper Voxel objects and stored in each chunk
- Meshing: I've gone through a few different approaches for this, but lately I've settled on a C#/shader hybrid. Each chunk has a MonoBehavior object that stores its 3D array of voxels & handles any edits that get made to it. When meshing, the chunk turns those voxels into a structured buffer that is sent to the mesh's shader, effectively as a single vertex per voxel. The shader then has a geometry shader step, where that single voxel is turned into vertices for up to 6 potential faces based on its neighbors, and those newly-generated vertices then go on to get drawn in the fragment shader.
Again this is all still very early conceptually, this project is mostly just a learning exercise and an opportunity to play around and try new things! Would be happy to answer any questions about it or get any advice the community might have.