Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.68k stars 251 forks source link

Holes appearing in planetary surface #711

Closed TheBeastOfTrenzalore closed 2 weeks ago

TheBeastOfTrenzalore commented 3 weeks ago

There are holes appearing in the lod terrain of my planet, I've tried adjusting all sorts of settings, but haven't gotten any new results.

The only error appearing in console is: E 0:00:01:0577 zylann::voxel::ComputeShader::load_from_glsl: Assertion failed: "VoxelEngine::get_singleton().has_rendering_device()" is false. <C++ Source> modules\voxel\engine\gpu\compute_shader.cpp:64 @ zylann::voxel::ComputeShader::load_from_glsl()

Fractured Frontiers (DEBUG) 10_18_2024 3_41_12 PM Fractured Frontiers (DEBUG) 10_18_2024 3_41_00 PM

for some reason, when I move back away from the holes, they disappear.

Zylann commented 3 weeks ago

E 0:00:01:0577 zylann::voxel::ComputeShader::load_from_glsl: Assertion failed: "VoxelEngine::get_singleton().has_rendering_device()" is false. <C++ Source> modules\voxel\engine\gpu\compute_shader.cpp:64 @ zylann::voxel::ComputeShader::load_from_glsl()

Which renderer are you using? This error might happen because the renderer you chose doesn't support the RenderingDevice API (but I can't tell because you didn't fill in the issue template), yet you probably enabled GPU features, therefore they fail to initialize? It also depends when and how often that prints, not sure. Though it might not be related to the holes.

for some reason, when I move back away from the holes, they disappear.

You mean, you move away from them, them come closer again, and they don't show up anymore? Do they always show up at the same locations?

Apart from that, I can't really help with this few infos. You should provide the infos the issue template was asking for, and ideally, a really minimal test project that just reproduces the holes, because there are all kinds of factors that could eventually cause this and I can't investigate with no simple reproduction (I don't have this issue in my own game with planets).

TheBeastOfTrenzalore commented 2 weeks ago

I have tried using each of the Godot renderers, none of them seemed to help. I believe the only gpu feature I have enabled was heightmaps (as I said, I tried turning off most things to see if it helped and it did not seem to help).

I mean if I back up they disappear, but if I come close again they reappear.

Here's a simplified version of the project that I saw holes in when testing it (you might have to walk around a bit on the planet to cause the terrain to have a hole):

Error Test.zip

Notes: The holes still exist when I scale the planet way down to like 1000-10000 units (at least they did for me)

This error no longer seems to appear with forward+ renderer though: E 0:00:01:0577 zylann::voxel::ComputeShader::load_from_glsl: Assertion failed: "VoxelEngine::get_singleton().has_rendering_device()" is false. <C++ Source> modules\voxel\engine\gpu\compute_shader.cpp:64 @ zylann::voxel::ComputeShader::load_from_glsl()

Zylann commented 2 weeks ago

I believe the only gpu feature I have enabled was heightmaps

The module only has "gpu detail normalmaps" and "gpu generation", no heightmap stuff. I see in the project you have normalmap_use_gpu enabled.

This no longer seems to appear with forward+ renderer though

Yes the error should not occur when using the Forward+ renderer. The renderer you've been using earlier doesn't support GPU features needed by the stuff you enabled. If you want to avoid the error in other renderers, you should turn it off, or use a script to do so if it is decided at runtime. Though again, I don't think this is related to the holes.

I notice your planet has a radius of 60,000. This is too big for a classic Godot build, as floating-point precision issues can start showing up as quickly as 4 Km away from the origin (subtle at first so it depends on your usage, but it gets worse further away; I've been exploring your planet in editor and moving the camera was iffy).

I also notice your project is in Godot 4.2, which hints that you're using an old version of the voxel module. There has been a release with Godot 4.3 since then, which has the following changes. No particular fix involving holes though.

After some investigation, it seems SDF clipping affects the issue. By default it is set to 1.5, so that if range analysis finds that a whole block has a range never going below 1.5, it gets filled with air. The opposite happen below -1.5. When I found a hole, it went away after increasing that threshold to something like 5.0.

But SDF clipping is only a symptom. It actually depends on range analysis, where each node's range is estimated within blocks to check if the final result can potentially contain a surface. It looks like the Large FastNoise3D node is causing the issue. It is the only node using OpenSimplex2S, the others are using Perlin. Range analysis might be wrong with this specific noise.

TheBeastOfTrenzalore commented 2 weeks ago

Thank you! it seems like this does changing the OpenSimplex noise to Perlin fixes it, even if I try doing more extreme operations on the noise

I do wonder why OpenSimplex caused that behavior, when none of the other types of noise do.

Zylann commented 2 weeks ago

I found the origin of the issue, will push the fix soon. The issue is there is a missing S here c3aa609e300079cc0e37546c21f773edfb45a418