Through the looking glass

Designing a composite scene with 3D Skyboxes


When creating a game based in outer space, one issue quickly becomes apparent – vast distances. In order for the scene to feel rich and full, we require landmarks that can be seen from huge distances, often from different orbits, like asteroid belts, planets, moons even suns and nebula. And that means that said landmarks must be huge in order to be visible.

This poses a problem when designing a scene. The player’s camera cannot render (or “see”) as far as is needed for those objects to become visible, because if it does, it will need to render all objects in-between; spaceships, debris, dust clouds, etc. These objects can pile up fast, causing low performance or even worse, game crashes.

There are various solutions to this issue; rendering everything to a 2D skybox, like a backdrop image, or selectively switching objects on / off are some popular approaches to solve the issue.

We have opted to use the 3D skybox approach, as it’s the most elegant solution, albeit most difficult to set up.

The 3D skybox exists between the standard 2D skybox backdrop and the normal scene where the game takes place. It contains a scaled down and low-polygon version of all distant landmarks (on a 1:100 scale in our case) and it’s typically rendered by a separate camera. The separate camera receives instructions from the main camera on how to rotate and move, in order for all images to sync.

Every frame, each camera outputs to the frame buffer what it sees, stacked in layers, much like we’d super-impose image layers in photoshop to generate a composite image.



Super-imposed layers forming final frame (Main Camera – movable objects and particle effects, Skybox Camera – Huge static structures rendered in 1:100 scale, 2D backdrop)


The result is the illusion of a unified image, while in fact, it’s a composition of many separate images.

This technique, not only offers good performance relative to the other methods available, but also allows for clever ways to expand level design. By manipulating the 3D skybox camera’s movement, we can cause the 3D skybox to “approach” the player as he moves towards it, and then, through the use of LOD (level of detail) techniques, cause a seamless transition from the 3D skybox to an actual non-scaled scene which would load on demand.

This is precisely the way we’re able to perform planet drops from high orbit in Stellar Codex!