hypermine icon indicating copy to clipboard operation
hypermine copied to clipboard

Populate chunk margins

Open Ralith opened this issue 5 years ago • 5 comments

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.

Ralith avatar Apr 08 '20 04:04 Ralith

A fix here will likely have a massive benefit to terrain rendering performance, as right now the overwhelming majority of rendered triangles are hidden.

Ralith avatar Jun 05 '20 23:06 Ralith

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?

patowen avatar Feb 26 '23 15:02 patowen

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.

Ralith avatar Feb 26 '23 23:02 Ralith

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.

patowen avatar Feb 26 '23 23:02 patowen

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.

Ralith avatar Jan 18 '24 07:01 Ralith