In part one of this series I talked about the graphical updates we’re making to Star Trek Online as we bring the game to PS4 and Xbox One. Deferred shading gives us the ability to place many more lights than we previously could. Light probes add a subtle yet powerful level of realism to the environments by adding bounced light and more accurate reflections. Now, I’d like to tell you a little about how we’re making those improvements, and show you some of the results.
Let’s start with lighting and how we’re going about the daunting task of relighting a game with over 1000 environments! The simplest approach is always the best place to start. We started by seeing how the existing lighting would work in deferred shading. Deferred shading is basically a code switch that can be turned on or off for the project. Since we can easily have the existing STO lighting work with deferred shading, that’s where we decided to start.
We turned deferred shading on so that we could see how it looked. The results were really good in some areas and really bad in others. There are basically three different types of environments in STO: space, exterior ground and interior ground. Because space and exterior ground maps use similar lighting scenarios - typically a single key light source like a star - they worked pretty well right out of the gate. We weren’t so lucky with interior ground maps though.
The old lighting system uses a combination of key lights that can cast shadows and affect material properties and vertex lights that color the geometry in the scene. Key lights had to be used sparingly because they’re expensive. That means lots of vertex lights get used. Key lights are also very accurate; if you see a circular spot light in the game, it’s a key light. Vertex lights, on the other hand, need geometry to work. Artists use them to paint vertex color and value around the environment by pointing them at the vertices. So, when we turned all of the vertex lights into key lights in deferred shading, lots of spotlight circles started appearing all over the world! Not the effect we were hoping for.
We needed a different way to light interior maps. Luckily, we took a modular approach to building STO’s interior spaces. Most of these maps are comprised of tiling pieces like hallways, wall sections, and floor sections that all fit together to create the rooms and connecting halls. We call them environment kits. Kits also contain all of the props for that environment style; furniture, computer consoles, warp cores, etc. We decided that lighting the kits and letting them propagate the lighting to the environments was the best approach.
But, there are a lot of kits! Romulan kits, Klingon kits, Federation kits, there’s a kit for just about every species in the game. Some kits contain hundreds of objects. Lighting them is time-consuming work; it can take days to light one kit and as soon as you’re done with it, it’s on to the next one. There was liberal use of headphones during the kit lighting phase!
Now that we knew how to get lighting into the environments we needed to figure out how to get light probes into the game. Light probes are a combination of two things: diffuse probes that simulate bounced light and specular probes that capture reflections. In a game level there can be thousands of diffuse probes; specular probes, on the other hand, generate textures so they are used sparingly. We had neither the time nor the inclination to hand-place probes into every single game level. That would likely take a sizeable team of people working for months, and those people might feel like zombies at the end of the process.
We needed an automated approach, so we developed the autoprobe tool. The three different types of environments come into play here again, and each would need its own solution. The most basic approach to probing a room is fill it up with diffuse probes and put a specular probe in the middle, because of this, setting up the space maps turned out to be pretty easy. All of our space maps are kind of like big boxes, really, really big boxes in some cases. Filling boxes with probes is fairly straightforward! Some of our initial autoprobe tests for space maps placed thousands of spec probes, but our budget is around a modest 32 - whoops. Adjustments were made!
From there, it was on to interior environments. Kit pieces are sometimes box-like, but they can also be pretty irregularly shaped. Those proved to be a little more challenging. Luckily, the engine requires the dev team to place volumes around all of the play spaces, designating them as rooms. We decided the room volumes were worth a shot, and after several tests and iterations we had interior maps figured out.
Last were the exterior environments. They were the trickiest because they usually contain terrain. The challenge with terrain is that terrain is lumpy. Regular grids of probes are not. If a probe ends up below the terrain it’s going to get bad data and throw off the lighting, The same thing happens in interior maps; for instance if a probe ends up outside the world it might sample the sky color and turn the interior blue. We’d rather spend our time lighting and polishing than fixing bugs.
We decided to start by putting the grid of probes in the air and casting a ray down to find a spot to place them, basically letting them fall until they hit something and putting them in that spot. Then we placed other layers floating above to give us a tetrahedral mesh that affects all of the objects in the game world. After that, the tool looks for rooms and fills them with probes. The autoprobe tool gives artists control over things like inset bounds, horizontal and vertical spacing, and snap distance for all the different types of environments.
With a kit lit and an environment autoprobed, the next steps were to go into the individual maps, look for issues, and do some polish work (including hand tweaking of the lighting and probe placement). It took us months to develop the process, write the tools and light the kits. Now we’re in the polish stages, and we’re pretty happy with the results. Like I said before, the impact of our graphics improvements can range from fairly subtle to very drastic. In the end, we’re achieving our goal of creating a more beautiful and believable experience for everybody who plays Star Trek Online, regardless of the system they play it on.
This is just the beginning. We’ve spent the past several months retrofitting new lighting into the game, but from here on the environment artists will have these tools to work with for every new environment they create. It will affect the entire way they approach creating environments, and I think you’ll see some even more amazing work coming from the STO team in the near future.
Star Trek Online