FarPlaneTwo

FarPlaneTwo

18.5k Downloads

Question: How does the meshing work?

Dimev opened this issue · 3 comments

commented

I know you are going to do a big writeup later on when the mod is closer to completion, but I'm interested: how do you generate the meshes for the distant chunks?

Looking through the code it looks like it's some form of dual contouring, that looks to be running on a regular grid.
Is this correct, and if so, how do you avoid gaps between lods?

commented

here is a debug image of the LOD blending (the image is from a month ago)
image

commented

well, it depends on which mode you're talking about:

heightmap mode

extremely simple: takes the highest point, rough generators can binary search the entire Y coordinate space.
mesh simplification is as trivial as, for each 2² space of samples, taking the sample whose height has the greatest deviation from the average of all 4.

voxel mode

rough generators simply generate a density grid, and i run dual contouring on that (a slightly modified variant that allows me to have multiple density types for solid/transparent blocks at once, and mixes them together). this doesn't need anything special for generating at lower detail levels - i just need to increase the distance between sample points.
exact generators are also pretty simple: i just track which blocks have at least one exposed face, and assemble the faces into a mesh. the complicated part happens when simplifying those meshes, as i can't do exact generation at arbitrarily low scales. basically, i made the observation that dual contouring doesn't ACTUALLY require a density grid, all it needs is the coordinates and normal vector at which the isosurface intersects each one of the voxel edges. by somewhat abusing this fact, i can run dual contouring on a MESH rather than a density grid. more specifically, i combine all the meshes in a 2³ region of tiles and dual contour those to get a single low-resolution tile. it's not a perfect solution, and i plan to change it to use some form of vertex clustering once i finish changing the "voxel renderer" into a "arbitrary 3d mesh broken up into tiles-renderer".

seamless transitions

literally just this. in voxel mode i simply run it in 3d.

commented

Thanks!