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.
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:
—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:
So, i pretty much i need to know how to tile noise into a cube map. Either with Libnoise or in the vertex shader.