Generating a planet mesh
I'm trying to create a planet, using either the builtin sphere mesh or generating my mesh on the fly if that's better. I want it to contain real valleys and mountains, for which I'm planning to use the Open Simplex module to generate a noise map. Stuff like player navigation / orientation should be fairly easy to script, Godot seems to make spider physics easy... I am however stuck on three aspects I need your help with for starters:
- How do I offset the vertices of the sphere toward or away from its center? With a plane this is easier as you can just go from start to end across the X and Z directions... in this case however the noise must be mapped to the body of a sphere. I don't mind doing it with either GDScript or a shader (whichever is better) though it mustn't break #2:
- Once 1 is working, how do I make the deformed shape of the sphere collide so physical items interact with the terrain?
- For the material, how would I blend different textures based on height so each height level has its own ground, and ideally blend one based on slope so the more vertical a part is the more rocky it looks? I'm assuming I can use the heightmap noise as a splatmap too, but have no idea how to blend different textures or materials with it. Note that each texture will have albedo, roughness, depth (parallax), normal map... and ideally also an alpha channel to be used for realistic blending.
I know this is all a bit complicated but doable, but I need some script pointers to start with. I can offer a little hint to my own question: It is mathematically possible to pack a flat plane into a sphere... I could use this to generate the terrain as a plane more easily, but doing it this way may cause ugly seams so maybe I use a sphere from the start.