bonsairobo / building-blocks

A voxel library for real-time applications.
MIT License
368 stars 30 forks source link

Running `cargo run --example lod_terrain smooth` produces terrain with gaps between chunks. #45

Open johnttan opened 3 years ago

johnttan commented 3 years ago

👋 Hey there!

I tried running the example and ran into some potential issues.

What happens when I run the example: image

What I expected from the docs: image

System Info:

OS Name Microsoft Windows 10 Home
Version 10.0.19044 Build 19044
Other OS Description    Not Available
OS Manufacturer Microsoft Corporation
System Name DESKTOP-PMARINB
System Manufacturer Gigabyte Technology Co., Ltd.
System Model    B450 I AORUS PRO WIFI
System Type x64-based PC
System SKU  Default string
Processor   AMD Ryzen 7 3700X 8-Core Processor, 3593 Mhz, 8 Core(s), 16 Logical Processor(s)
BIOS Version/Date   American Megatrends Inc. F50, 11/27/2019
SMBIOS Version  3.2
Embedded Controller Version 255.255
BIOS Mode   UEFI
BaseBoard Manufacturer  Gigabyte Technology Co., Ltd.
BaseBoard Product   B450 I AORUS PRO WIFI-CF
Installed Physical Memory (RAM) 32.0 GB
Total Physical Memory   32.0 GB
Available Physical Memory   744 MB
Total Virtual Memory    73.9 GB
Available Virtual Memory    7.80 GB
Page File Space 41.9 GB
bonsairobo commented 3 years ago

I'm aware of the issue, but thank you for filing it.

This is a result of the new clipmap algorithms that are currently still in development. You won't find this issue on the v0.7.0 tag.

The root cause is that surface_nets requires copying border voxels from adjacent chunks in order to get the correct transition mesh between chunks. There is currently no constraint in the ChunkTree::clipmap_render_updates function which guarantees all of the neighbors of a chunk are loaded before trying to mesh it. If you move the camera around and trigger re-meshing, then the cracks will disappear, since neighboring chunks have had time to load.

I plan on fixing this before v0.8.0.

bonsairobo commented 3 years ago

I believe this problem is resolved on main, but it is not very performant. I want to work on optimizing the neighbor checking before closing this issue.