Lowering of terrain not showing up for single coordinates
faweizz opened this issue · 11 comments
Hi! Im working on a project where the terrain can be deformed at runtime. So far, this is working fine. But when single coordinates are lowered under the level of the surrounding coordinates, it shows some weird behaviour:
- Detail is sinking correctly with the coordinate
- The collision layer is sinking correctly with the coordinate
- But the mesh seems like its forming some kind of convex hull around the points
- When i drop the camera into this hole, it seems like the mesh is forming correctly underneath, but due to the hull, its not visible
When raising single coordinates, this works as expected and a spike is formed.
Im using the MULTISPLAT16 shader. There seems to be no change, when i apply other shaders.
Can i turn this behaviour off? (or is this a bug on my side?)
By single coordinates, you mean raising/lowering a single pixel of the heightmap? This is bound to accuracy issues, I wouldn't rely on this because it looks really bad either way, as there is not enough triangles.
I'm also confused as to how lowering has any different effect than raising, there is no different code to handle either, it works the same.
The only possible difference is that the mesh uses a diamond pattern in wireframe, but still, that applies to both raising or lowering.
Can i turn this behaviour off? (or is this a bug on my side?)
You can't turn off "not enough resolution", it's an inherent problem of modifying single pixels 🤔 but I might misunderstand what you mean tbh. I have no idea what is that convex hull you are referring to. Do you have screenshots? An MRP? Is it happening too in the editor?
Thanks for your response. I looked further into the issue and noticed that this behaviour also only affects certain x/z regions of my map.
The effect is visible in the screenshot above: The terrain clips through the details, whereas you can see "correct" details on the topright. The area where the details are clipping is lower than the terrain on the top right.
When i lower the terrain in the area where the details are clipping further, the details/collision will lower as expected. The terrain stays the same.
The heightmap is created programmatically, using the apis of your procgen example. When i spawn debug cubes on the x/y/z coordinates i use to create the terrain, they are generally placed at the correct locations. In the described area, they are swallowed in the same way, the details get swallowed.
Can you make a minimal reproduction project? Because I fail to find a quick way to interpret this, as in, what would be the actual cause, because it makes no sense to me that terrain would randomly differ like that in such specific ways. It could be that terrain is scaled so big that the diamond shape difference would begin to show up, or it could be that the mesh doesn't update somehow, or gets an out of date heightmap, or it could be that a LOD chunk failed to hide and stays hovering in place making it look like terrain isn't lowering, or it could be some very specific cicrumstances arising with your code, some timing issue in the steps you followed... really it could be many things, but it needs a clear reproduction project at this point
The repro is not finished, but I managed to find out more. I will propably provide it this weekend.
What I managed to find out is the following: When I create a gdscript with 2 functions which are called externally, one being init and one being an update, I can reproduce the issue.
The init function just initialises a terrain/data and adds it as a child.
The update call writes height data to the terrain and updates it.
When I call init/update with some time in between, the issue appears. When I write the data directly after instantiating the terrain, the terrain behaves as expected.
What I’m currently not doing is updating the terrain normals as you are referring to in the documentation about programmatically updating the terrain. Could this lead to a problem as such?
What I’m currently not doing is updating the terrain normals
That should not affect the heightmap.
Sorry for the delay but i managed to finish the repro: https://github.com/faweizz/hterrainrepro
The issue while reproducing was, that the behavior only shows when the camera is near the updated terrain. When i move the camera away and return, the mesh shows correctly.
The repro loads a piece of my heightmap after the hterrain has been instantiated, the camera is placed near the spot where you can see the issue.
Is C# required to run this project? I see a repro.gd
but I can't open scene.tscn.
I ported the script.
Looks like some chunks are overlapping for some reason. The LOD system shows the right ones, but is also not hiding some of them when it should.
One workaround you can use for now is to call terrain._reset_ground_chunks()
after notify_region_change
I think I found a fix in 0b70932
It's very old code, let me know if it works for you
Yes, I use it to bootstrap the scene. if that’s a problem I will rewrite it asap
edit: oops, didn’t reload
This fixes it :)