Realtime volume terrain using geometry nodes

I’m thinking of using geometry nodes in UPBGE 4 to create terrain using the Volume Cube and Volume to Mesh nodes, given how effectively they produce realistic 3D terrain. I don’t need it to be editable in realtime at least for what I’m imagining now, thus I plan on using static noise textures. I do plan to allow a random or customizable seed using the W parameter of 4D noise to get an unique world each run.

While I understand the general setup, I’m not sure how to do this in a way that’s optimal for BGE. Voxel to mesh conversion is expensive and generates a lot of vertices even with adaptivity, which is a problem for rendering and collision performance. Clearly you can’t have the whole terrain as one volume cube: It needs chunks (dis)appearing based on distance with resolution adjusted to the camera distance for LOD. Thankfully UPBGE lets logic nodes change values in geometry nodes, although I remember an issue with collisions not being updated yet: The question is finding the most ideal setup that doesn’t cause a huge performance drop.

My concept so far: BGE rounds the camera’s position to a large grid such as 16 (-16, 0, 16, 32, 48, …) so when the X or Y or Z position snaps to a new value an update is issued… this ensures updates aren’t done each frame, only when the player has moved far enough. Even so I need voxel resolution and vertex count to decrease with range for a good draw distance at reasonable performance; I could just use a series of Merge by Distance nodes based on range to reduce the vertex count, but this requires the mesh to be originally generated at high resolution which causes noticeable freezes per update, I need the original voxel calculation to be light.

As each volume has a fixed resolution multiple cubes are needed. The problem then is you can see the seam where a high resolution volume meets a low resolution cube which moves with the camera and looks ugly. Interior faces also need to be deleted, when I do this I also get holes where the meshes connect. Since geometry nodes don’t have loops you can’t even stack the cubes without a crazy number of nodes, like for a 3 x 3 grid you need to define 27 volumes; It’s thus easier to have a larger volume for each LOD level, but in that case you need to not generate geometry in areas covered by smaller cubes.

What is the best solution? Keep in mind the terrain is meant to have collisions and possibly pathfinding, with characters and NPC’s and physical objects interacting: Those objects will be added or removed as to only exist in areas with terrain and not fall into the void, but the terrain changing thus modifying the collision mesh may cause them to sink or fly off. Other things such as grass will be considered once everything else works, though I’d need foliage to not awkwardly change position as the terrain mesh changes.