Besides the traditional 6 Sided and Cubemap, Unity now features a third type of skybox: the Procedural Skybox. Easy to create and setup, the Procedural Skybox can be used in conjunction with a Directional Light to provide Environment Lighting to your scene. In this recipe, we will learn about different parameters of the Procedural Skybox.
For this recipe, you will need to import Unity's Standard Assets Effects package, which you should have installed when installing Unity.
To set up an Environment Lighting using the Procedural Skybox and Directional Light, follow these steps:
0
; Y: 0
; Z: 0
scaled to X: 20
; Y: 1
; Z: 20
, which is to be used as the ground, as shown:MySkybox
. From the Inspector view, use the appropriate drop-down menu to change the Shader of MySkybox from Standard to Skybox/Procedural.0.05
and Atmosphere Thickness as 1.4
. Experiment by changing the Sky Tint color to RGB: 148
; 128
; 128
, and the Ground color to a value that resembles the scene cube floor's color (such as RGB: 202
; 202
; 202
). If you feel the scene is too bright, try bringing the Exposure level down to 0.85
, shown as follows:5
; Y: 170
; Z: 0
. Note that the scene should resemble a dawning environment, something like the following scene:RotateLight
. Open your script and replace everything with the following code:using UnityEngine; using System.Collections; public class RotateLight : MonoBehaviour { public float speed = -1.0f; void Update () { transform.Rotate(Vector3.right * speed * Time.deltaTime); } }
Sun
flare.3
and Flare Strength as 0.5
, shown as follows:Ultimately, the appearance of Unity's native Procedural Skyboxes depends on the five parameters that make them up:
1.0
) are good for simulating the outer space settings. Moderate values (around 1.0
) are suitable for the earth-based environments. Values that are slightly above 1.0
can be useful when simulating air pollution and other dramatic settings. Exaggerated values (like more than 2.0
) can help to illustrate extreme conditions or even alien settings.It is important to notice that the Skybox appearance will respond to the scene's Directional Light, playing the role of the Sun. In this case, rotating the light around its X axis can create dawn and sunset scenarios, whereas rotating it around its Y axis will change the position of the sun, changing the cardinal points of the scene.
Also, regarding the Environment Lighting, note that although we have used the Skybox as the Ambient Source, we could have chosen a Gradient or a single Color instead—in which case, the scene's illumination wouldn't be attached to the Skybox appearance.
Finally, also regarding the Environment Lighting, please note that we have set the Ambient GI to Realtime. The reason for this was to allow the real-time changes in the GI, promoted by the rotating Directional Light. In case we didn't need these changes at runtime, we could have chosen the Baked alternative.
18.227.46.69