Luxelith is a Unity project showcasing a hyper‑performant voxel world renderer powered by Compute Shaders and greedy meshing on the GPU. It streams chunks around the player, generates terrain with Burst/Jobs, and builds meshes via a shared GPU mesher with async readback. The goal of this project was to create a Unity voxel engine that does not use GameObject based chunks and CPU bound mesh generation like most tutorials on the internet, but rather calculating as much as possible using compute shaders, as well as using multithreading to make the best possible voxel engine I could in Unity for my own projects. I wanted to share this code so anybody would be able to use this as a basis for their own Voxel Projects in Unity.
Key modules
- GPU meshing (compute + greedy) with per‑face textures
- Streaming and terrain generation (Burst/Jobs)
- Block database (per‑face Texture2DArray indices) and editor tooling
- Fly camera and diagnostics overlays
For detailed documentation, see the docs folder:
- docs/overview.md
- Per‑script reference stubs in docs/scripts/
- Unity version: see
ProjectSettings/ProjectVersion.txt(tested with 6000.0.24f1) - Open the project at
HyperPerformantGPURendering/ - In a scene, add:
- WorldStreamer (assign ComputeShader/Material or let it auto‑load from Resources)
- BlockDatabaseIntegration (assign a
BlockDefinitionDatabaseasset) - PlayerFlyController on the Camera rig and assign it to the Player field in the World Streamer
- Create/assign
Assets/BlockDefinitionDatabase.assetwith a Texture2DArray atlas; open Tools > Voxel Engine > Block Editor to author per‑face indices. - Play. The world streams around the player in a deterministic spiral.
You can also use the already pre-setup default scene.
- ComputeShader greedy mesher with per‑face texture indices
- Async GPU readback + MeshData API to reduce GC and main‑thread stalls
- Deterministic streaming order, distance‑based unload
- Burst IJob terrain generation (FBM sample included)
- Editor Block Editor with live per‑face preview from Texture2DArray
- Build diagnostics overlay (FPS, frame time, memory, compute support)
- Assets/ActualStuff/Scripts/Voxels
- ChunkDefs, Chunk, WorldStreamer, GpuMesher, TerrainGeneration (GenerateChunkVoxelsJob), BuildDiagnostic
- BlockDefinition, BlockDefinitionDatabase, BlockDatabaseIntegration, BlockTypes (ids & UV triplets)
- Assets/ActualStuff/EditorStuff
- Editor: BlockEditor, TextureArrayShaderGUI
- Scripts/Voxels: BlockTypes (BlockId, UV triplets, static BlockDatabase used by GPU mesher)
See docs/scripts/ for per‑file notes.
-
WorldStreamer
- Computes a streaming center (player/camera), keeps chunks within
viewDistanceChunks - Schedules
GenerateChunkVoxelsJobto fillNativeArray<byte>voxels - Queues ready chunks, feeds them to a shared
GpuMesher - Reads back counters then vertex/index streams; applies via MeshData; draws with
Graphics.DrawMesh
- Computes a streaming center (player/camera), keeps chunks within
-
GpuMesher
- Manages ComputeBuffers (voxels, counters, vertices, indices, UV triplets, per‑face textures)
- Dispatches greedy kernels for ±X/±Y/±Z planes
- Supports per‑face texture mapping via
[blockCount*6]buffer uploaded byBlockDatabaseIntegration
-
Blocks & textures
BlockDefinitionDatabasestoresBlockDefinitions (id, per‑face texture indices, gameplay flags)BlockDatabaseIntegrationuploads per‑face indices to the mesherBlockEditor(EditorWindow) previews/edits faces and reads slices fromTexture2DArray
- Ensure target platform supports compute shaders and URP (or the target shader)
- Provide a
Texture2DArraywith one tile per material slice; set array slice count on the material/shader if required - Add a Directional Light for sun direction (optional). Defaults to Vector3.down if missing
- No meshes: assign/locate
Resources/VoxelMesher.computeor setvoxelMesherin WorldStreamer - All faces same texture: ensure
BlockDatabaseIntegrationis in scene and database has a validTexture2DArray; use its Refresh action - Editor preview shows color tiles: extraction fallback when array isn’t readable; verify Texture2DArray asset
- Performance: enable
BuildDiagnostic, reduceviewDistanceChunks/maxGeneratePerFrame
See LICENSE.

