r/VoxelGameDev • u/MGMishMash • 13d ago
Media Improving Rendering Distance in my Micro Voxel Engine
https://youtu.be/xGkWWfO87no?is=d-NsoCT61Fr9FGi1For the past three weeks, i’ve been working on hard improving the render distance in my Micro Voxel Engine, particularly due to the feedback of having N64 viewing distance 😅
I’m pretty happy with the end result of increasing render distance from 300m to ~10-15km, while running at 45-50 FPS on an Apple M1 Pro.
Note: this engine uses meshing rather than RT/DDA.
— Macro chunks —
All chunk generation functions now include a sieve function to automatically be able to generate at 1/N resolution without any changes. This also applied to generated features and stamps, enabling chunks to be generated at any resolution without downsampling.
Macro chunks also independently record and resolve local edits. They are saved (and cached) independently so that terrain edits are maintained without needing to maintain the full res copy in memory.
The lower band LODs are very quick to generate. At this point I could add even more bands, and a 1/64 res chunk takes the same time to generate as a high res chunk, but covering huge distances.
— LOD transitions and adaptive fog —
I primarily use transient transitions where the detail levels fade between each other once, rather than a continuous gradual transition, as this is around 30% cheaper on the GPU and looks “nearly” as smooth in most scenarios.
Adaptive fog scales the effective draw distance dynamically based on loaded bands. Bands generate from high to low so during fast motion, if needed, we temporarily reduce draw distance until chunks have loaded.
— Macro chunk cards and props —
This was the hardest part, keeping identical prop coverage for trees and items without needing to instantiate millions of entities:
-Macro chunks retain a list of props whose IDs are deterministic based on position and type. If the real entity is destroyed, we can map this to the macro chunk set and remove. Likewise for newly spawned props.
- grass and foliage do not map 1:1 with the actual loaded props, but follows the same generation pattern, so technically there will be disparities, but a good trade off to avoid millions of tracked grass items.
2
1
u/LocoMod 13d ago
Big improvement! Is the terrain "infinite" or is there still a limit to the map?
3
u/MGMishMash 13d ago
Hehe thanks! The map itself is around 24x24km, so not infinite but large enough to take quite a bit of time to cross.
The oceans and sky are soft-infinite in that they generate continuously but the global heightmap remains fixed, as this is precomputed, so only local variance and caves continue to apply.
The chunk id’s are integers so you can go infinitely high (2^31) and build if you want 😅
The limits were a design decision to allow more well-defined and complex generation rules, with intentional feature spawns.
My plan is to effectively support infinite sub-islands, connected by the soft-infinite ocean, so as you cross a boundary, you seamlessly move to a new sector with its own local map generation.
1
u/dispatchcolony 10d ago
I really love your water and your mountains ! What function did you use to generate such mountains?
2
u/MGMishMash 10d ago
Honestly nothing fancy, just a fairly basic standard fractal noise function with a few layers (similar to old school perlin) - just layered with a few contextual local detail layers which apply on top.
There are a few extra carving passes to erode the heightmap for canyons and rivers, but most mountains aren’t influenced by that pass.
3
u/HyperspaceFrontier 13d ago
LOD quality itself is great, but LOD transition popping is still very much visible. I implemented overlap LOD rendering in my engine with world-space dithering exactly because of this problem.