I have a height map that I want to convert into a sphere to make a planet. The only problem is that I don't know how to convert a cube to a sphere. How can I do that?

  • Megalomaniak replied to this.
  • Fallen How can I do that?

    You wouldn't. You would create or generate a sphere and then UV map the image to it, or rather it's segment of the surface to the respective image.

    Conveniently the editor already should offer a sphere option in the editor inspector when you add a MeshInstance node to your scene tree. In case your planetoid is going to be "embarkable" or "landable" or even low orbit/in atmo flyable you wouldn't actually use the same sphere but implement some means of smoothly transitioning to, likely a chunk based, terrain model/system.

    Fallen How can I do that?

    You wouldn't. You would create or generate a sphere and then UV map the image to it, or rather it's segment of the surface to the respective image.

    Conveniently the editor already should offer a sphere option in the editor inspector when you add a MeshInstance node to your scene tree. In case your planetoid is going to be "embarkable" or "landable" or even low orbit/in atmo flyable you wouldn't actually use the same sphere but implement some means of smoothly transitioning to, likely a chunk based, terrain model/system.

    A planet to look at or a planet to walk on ?
    And is your height map actually a cube map ?

    I don't have a ready made cube-to-sphere algorithm, but there are several tutorials.

    If you go the cube map way, the simplest way starting with a cube around the origin, let's say +/-0.5 on all axes. Then you stepwise subdivide each face of the cube, creating new vertices in the middle between each 2 vertices. Each vertex maps to a sphere simply by normalizing and multiplying with the radius.

    I'm more of a low level programmer, maybe a colleague can tell how to do this in Godot. Start with a subdivided cube mesh instance and normalize/multiply each vertex ?

    TL;DR: You should probably go into a bit more detail on what you actually want to achieve and do.