Objective: introduce the Reader to Unity’s four different Skybox shaders.
Let’s begin by asking the question: what is a Skybox? A Skybox is basically a big cube with different textures on each of its internal faces. These textures can be whatever you want: an image of the sky, outer space, a panoramic scene of a mountain range, a solid color,…Unity then places your Scene inside this cube (right in the middle), so as you look around your Scene, all you see are these rendered faces inside the cube. Since Unity always renders the Skybox first, the “sky” is always rendered at the back. This means that a Skybox is a Material that uses a Skybox Shader.
You can use a Skybox to render a sky around your Scene, to create realistic ambient lighting based on the Skybox configuration, or you can completely override the Skybox associated with an individual Camera by using the Skybox Component.
The High Definition Render Pipeline (HDRP) does not support skybox Materials and instead includes multiple sky generation solutions. HDRP is completely different because it uses Global Volumes. This means that the Volume has no boundaries and will affect all the Cameras in your Scene.
Creating a new Skybox Material
Now that we have the basics out of the way, let’s start the process of creating a new Skybox Material:
- From the menu bar, click Assets > Create > Material. Or Right-Click the folder you use for Materials, then Create > Material (example below).
- In the Shader drop-down, click Skybox then the skybox Shader you want to use. You will have four options presented to you: 6 Sided, Cubemap, Panoramic, and Procedural (see further below for references taken from the Unity documentation exploring each in more detail).
- You can now fill out the properties on the Material to set up the skybox. These properties may be different depending on which Shader you pick.
Now that your Material is created, you need to render it in your Scene. From the menu bar, click Window > Rendering > Lighting Settings. This will open the Lighting window (I normally dock it next to my Inspector window). Click the Environment tab, and assign your new Skybox Material
Assigning the active light in your Scene (Directional Light) as the Sun Source allows the Shader to use the rotation of that active light to position the sun in your Skybox.
Unity provides multiple Skybox Shaders for you to use. Each Shader uses a different set of properties and generation techniques. Each Shader falls into one of the following two categories: Textured or Procedural.
The first category is Textured: these generate a skybox from one or multiple textures. The source textures represent the view of the background from all directions. The Skybox Shaders in this category are: 6-Sided, Cubemap, and Panoramic Skyboxes.
6-Sided skybox: this skybox Shader generates a skybox from six separate Textures. Each texture represents a view of the sky along a particular world axis. To illustrate this, think of the Scene as being inside a cube. Each Texture represents one of the interior faces of the cube and all six combine to create a seamless environment. To generate the best ambient lighting, the Textures should use a high dynamic range (HDR).
To create a 6-Sided skybox, you need six individual Textures that, when combined, map to a net layout like:
Properties — 6-Sided Skybox
To create a Panoramic skybox, you need a single 2D Texture that uses latitude-longitude (cylindrical) mapping, like so:
To make sure the Texture is 2D:
- In the Project window, select the Texture you wish to apply.
- In the Inspector, make sure the Texture Shape is set to 2D.
Properties — Panoramic
The second category is Procedural: The Procedural Skybox Shader does not require any input Textures and instead generates a skybox purely from the properties set in the Material Inspector.
Properties — Procedural
There you have it. This was a quick overview of Skyboxes in Unity. These are basically textured boxes with the world you created in the middle, giving the Player a realistic illusion that the game area is much larger than what it actually is.
The Built-in Render Pipeline and the Universal Render Pipeline (URP) both use skyboxes to render a sky. These skyboxes are Materials that use a Skybox Shader. The High Definition Render Pipeline (HDRP) does not support skybox Materials and instead includes multiple sky generation solutions using Global Volumes.
I hope you found this article informative. As always, thanks for reading :)