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!
You may have thought I’d given up by now – over a month without an update – but despite seeing such incredible similar indie projects as Infinity Universe (well worth checking out for the crazy scale – over 7 years of dev! and multitude of tech posts), and Salvation Prophecy (also awesome, and actually released), I’m still working on the game. Granted, I haven’t done as much as I would have liked, but then I never do.
Seeing the great projects linked above has filled me with amazement for how much one person can do, as well as depressed me by showing me how much I have left to learn. So I’ll try and keep the scope of this game pretty low, as I don’t want to be working on it forever! I also started watching the first season of Firefly, which I’m loving, but can’t believe how Mr Whedon stole half my ideas before I’d had them! Seriously though, that is almost exactly how I’d pictured the state of civilisation in my far-fetched fantasies about this game.
Ok, here’s some stuff I did in the last month in pretty much chronological order:
- learned some of Zbrush 4R2 and figured out a new, better modelling workflow (along with 3ds max), which I’ll put up a video of in the future. It’ll be useful for any 3d modelling project, really, not just games. Did some spaceships with it.
- Improvised and recorded a sum of around 10 minutes of guitar “music” for the game – who’d have thought your skills degenerate so much after a year of not playing? Tried out FL Studio.
- Messed around a bit with Ogre, read articles/book on game programming, a bit of C++.
- Started a clean framework for the game, using http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Advanced+Ogre+Framework&structure=Tutorials
- Started learning shader programming – all that maths screws with my head. The pain is not alleviated with this complicated (for me anyway) free book GPU Gems 2
A 2-pass planet-y shader. Quite simple, I suppose; the atmosphere pass expands the vertices along their normals, and then colours using a “falloff” like pattern (if you’re used to max’s material system), and there’s a basic blinn shader as pass 2. Unfortunately the way I implemented the atmosphere (writing colour without depth) means it doesn’t work in Ogre when I ported it over. But I knew I’d have to re-write it anyway! I want to figure out a way of doing procedural noise-based planet textures – I’m pretty sure you can do lots of the work on the GPU. It seems everywhere I go for this sort of thing, this guy pops up as being a colleague of the writer: Inigo Quilez. I first came across him about a year ago; he seems to be a total genius having read the majority of his stuff!
Ok that’s enough for now. If you want any detail that I might be able to provide, don’t hesitate to ask.