hypermine
hypermine copied to clipboard
Populate chunk margins
Chunk data sent to the GPU is wrapped in a one-voxel margin that should be, but is not currently, populated with the data from neighboring chunks. If supplied, this data would produce correct AO and hidden face detection for voxels on the face of a chunk, improving both visuals and performance.
There are two exceptions:
- Chunks which are otherwise void do not benefit from having margins set, as they have no faces to hide or occlude. Setting a margin might also interfere with efficient sparse representation of such chunks.
- Chunk faces which face graph nodes that don't yet exist, i.e. outside of the graph, cannot be populated, as their chunks are sensitive to parameters that have not yet been computed. Fortunately, we can make up whatever values we like for them: a camera within the graph cannot possibly observe any potentially exposed voxel faces along such a chunk face, and ambient occlusion errors will be difficult to see, especially in the presence of distance fog.
A fix here will likely have a massive benefit to terrain rendering performance, as right now the overwhelming majority of rendered triangles are hidden.
For the second bullet point, as more chunks are generated, surface extraction has to be repeated for chunks with new neighbors. @Ralith, do you have a recommended optimization for this, or should this be figured out by the person who tackles this issue?
Off the cuff, I think it would be reasonable to mark chunks generated with incomplete margins, and regenerate them when new margin data becomes available. We could also just perform no surface extraction for a chunk unless its margins are fully known; that would require more data to be held in memory to achieve a given view distance, but that memory usage might not be the limiting factor anyway.
That makes a lot of sense. I think the second option would be simpler for an initial implementation, so once we've done some profiling, we should be able to make a better decision here.
mark chunks generated with incomplete margins, and regenerate them when new margin data becomes available
Simpler approach: whenever voxel data for a chunk is first populated, invalidate surface extraction for any previously surface-extracted chunks. The same mechanism can be applied when edits touch a chunk face.