Monday, September 27, 2010

Star Maps

It's really common for star maps to be in 2D. I think this is unfortunate, so I'd like to talk about making the transition to a 3D star map.

The difficulty in a 3D star map is that the human mind really tends to think of surfaces rather than freefloating objects. Just look at how difficult it is to make out what is going on when looking down on scaffolding: how many levels high is it? Which slats are on which levels? This is a problem that many games are beginning to encounter as they try to build very high (tall) levels. Mirror's edge has some examples, as does Prince of Persia: it's easy to lose track of what is "beneath" you, even though you passed through a few moments ago. Which part of the level is that, down there?

And those games have it easy, because at least they're working with surfaces. A star map is just points of light.

There are several things we can do to ease the problems.

One is to introduce surface-like elements, including things like radial disks around certain stars, and trade routes that have broad, flat surfaces. It's critical to keep these things to a size that can be easily extrapolated, so you can tell the distance. Having a disk around a star that grows based on population makes it impossible to use that disk to determine what z-level the star is on. If the disk is always the same size, though, we can guess where the star is by looking at the perspective-induced difference is size.

Having a flat "z-surface" with "raised lines" is pretty common in games. This is descended from old submarine sims. I find this to be a pretty poor solution, only slightly better than no marks at all. A single flat surface with no relation to any of the actual points of light isn't a very useful surface, so the surfaces should integrate the stars.

Gently sliding the camera into position rather than simply "popping" into place is also somewhat useful, as it gives parallax information. This only works until the user switches screens due to the way we process visuals, so it might be useful to slide the camera into place every single time the user switches screens, even if the galactic camera has no reason to have moved. Even a tiny motion is sufficient to give parallax.

Keeping the same "up" and "north" is also useful. It's tempting to let the player control the pitch and yaw of the camera, since it's a 3D world and your instincts are based around flight sims and FPS games. But in actuality the only control the player needs is zoom: always keeping the same up, down, north, south, east, and west means that the players will be able to memorize the location of stars using the same faculties they use to memorize the location of the door in their room, an icon in their desktop, the shift stick in their car. Humans are bad at rotational pattern recognition, and there's no gameplay reason to allow rotation.

All of these will help, but they have the fundamental problem that they're still representing freefloating dots and rails rather than surfaces. It might be worthwhile to create surfaces instead. We can, for example, build a number of surfaces into the star region, and stars have to be on a surface. Due to the vertical requirements, the best solution is probably thick tubes or large freefloating objects instead of a terrain-like surface.

You will have problem with opacity, though: how will you see stars on the opposite side of an object, or occluded by an object? On the plus side, your travel routes could be inherently linked to the topology, making it feel like more than just a visual aide.

This brings up the problem of opacity in general. Stars are not the only things in space. Things like nebulae are often important tactical considerations, but rendering them is difficult to do without mucking up the display: large opaque blobs will hide everything inside them or on the other side. Also, since they are arbitrarily sized and shaped, it can be very hard to determine where in space they actually are.

National borders have the same problem: they are a 3D perimeter of arbitrary size and shape. How do you draw them so they don't confuse the viewer or obscure other important things? Transparency might seem like the answer, but in fact it just makes things even muddier.

I don't know if there's a perfect solution, but I'm playing with two solutions.

One uses the "stars on surface" approach as mentioned above, except that the "surface" is automatically generated to include all stars not part of your nation/reach. This essentially puts your nation inside a bubble. This has a lot of downsides, though. It requires that you have "flight sim" controls due to opacity issues, which in turn means that if your nation is larger than about a dozen stars, you start losing track and thinking of them as "those stars" rather than individual stars.

The other idea is the "panned opacity". I think of this like radar: the opaque walls of nebula and borders are drawn, but only in a transitory thin slice as the "scanner" travels. This seems to work okay, but it feels kind of "foggy".

None of this is necessary if you have a surfaced-based space, though: you can just color the always-visible surfaces the color of their owners.

Another "solution" is to simply radically downplay the importance of the 3D star map to the player. The AI can take advantage of that 3D space to build an interesting world, but the player's game takes place in a small enough region that he can't get lost. Also, if the player is an avatar instead of a nation, the player will have an easier time of it because they won't have to remember where every star is and what they are doing, just two or three.

What are your opinions on 3D star maps?

9 comments:

John Brewer said...

I've actually thought about star maps a fair bit in the past years or so, and each time I come closer and closer to the conclusion that if you're modeling true 3-space space lanes, a map in the traditional sense of representing a projection of a "realspace" environment onto a display at scale isn't a terribly useful tool. Generally speaking, you don't care about the space between stars. All you care about is distance, and any zone properties (such as being in a nebula.) Generally when you're navigating a stellar-level environment, you're looking for specific properties of a star, or a group of stars. What's uncolonized that has significant mineral deposits in my area? Where are major opposing shipyards? What is the shortest route between Alpha Centauri and Gamma Ionis? That sort of thing.

None of these are really things that require visualization -- one just needs a list of stars. When relative positioning is important, there are usually only a handful of stars that need to be examined, and easily fit in a small, rotating display of less than a dozen points of light with information connected to them. Massive, galaxy-sprawling maps are only useful in a handful of situations, and in most of those situations, I think a more abstract view of the situation would be more obvious and communicate the proper information better.

To summarize, I think that determining how to display starmaps is the less interesting question here, but rather, what tools are more useful in displaying the information a player is seeking when examining a starmap.

Craig Perko said...

Oh! I disagree!

You and me, we're used to thinking of space like that. We've done a bunch of games like that. But I think it is a way of thinking that's come about because of our inability to visualize star maps, NOT because it is actually the best way to play.

There's a complexity to space: a location in space is related to other locations in space. "Flattened" to a single "range" stat, you can see how your position relates to their position, but not how their positions relate to each other.

As an example, if we thought of France, Belgium, and Poland as "the same distance from Germany", we would be missing out on the fact that France and Belgium are right next to each other, while Poland is in the opposite direction. This is patently obvious if viewed in two dimensions, but viewed in one dimension, that data is missing. And it's important data! Trying to add it back in using more numbers is inefficient and taxing.

I think if we can find a good way to display a 3D map, we will find that our game world will be greatly enhanced. This will enable us to do far more complex things. For example, instead of simply being a lot of independent points of light, we could build structures that are visible on our star map - roads and walls and all sorts of other things which would radically change what "distance" means. They don't even have to be physical structures: perhaps FTL travel creates a concussive wave so that another FTL route cannot pass nearby. Perhaps there is a psychic field that must be extended before a world can be settled and allows for FTL communication.

There are many, many options for very unique 3D space games. However, we haven't seen them yet because we literally can't see them yet.

Aaron said...

Not a full solution, but what about modifing the stars/routes visuals with a distance gradient? White/Near to Black/Far; Or red to blue. Maybe even by shape- square to circle.

I think that can help with depth perception when you don't have paralax constantly in effect.

Craig Perko said...

Yeah, I was thinking about that, too. I think it might be better to assign absolute colors instead of relative colors. Everything in the 510-515 lightyear Z area is blue, for example, regardless of where you're looking at it from. This way you'll instantly know what "layer" you're looking at. You'll be able to remember that the factory star you built is back on red layer...

However, using colors in that way makes it somewhat harder to use colors for borders. Hm.

Aaron said...

You could always break up the colors into hue, saturation, value components. Value for distance, probably stop short of black before you lose hue, and hue/saturation for layer or region.

Then the value gives you a feel for the space, and the hue gives you landmarks to navigate by.

Some additional possibilites:

- Slowly move the camera in a small circle perpendicular to the view plane so there is always some parallax but the view position does not change much. Keep the focal point constant however.

- Allow the map to be sliced with a field of view effect and allow the user to adjust the focal length.

Makiyivka said...

I'd be curious to see what you thought of the map that Sword of the Stars uses. There are a few issues with it, but overall I think it does a pretty good job of depicting a 3d star-map; especially once your empire gets up and running a bit.

Craig Perko said...

@aaron: circular camera motion makes many people sick, and back-and-forth linear motion isn't too much better. That's why I settled on the "ease in" camera, despite its lack of continuous parallax..

You definitely have to fade out the stars that are in the distance, and the higher the zoom of the camera, the faster they have to fade out.

@maki I haven't actually played Sword of the Stars much, because I can't get ahold of it very easily. All of these game devs that distribute almost entirely through Steam lose my sales. Civ 5 is another example of a game I wish hadn't required Steam.

However, looking at the screenshots, it looks like Sword of the Stars uses a shallow starfield. In local space, the stars are in a 3D space, above and below each other. However, at any real range, it becomes clear that the Z axis is very shallow and largely unimportant.

Here's a quick way to check: does the Z axis matter in early game, then stop mattering in end game? If so, it's a shallow starfield.

This technique seems solid at first: when your concerns are small, the star map is in real 3D. As the star map gets too large to easily picture (more than ~12 stars), the Z axis starts to fall away so you don't lose track of the map.

But you lose out on the 3D complexity! So I want to avoid that technique.

Makiyivka said...

"However, at any real range, it becomes clear that the Z axis is very shallow and largely unimportant."

Just to clarify a few things not readily apparent from ranndom screenshots: SotS gives you the option, when creating a new game, of using a bunch of different map types; some of which definitely use a shallow starfield (disk, 2d, spiral to some extend) while others I think you would qualify as a deep starfield (real space, sphere, nursery, etc). I went and looked at some screen shots via google images, and most of them appeared to be on maps of the shallow variety (with good reason; as has been pointed out, making sense of truly 3d maps with a single screen shot is hard!).

Anyway, here's an imgur album I threw together quickly showing the map selection part of SotS; maybe it'll give a better indication of the types of maps available. http://makiyivka.imgur.com/sword_of_the_stars_map_types

Finally, a quick description of how navigation works in the game. Your view is always centered on either a star or a fleet. You are free to rotate around that object at any distance you choose, but it will stay centered. When you double click on another object, the camera pans over to that object while maintaining the same camera orientation, giving you a nice parallax effect that grants a sense of scale and distance while eliminating many of the problems that exist with a free-flight style control system.

Anyway, hopefully that explains a little better how SotS does things; I think there's a demo available, anyone wanted to just experience the navigation for themselves.

Granted, the system the game uses does not solve the problem of quickly making sense of a region of space merely by glancing at it. There are no gradients or anything to indicate how far away systems are (fleets have a 'travel arrow' that helps with this). That being said, you do start to know your local neighborhood of stars as you constantly interact with the 3d environment, and I think that's a big part of dealing with a 3d environment; being able to get in and move about in it.

Craig Perko said...

Hm, I wonder how well it plays in a spherical star cluster when your empire has >12 stars.

Thanks for the more detailed information. It sounds like they're doing it in the way that most people do it: a way that I don't think is good enough. But it's hard to say for sure without playing it in more detail.

If you happen to play a globular game, take some end-of-game screenshots and link me to them: I'd really like to see how it scales.