Baby steps – Planet and Stars
How do you wrap a 2D image around a sphere? Well, the most familiar way to me is what 3ds max calls spherical mapping; you’ll have seen this if you’ve looked at a 2D atlas. The top and bottom poles of the sphere get a much larger area of the image than the middle of the sphere. Without correcting for this in some way, the top and bottom seem very pinched. I found a way of correcting for this, for a (horizontally tileable) texture in Photoshop. You can download a little action I made to help with this here. I’ll try and illustrate what you get from it with an image:
Top left – front view of sphere’s geometry with yellow UV seams at poles; top right – UV layout; bottom left – a cheap 2D grid texture I photoshopped together using my action; bottom right: the resultant sphere with texture applied. Although the grid on top and on the sides doesn’t match up, at least the scale is relatively consistent, which for most textures will be the most obvious thing if standing out.
Another way of mapping spheres, with less distortion, is using a cube map. This is just 6 images representing the positive and negative of the 3 axes – front, back, left, right, top, bottom. I’m probably going to use this method for a static “spherical” environment of a star-field, to indicate far off, where there is no geometry. It’s very cheap on modern graphics cards, and you can generate them in 3ds max easily using an existing environment. Here’s a quick test I did in the engine:
The cube map starfield was created in about a minute using a pflow system in max. It is apparently possible to generate a “real-time” cube map starfield texture procedurally, but I doubt my skills will be up to it in the near future. I’ll probably just create something prettier in max and photoshop, or maybe not use cube maps at all and go with pure geometry.
In the above image, the planet is a geosphere (triangles and no geometric poles) with spherical mapping using the method above with a PS generated texture. Obviously the lighting and shading are really dull at the moment. The vertical poles look pretty good, except when the LOD mesh kicks in – probably a UV interpolation issue. Not yet sure whether to go with procedural planets, moons etc, or bitmaps. I’ll leave it to when I really want to overhaul the graphics!