The Complete Guide to Skyboxes for Unity
June 6, 2023
What is a Skybox?
A Skybox is a material, texture, or visual effect (or combination of materials, textures, and visual effects) that enable game developers to include clouds, stars, skies, moons, or even distant level geometry in a game level. This tool helps players to feel like they are in a much larger play-space than they actually are in. The most basic skyboxes are represented using a simple 2-dimensional texture known as a cubemap. This cubemap skybox texture is then sampled using a skybox shader that re-maps the 2-dimensional data across the spherical area surrounding the play space. Typically, the skybox is rendered quite early on in the render queue - ahead of geometry, opaque, and transparent passes - but it can be rendered after geometry or opaque passes to enable the skybox shader to avoid overdraw. Players can never "go into" a skybox, but there are techniques that enable developers to simulate 3-dimensionality and parallax effects even in 2-dimensional skybox environments. Apart from that, developers can also introduce volumetric rendering techniques in order to simulate clouds or other atmospheric elements.
At OccaSoftware, we have created two skybox shaders for Unity. Altos is a powerful sky system and dynamic skybox for Unity that includes volumetric clouds, a procedural skybox, a day night cycle, and night sky rendering. Super Simple Skybox gives you a straightforward material for a dynamic skybox with dozens of parameters and a sleek user interface.
What are the different types of Skyboxes for Unity?
Developers have invented several clever methods to represent skybox data in Unity, but at the end of the day, there are two main types of Skyboxes: static skyboxes and procedural skyboxes. Most Unity skyboxes fall into one category or the other, though some developers have integrated the two. For example, you might have procedural elements (like volumetric clouds) overlayed on a static skybox cubemap.
What is a Static Skybox?
A static skybox is typically a single 2d texture representing the complete sky and distant geometry state of a game level. Photographed static skybox textures are also often referred to as an HDRI, or a High Dynamic Range Image. Typically, the skybox texture is a panoramic image. To use these, you just use the Panoramic You can download free HDRIs from a ton of sites online, including PolyHaven, Textures.com, and HDRMaps.
Typically, a static skybox is authored outside of the game engine, then converted to the appropriate texture format expected by the skybox shader, and then rendered by the skybox shader. Skybox artists may combine several textures together in external tools (like Photoshop or Gimp) and may combine the 2d background texture with other visual effects or 2d textures. For example, the skybox artist might also take some photographs of clouds, edit them in Photoshop, and then bring those clouds in to the skybox environment as static 2d sprites.
Artists can also include transparent layers to simulate distant fog attenuation or other similar effects. Static skyboxes are most often used in cases where artistic direction is highly critical and there is a single fixed time of day or fixed set of times of day that can occur in a given scene.
What is a Procedural Skybox?
Procedural Skyboxes are somewhat more complex than static skyboxes, and as a result often have corresponding higher performance cost. A procedural skybox is often a combination of shader wizardry and 2d or 3d textures combined. Most often, the technical artist would use the main directional light (the sun) along with perhaps a second directional light (a moon) in order to describe the time of day, and then use that time of day as an input to a set of algorithms that result in a color fragment for each pixel on screen (i.e., each pixel on the skybox). For example, the technical artist could expose a set of parameters such as the horizon and zenith colors of the skybox at different times of day, and the designer could use these parameters in order to describe how the particular procedural skybox material should respond as the directional light moves through the sky and the time-of-day changes.
Although this does give more flexibility by enabling the designers to easily change through different times of day (or have a completely dynamic time of day system), there are other considerations to keep in mind as well. When the time of day and light position changes, you will need to re-bake any static lighting in your scene. Re-baking this static lighting is a performance intensive process, so you would likely need a dynamic baking system, or a dynamic GI system integrated to your project to fully take advantage of these benefits.
Using a Skybox in Unity
In this section, I will cover how to create a new skybox material in Unity. You can also check out our full guide on how to create a skybox.
How to create a new skybox material
By default, a new scene includes Unity's default skybox. This example will describe how to create a new skybox material using Unity URP 2021.3 LTS, so the instructions may be slightly different if you are using a different version of Unity or a different render pipeline.
At a high level, you will need to do three steps to create and apply a new skybox material. First, you will create a new material in the project. Second, you will change the shader of that material to one of Unity's included Skybox shaders. Third, you will apply the material to your scene.
Create a new material in the project
To create a new material, simply right click in your project hierarchy, then click "Material".
This will create a new material asset in your Project panel. Next, we will change the shader that is used by this material. A shader is a program that calculates the position of each vertex and color of each pixel for an object. The Unity skybox is rendered as a big sphere around the camera, and we will apply this material to that sphere.
Change the shader for the material
Now you will need to change the shader to one of Unity's included skybox shaders. To update the shader, click on the material that you created. Then, click on the Shader dropdown at the top of the inspector window for the material. Click on the "Skybox" section, then choose "Procedural".
Now that you have changed the shader for your material, we need to apply this material to the skybox object in your scene. Before we do that, you might want to adjust one of the properties for this new material so that you can easily see the change when you apply it to your skybox.
Apply the skybox material to your scene
To apply the new skybox to your scene, you need to open your Lighting panel. In the default UI view, this is available on the top right of your screen, next to the Inspector window. If you don't see it, you can open the window by going to your toolbar and clicking Window -> Rendering -> Lighting.
Now you should have your Lighting panel open. The Lighting panel consists of four sub-panels: Scene, Environment, Realtime Lights, and Baked Lightmaps. We want the Environment sub-panel, so click on that.
Now look for the Skybox Material slot in the Environment sub-panel. Click on the new material that you created, then drag and drop it to that Skybox Material slot to apply the material.
If nothing happens, try changing the material properties for your new skybox material.
Complete Sky Systems vs. Skyboxes
Some developers opt to use a complete sky system as opposed to a standalone skybox. While a skybox is often good for more static scenes, a complete sky system will give you more realism along with integrated day/night cycles, stars, moon support, and so on. At OccaSoftware, we have developed skybox solutions to fit either need.
Altos vs. Super Simple Skybox
We have published two different procedural skybox assets for Unity to the Unity Asset Store.
Altos is our complete sky system for Unity. This game asset includes a highly customizable procedural skybox as well in addition to standalone volumetric clouds. Altos also features a configurable day/night cycle, stars, a 3d moon, distance fog, and skybox clouds. We typically recommend Altos for game developers looking to create a game with a more complex, realistic sky that is internally integrated. Altos is only available for Unity URP and is currently targeting Unity Editor 2021.3. We've put together a tutorial for Altos demonstrating all the features included in this sky system for Unity.
Super Simple Skybox
Super Simple Skybox is our straightforward, easy to use and integrate standalone procedural skybox for Unity URP. This asset features a dynamic skybox that responds to changes in your main light position. It also includes a procedural moon and sun along with star textures. It also features beautiful skybox clouds rendered using innovative UV-remapping techniques that allow you to display clouds directly overhead - something that many procedural skyboxes do not have. However, Super Simple Skybox does not include volumetric clouds, 3d moons, distance fog, or a configurable day/night cycle. You can see Super Simple Skybox in action on our YouTube channel.
Learn more about Super Simple Skybox ->
Which skybox is best for me?
We typically recommend the Altos complete sky system for more ambitious projects featuring better graphics and targeting console or PC hardware. It's really hard to beat the beauty and realism offered by our volumetric clouds with any 2d skybox solution. On the other hand, Super Simple Skybox is perfect for smaller projects targeting mobile or lightweight hardware. This asset also provides a high level of customization on the procedural skybox itself, so it is great if you want to focus on that area.
Other assets to complete a skybox
We highly recommend using two other important assets to help complete your game's skybox environment. The first is a Volumetric Fog rendering solution. Volumetric Fog is essential to helping ground your environment in the scene. We think that Buto, our in-house volumetric lighting and fog solution, is the best pick here ;-).
We also strongly recommend an Auto Exposure asset. Auto Exposure is a post-process rendering feature that dynamically adjusts a scene's luminance in order to maximize the scene's visibility. This is also called eye adaptation, because it simulates the way that the human eye dynamically adjusts to changes in brightness in the environment. This type of eye adaptation asset enables you to ramp up the dynamic range of your scene and let your sky really be a major player in your game. Our personal favorite is also an in-house pick - Auto Exposure for URP.
Want to learn more about sky and volumetric rendering?
We've compiled an extensive list of resources on sky rendering and volumetric rendering to help game developers like you get a head start on the basics and dive deep into the details. With 50+ links to detailed resources on rendering techniques, noise generation algorithms, signed distance field calculations, ray marching concepts, and more, our resources document is the best place to start to learn more about volumetrics.
We also have a helpful guide on how to change your skybox. This guide covers what a skybox is, explores different skybox options, describes how to change a skybox in Unity, walks you through customizing your skybox, and highlights advanced skybox techniques.
Finally, we have a great guide on importing texture-based skyboxes from HDRI Haven and using them with your skybox in Unity. Click here to learn more about creating a skybox with an HDRI.
Unity 2022 LTS: Empowering Game Developers and Artists
Unlock your creative potential with Unity 2022 LTS. Discover the new features and improvements for artists and programmers, and create high-quality games.
Introducing Responsive Smoke: Interactive Volumetrics in Unity
Discover Responsive Smoke: A Unity asset that brings dynamic, interactive volumetric smoke effects to your projects. Read on to explore its features.
Text Mesh Pro in Unity: Font Import Guide
Learn how to import and use Text Mesh Pro fonts in Unity. Enhance your text elements with advanced features and improved visual quality.