mohsenph69 / Godot-MTerrain-plugin

A GDExtension plugin which give godot the ability to produce highly optimized Terrain for Open world games
MIT License
372 stars 19 forks source link

Holes in landscape #3

Closed JekSun97 closed 6 months ago

JekSun97 commented 10 months ago

Will there be support for terrain holes? For example to create caves

And one additional question, is it possible to somehow generate a landscape in real time using code?

mohsenph69 commented 10 months ago

Will there be support for terrain holes? For example to create caves

And one additional question, is it possible to somehow generate a landscape in real time using code?

As you know recently we added texture painting, so what you can do is to send a information with that to where the hole is located (Please watch the texture painting video if did not see that) Then in fragment function do this

if(is_hole){
discard;
}

is_hole is variable that comes from texture painting

This will remove the terrain in that location. So the first part is done.

Now remain the second part, We should remove the physics also. unfortunately Godot physics does not support holes in the terrain, At least for now I did not heard about anything yet, If you know about that let me also know about that.

So in my opinion a away around that for now is to create a platform with physics before cave, put that platform physics layer is in the first slot and the second slot (Terrain physics layer is in the first layer always), So as the player get close to cave disable its physics for the first layer, This way it will not collide with the terrain anymore, and that platform as is in the second physic layer still support player, and as the player get far from the cave you can do the opposite thing.

basically when the player get close to cave you disable the terrain physics, But as player is already is on a platform with another physics layer it will not fall

JekSun97 commented 10 months ago

Thanks for the advice, I'll try it. What about dynamically creating landscapes with code?

mohsenph69 commented 9 months ago

Thanks for the advice, I'll try it. What about dynamically creating landscapes with code?

You know for now I used a lot "World Machine" to create my height map, You can also other terrain generator tools like gaea, world creator and ... The quality which these software will give you is incredible, If you can afford to work with these and import your height-map to Godot it is really good, Even people which use unreal-engine and unity they use them

But in case you want to create with code you can do this: First set your heightmap in a loop and after finishing that save that

for y in range(0,terrain_pixel_height)
     for x in range(0,terrain_pixel_width)
           set_heightmap_by_pixel(x,y, Your_height_Value_in_meter)

save_all_dirty_images()

You can obtain your height-map from noise value and so on

Maybe later I will add the functionality to generate terrain from noise, We will see

The method above is not for changing the terrain in run time

mohsenph69 commented 6 months ago

You can make holes in M Terrain version 0.9.3