Weekly Update #57: Space Atmosphere

Earlier this week, Beta 0.16.1 was promoted to the default branch on Steam. This is the first default build to include an ending to the main story. While players provide feedback and I gather analytics data, I started working on a cosmetic change. Rather than the usual weekly task list, I thought I’d do a quick technical write-up for those who are interested in how a minor game feature gets implemented:

A Bit of Background…

In the current version, most of the game universe outside of nebulae has a constant background consisting of: a particle field of stars to help give a sense of movement, a background plane of stars to fill things out, and a textured backdrop of a dark dusty blue space. The starfield and the backdrop shift gradually at different rates as the player moves, giving an additional sense of depth and movement.

The new system combines the cosmic backdrop, starfield and nebula backgrounds into a single shader.

How it Works (new model):

If you’re not familiar with shaders or RGB color math, a color is typically stored as 4 floating point values: Red, Green, Blue and Alpha (transparency) ranging from 0-1. Adding colors or textures together makes them brighter. Multiplying them makes them darker because the values are (or should be) less than 1.

In the game, an EnvironmentManager looks at active color influencers that contribute to the three tints: background, overlay and highlighting. It sums their local color values as determined by inverse distance from the viewer. The background and overlay come from an invisible object in each sector (or nebula if present). The highlighting comes from the local stars, if any. These color values are sent to the shader, which multiplies them with their respective texture sample (3 different seamless cloud textures). The highlight texture is multiplied by the overlay texture to create the illusion of starlight illuminating parts of the clouds. The highlight texture is also given a bit of “solar wind” drift. This gives the appearance that the clouds are gradually evolving even if the player is stationary.

The background layer is “clamped” to a minimum color so that even in the depth of the void there’s still some dust clouds.

The three layers are added together along with the starfield texture.

As the player moves, the three textures uv coordinates get shifted at different rates in the opposite direction of the player’s movement to create a parallax effect, while the texture itself follows the camera.

Here’s a quick test video, the video recording software seems to have lowered the brightness/gamma, sorry about the quality:

Here’s what the shader looks like in Amplify (the node-based shader editor that I use):

A subtle dusty midnight blue background.
A more dramatically chromatic region near a star, with the same shader.

As usual, these updates represent works in progress of features that I intend to incorporate into an upcoming build, but may change, be delayed or removed..

Until next week! You can always reach me on Twitter, Discord or the game’s Steam Forums.