Zylann / godot_heightmap_plugin

HeightMap terrain for Godot implemented in GDScript
Other
1.74k stars 159 forks source link

Is it possible to create infinite procedural generated terrain? #453

Open Critsium-xy opened 4 months ago

Critsium-xy commented 4 months ago

I think I can math the terrain node position to player position, meanwhile streaming the terrain heightmap according to the position. But is this method possible and will this method cause visual artifacts? And if it can be done in this way, when should I use terrain_data.notify_region_change method in real time?

It would be better if there is a simple demo completing this feature

Zylann commented 4 months ago

This plugin is not suitable as-is for streaming. While you could create multiple terrains, they will not line up without seams at the borders. You will have to modify shaders or the way normals are calculated, maybe pad heightmaps in some way so that they take into account neighbor terrains, or use a generation method that produces normals directly instead of running a second pass over a fixed chunk (because otherwise normals just repeat height values 1 pixel beyond the bounds, while it should take the neighbor's border pixel instead).

when should I use terrain_data.notify_region_change method

That method should be called after you're done editing terrain in a specific area during the current frame.

It would be better if there is a simple demo completing this feature

There is one, though quite old: https://github.com/Zylann/godot_heightmap_plugin/blob/master/addons/zylann.hterrain/doc/docs/index.md#procedural-generation

Also, it seems the title of your new issue doesn't actually match what you're asking. Because otherwise, there are many existing posts about generating terrain:

https://github.com/Zylann/godot_heightmap_plugin/issues/448 (already yours?) https://github.com/Zylann/godot_heightmap_plugin/issues/442 https://github.com/Zylann/godot_heightmap_plugin/issues/354 https://github.com/Zylann/godot_heightmap_plugin/issues/195 https://github.com/Zylann/godot_heightmap_plugin/issues/175 https://github.com/Zylann/godot_heightmap_plugin/issues/76