Thursday, December 12, 2013

On Procedurally-Generated Space Systems

Most of the people that know me know that I love space and space exploration. Most of the people who have read a few of my other posts will have been able to gather that same information.You may also be aware that, since I can't actually go out and explore space personally, I tend to enjoy video games that allow me to do that sort of thing.

What might surprise you to know is that I actually don't play that many space exploration games. I own and have played quite a few, including Battlecruiser Millenium Gold, Artemis SSBSFreelancer, Galaxy on Fire 2 (for the PC, of course), and X3: Terran Conflict. All of them had their good and bad, and some of them I enjoyed much more than others. But the thing that they all lacked in common was the actual feeling of exploring space. Some of them had really large and really open worlds. Some of them were good at handling free-roam elements while still providing a story. But the reason that I don't play these games regularly, (and didn't even finish several of them) is because I didn't get that feeling that I was looking for, the feeling of adventure and exploration, the feeling of finding something new that had never been seen before, and that has prevented me from dedicating much time to the genre, outside of looking for a new game that might slake my thirst.

One of the major issues with space games actually comes from the limits of computer precision. I know that sounds ludicrous, since consumer computers these days are incredibly powerful, but it's true. To put it simply, the variables that are used to hold location data can only hold the kind of precision that games need out to a certain number of digits. The end result is that most game engines can't handle distances larger than 100 km or so before the accuracy makes the game unplayable. 100 km sounds like a lot, and for games like Halo and Half-Life, 100 km is more than sufficient. However, for most space-type games, 100 km is practically nothing. 100 km is the distance from the surface of the earth to what is considered the lowest border of "space." However, the International Space Station orbits the earth at almost 4 times that distance, and the moon orbits the earth almost 1000 times further. 

Now, some games get around this limitation by moving the origin of the measurement system periodically. Some games handle this with load screens between areas. Other games manage to dynamically move the origin without a load screen, depending on the system speed. However, these games are still generally kept in smaller regions, planet-bound or similar. Additionally, the need for art assets for large game areas makes the memory requirements substantial.

Except when it doesn't. As I was searching for a way to overcome floating-point precision errors for my own projects, I stumbled across the work of a programmer named Imerso. His program is an amazing space exploration engine with some incredible features. On the surface it seems simple. The player controls a simple-looking spaceship while flying around a solar system, but a deeper look reveals some ground-breaking concepts. First of all, his program uses an algorithm for procedurally generating entire planets, complete with fractal-based surface topography. (By the way, follow that link. Fractally-generated landscapes are incredible.) The amazing thing about this program is that it generates planets that are actually planet-sized, meaning larger than 100km in diameter. The second awesome thing the program does is it incorporates an algorithm for seamlessly moving the origin of the game as your player ship moves through the system. Because of this and a good control over the level of detail, you can fly your ship between planets and all the way down to the surface and back again without ever seeing a loading screen. Now, if this doesn't sound amazing or remarkable in any way, you probably haven't played many video games. 
Let me be clear.
THIS
IS
INCREDIBLE
And it gets more incredible-er
The C++ demonstration version of the whole program, including all art assets, is only 88 kilobytes.
I'll repeat
Eighty-eight kilobytes. Not Gigabytes, not Megabytes. Kilobytes. As in, you could fit the entire program 16 times on an old 3.5" High-Density floppy disk and still have enough room left over for a 10-page Word document.
If you don't believe me, check out the following videos:

This first one is basically what the 88 kilobyte tech demo (for free download on that page) looks and feels like, except there's a little 3rd-person spaceship in the middle of the screen and a sort of HUD to display info like speed, distance to next, etc. As you can see, there are no gaps as the camera flies from deep space down to the surface of the planet and back again.

This second one is exactly what the tech demo is like, except for the music. That you have to provide yourself.

Now, the game engine itself has been developed for use with Unity 3D, which is a game development platform. The engine is available for sale and purchasing it give you the ability to incorporate it into any sort of game you want. This means you can add gigabytes and gigabytes of high-def art assets and complex gameplay and everything 
This last video demonstrates the kind of scale he can achieve with the engine:


Now, the one thing a lot of you may have been noticing if you're clever, is that the actual scale between celestial objects isn't quite right. And if you didn't notice that, take a minute to think. When you look up at the sky, how big do other planets look to you? Quarter-sized? Nickel-sized? Even dime-sized? If you know what you're looking for, the planets look like brighter-than-normal stars. That's the one thing that bothers me about this engine, and it's not even a problem with the engine, but rather with the tech demo. That last video shows the ability the engine has to separate objects by realistic distances, so really it's more of a question of the user doing the right thing with it. 

Imagine what could be done with this sort of thing. Imagine a game where you can fly your ship to a new planet, travel down to the surface and find an interesting place to land. Then you get out of the ship and explore the area, maybe even building a base of operations in a secluded area. Then you can fly right back out to space and find new regions, new planets and moons. The engine could generate a near-infinite universe of unique planets, moons, and solar systems. 

Even if the engine were used for a single planet, that could be a huge step for gaming. Planets could be randomly generated, complete with cities and environment locations. This could be the base for a strategy game, an adventure game, or even a first-person shooter MMO.

Basically, this sort of engine could be used to create the kind of space exploration game that I could really sink my teeth into (and by teeth, I mean time).


No comments:

Post a Comment