Zylann / godot_voxel

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

removing terrain glitches instances that are on top of it #670

Closed DeepCanionStudio closed 4 months ago

DeepCanionStudio commented 4 months ago

this video shows what happens

https://github.com/Zylann/godot_voxel/assets/132934035/fc917d3d-9cb0-4774-a795-bed8fa4c3956

i'm using a voxel instancer on a voxel lod terrain this happens on both persistent and not persistent instances this only happens on multi mesh instances, if i delete the terrain under a scene instance nothing happens and the instance stays there

MGilleronFJ commented 4 months ago

I have never seen that before. I wonder if it's a new Godot bug or something? I can't think of a reason why that could be happening 🤔 Soooo since that's a bug report, what version of Godot are you using? Did you try with a different version? Which OS? Which graphics card? Do you have a minimal reproduction project to test this? There was an issue template to fill: https://github.com/Zylann/godot_voxel/blob/master/.github/ISSUE_TEMPLATE/bug_report.md

DeepCanionStudio commented 4 months ago

i've spent 40 minutes trying to reproduce the issue on another project with the same godot version and i can't i also want to mention that i often get this error message in the log:

modules\voxel\terrain\instancing\voxel_instancer.cpp:657 - Condition "_parent == nullptr" is true.

i'm on windows, godot version is 4.2.2, my graphics card is an rx 6650xt

DeepCanionStudio commented 4 months ago

this is the full error

E 0:00:00:0928 zylann::voxel::VoxelInstancer::regenerate_layer: Condition "_parent == nullptr" is true. <Sorgente C++> modules\voxel\terrain\instancing\voxel_instancer.cpp:657 @ zylann::voxel::VoxelInstancer::regenerate_layer()

MGilleronFJ commented 4 months ago

i've spent 40 minutes trying to reproduce the issue on another project with the same godot version and i can't

If you can't, there is very little chance that I can help fixing this by making my own repro as well... (especially if that's a Godot bug, because that's needed for Godot devs to fix it)

modules\voxel\terrain\instancing\voxel_instancer.cpp:657 - Condition "_parent == nullptr" is true.

This error happens here: https://github.com/Zylann/godot_voxel/blob/ec063a684a4b17878d4018c015c55e2d625f724c/terrain/instancing/voxel_instancer.cpp#L657 It happens if you are trying to modify the configuration of an existing instancer while it's not in the scene tree. Whether that's supposed to happen or not is subject to the same need for reproduction steps. It should be possible to setup an instancer with code (that's what my own demo does), but the code checks for some situations where it's not permitted, I'm not sure how you're triggering it. I dont think it's related to your issue though.

DeepCanionStudio commented 4 months ago

i copied the project where the bug happens and reduced it to the bare essentials https://github.com/DeepCanionStudio/Voxel-Tools-Instancing-Glitch

Zylann commented 4 months ago

The link doesn't work

DeepCanionStudio commented 4 months ago

i forgot to make it public, fixed now

Zylann commented 4 months ago

I suppose I have to launch solar_system.tscn? There are a lot of errors:

WARNING: res://scenes/solar_system.tscn:9 - ext_resource, invalid UID: uid://cj4hmsylv8hxo - using text path instead: res://shaders/foliage.tres
     at: ResourceLoaderText::load (scene\resources\resource_format_text.cpp:448)
scene\resources\resource_format_text.cpp:448 - res://scenes/solar_system.tscn:9 - ext_resource, invalid UID: uid://cj4hmsylv8hxo - using text path instead: res://shaders/foliage.tres
Compiled voxel graph. Program size: 76b, ports: 9, buffers: 3
Voxel graph compiled in 804 us
Construct VoxelLodTerrain
ERROR: Condition "_parent == nullptr" is true.
   at: zylann::voxel::VoxelInstancer::regenerate_layer (modules\voxel\terrain\instancing\voxel_instancer.cpp:681)
modules\voxel\terrain\instancing\voxel_instancer.cpp:681 - Condition "_parent == nullptr" is true.
ERROR: Condition "_parent == nullptr" is true.
   at: zylann::voxel::VoxelInstancer::regenerate_layer (modules\voxel\terrain\instancing\voxel_instancer.cpp:681)
modules\voxel\terrain\instancing\voxel_instancer.cpp:681 - Condition "_parent == nullptr" is true.
ERROR: Condition "!is_inside_tree()" is true. Returning: Transform3D()
   at: Node3D::get_global_transform (scene\3d\node_3d.cpp:343)
scene\3d\node_3d.cpp:343 - Condition "!is_inside_tree()" is true. Returning: Transform3D()
ERROR: Condition "!is_inside_tree()" is true. Returning: Transform3D()
   at: Node3D::get_global_transform (scene\3d\node_3d.cpp:343)
scene\3d\node_3d.cpp:343 - Condition "!is_inside_tree()" is true. Returning: Transform3D()
ERROR: Condition "!is_inside_tree()" is true. Returning: Transform3D()
   at: Node3D::get_global_transform (scene\3d\node_3d.cpp:343)
scene\3d\node_3d.cpp:343 - Condition "!is_inside_tree()" is true. Returning: Transform3D()
ERROR: Condition "!is_inside_tree()" is true. Returning: Transform3D()
   at: Node3D::get_global_transform (scene\3d\node_3d.cpp:343)
scene\3d\node_3d.cpp:343 - Condition "!is_inside_tree()" is true. Returning: Transform3D()
ERROR: Condition "!is_inside_tree()" is true. Returning: Transform3D()
   at: Node3D::get_global_transform (scene\3d\node_3d.cpp:343)
scene\3d\node_3d.cpp:343 - Condition "!is_inside_tree()" is true. Returning: Transform3D()
ERROR: Condition "!is_inside_tree()" is true. Returning: Transform3D()
   at: Node3D::get_global_transform (scene\3d\node_3d.cpp:343)
scene\3d\node_3d.cpp:343 - Condition "!is_inside_tree()" is true. Returning: Transform3D()
ERROR: Node not found: "" (relative to "/root/Solar System/PlanetContainer/sun").
   at: (scene\main\node.cpp:1652)
Node not found: "" (relative to "/root/Solar System/PlanetContainer/sun").
ERROR: Cannot open file 'res://saves/inengine/sun_builds.tscn'.
   at: (scene\resources\resource_format_text.cpp:1643)
Cannot open file 'res://saves/inengine/sun_builds.tscn'.
ERROR: Failed loading resource: res://saves/inengine/sun_builds.tscn. Make sure resources have been imported by opening the project in the editor at least once.
   at: (core\io\resource_loader.cpp:275)
Failed loading resource: res://saves/inengine/sun_builds.tscn. Make sure resources have been imported by opening the project in the editor at least once.
ERROR: Node not found: "" (relative to "/root/Solar System/PlanetContainer/wandering_oasis").
   at: (scene\main\node.cpp:1652)
Node not found: "" (relative to "/root/Solar System/PlanetContainer/wandering_oasis").
ERROR: Cannot open file 'res://saves/inengine/wandering_oasis_builds.tscn'.
   at: (scene\resources\resource_format_text.cpp:1643)
Cannot open file 'res://saves/inengine/wandering_oasis_builds.tscn'.
ERROR: Failed loading resource: res://saves/inengine/wandering_oasis_builds.tscn. Make sure resources have been imported by opening the project in the editor at least once.
   at: (core\io\resource_loader.cpp:275)
Failed loading resource: res://saves/inengine/wandering_oasis_builds.tscn. Make sure resources have been imported by opening the project in the editor at least once.
Creating VoxelEngineUpdater
Pairing viewer {i: 0, v: 1} to VoxelLodTerrain
Setting reference to 0 (sun)
Close to wandering_oasis which is at (1915.914, 0, 3205.828)
Setting reference to 1 (wandering_oasis)
ERROR: Node origin and target are in the same position, look_at() failed.
   at: (scene\3d\node_3d.cpp:935)
Node origin and target are in the same position, look_at() failed.
Setting reference to 0 (sun)

And when it's finished loading I'm here: image And I can't do anything but look around with a weirdly-angled camera.

Unless you have a quick fix to that, you should really find a more minimal way of reproducing that issue, because there are way too many things going on.

DeepCanionStudio commented 4 months ago

And when it's finished loading I'm here:

i forgot to change this when i committed the project, the planet needs to be at x = 3700

Unless you have a quick fix to that, you should really find a more minimal way of reproducing that issue, because there are way too many things going on.

i removed as much stuff as i could without having to make the project from scratch (i tried making it from scratch but the issue never appeard)

Zylann commented 4 months ago

Unfortunately that doesn't fix it: when I investigate projects like this, I run the engine in debug mode, which is significantly slower. Your game is not accounting for the possibility that the player could reach the ground before ground collision is generated, so I fall through the planet and end up very far away. But again, if the repro was better constrained than that it would be easier.

DeepCanionStudio commented 4 months ago

for some reason the planet is considered far from the ship when it's at 0 0 0 and theres a line in the code that deactivates the collision when the planet is far from the ship, that is why moving the planet should work, if the problem is the collision taking more time just move the player farther from the center

Zylann commented 4 months ago

I already tried turning off the character's physics process if the area isn't loaded, but it is loaded... so I guess it's because of your other logic thing turning off collision? (which again is one of the many things that should be a non-issue if the project was properly constrained to work as a repro project).

that is why moving the planet should work

I already moved the planet to x=3700. It changes stuff but it doesn't help getting anywhere close to a state where the bug can begin to be reproduced. The ship is also falling through the ground, and for some reason the ground isn't rendering. Then even if I manually force the player to not fall, the planet disappears entirely on its own after a few seconds...

https://github.com/Zylann/godot_voxel/assets/1311555/71a2ab51-d016-401b-b982-b7a973494afd

I don't know, remove the ship logic (and the ship maybe), make the planet static, make a basic fly camera instead of a character with collision and all the things, place it where it should be to repro the issue etc; you shouldn't need to remake everything from scratch, just remove stuff (especially from the player) while keeping environment graphics (since it appears to be a rendering bug anyways, not sure it's a voxel bug)

DeepCanionStudio commented 4 months ago

i updated the repository and now there's nothing aside from the planet and the player that can move and modify the terrain

Zylann commented 4 months ago

Is the issue still happening for you if you turn off FSR2?

DeepCanionStudio commented 4 months ago

it's fixed, that was actually the problem, thanks,

Zylann commented 4 months ago

Well... no, it's not fixed, at least not in Godot. This shows there is apparently a bug in Godot that somehow links FSR2 to multimeshes randomly getting garbage, until proven otherwise.

I tried turning off FSR2 at runtime after the issue started happening, but it didn't "fix" it. Though maybe the issue occurs at the time multimeshes get modified.

DeepCanionStudio commented 4 months ago

yea it's not fixed but at least there is the solution of not using FSR2, and FSR1 works so for now i think it's fine, although this problem should be mentioned in the documentation even if it's a godot problem and not a voxel tools problem

Zylann commented 4 months ago

Bugs should not be "documented", they should be reported in the issue tracker (which then helps finding them). I could not find one linked about multimeshes and FSR2. Is the minimal project you made from scratch earlier able to reproduce the issue now, if you use FSR2 in it?


I think I got something in a new project. Doesn't look the same, but enough to see there is a problem