4

I'm currently working on some Planet Generation mainly for fun and hoping to end up with some kick ass planets. I'm using a Cube which has been mapped into a sphere by normalization. planet terrain and sky

The terrain isn't textured properly yet in this picture. This is just the render from the Heightmap. However this is not my problem. When creating a sphere from a cube you are left with 6 faces bent to the shape of a sphere. Therefore, I do not have latitude and longitude that can be used to wrap a spherical heightmap around the terrain. Currently I'm using Cube Mapping. However, this has caused several problems, as you can see: cube-to-sphere mapping problems —where my problem becomes obvious. The problem is due to the fact that the sphere still has the topology of a cube. I have to generate a heightmap for each face. I use Libnoise currently for the heightmap and this is where the big problem starts. I can either export it as a spherical heightmap—which would be useful if i had a sphere—or I can use planar heightmaps which must be mapped to all 6 faces. However, due to how the mapping works. I can get 3 faces to line up around the middle and be seamless but the last heightmap won't join to the first as Lib noise uses bounds and creates a grid of coordinates.

The sphere is created like so—

for(int i = 0; i < vertices.size(); i++)
{

    glm::vec3 oldVec = vertices[i];
    glm::vec3 newVec = glm::normalize(oldVec);
    vertices[i] = newVec * glm::vec3(500, 500, 500);
}

The reasoning behind this can be seen here.

However, the structure of the sphere will make it easier to implement lod in the form of a Quad-Ttee later on. Is there anyway I can generate a cube map heightmap with LibNoise? Or is there something I can do to make the sphere be able to use a sphereical heightmap?

I figured out how to make it render using Sphere Maps but this isn't going to work when i come to using a quad tree. However, it produces some nice results like:

enter image description here

So, i pretty much i need to know how to tile noise into a cube map. Either with Libnoise or in the vertex shader.

user1118321
  • 23,821
  • 4
  • 52
  • 78
Vangoule
  • 155
  • 2
  • 11

1 Answers1

1

I finally got it working how i intended. To do this i normally unwrapped the cube without a cube map or sphere map. I apply the heights with 3D Perlin noise in the form of a cube map but i'm not using the UV coordinates so it doesn't matter that i haven't unwrapped it as a cube map. I then apply a texture according to the height of the vertex and it seems to produce great results. Maybe i'll have problems later on who knows. Here's a picture of what i got now:

enter image description here

PS: That's not the moon it's the sun. For testing purpose it's closer and i haven't got a sun texture at the moment so i just used an old greyscale heightmap texture so i could see it better. The planet's starting to look great now.

Vangoule
  • 155
  • 2
  • 11