Ambient and environment
- Game Development course
- Intermediate
- Lesson 9/83
- 4 min
Learn Window > Rendering > Environment Lighting settings.
Ambient light
Ambient light is indirect light that reaches everywhere in the scene at the same time. Even with no light source, objects do not look completely black; ambient light brightens them slightly. This setting is made in the Environment Lighting section of the Window > Rendering > Lighting window.
RenderSettings.ambientLight = Color.gray;RenderSettings.ambientLight holds the color of the ambient light.
Skybox and Environment Lighting
A skybox is the texture that shows the sky and the far surroundings of the scene. When the skybox is chosen as the ambient source in the Environment Lighting section, the colors of the sky reflect into the scene as indirect light. If the sky is orange, the scene takes on a warm tone as well.
// Environment Lighting > Ambient Source > SkyboxThis way, when the sky changes, the overall lighting of the scene changes too.
Practice Choose the ambient source
In a class named OrtamIsigi, define a string kaynak field with the value "Color". In the Awake method, set the kaynak value to "Skybox". In the Start method, print the text "Ambient kaynagi: " joined with kaynak using Debug.Log.
Starter code
using UnityEngine;
public class OrtamIsigi : MonoBehaviour
{
// string kaynak alanini "Color" degeriyle tanimla
void Awake()
{
// kaynak degerini "Skybox" yap
}
void Start()
{
// "Ambient kaynagi: " metnini kaynak ile birlestirip yazdir
}
}Sample solution
using UnityEngine;
public class OrtamIsigi : MonoBehaviour
{
string kaynak = "Color";
void Awake()
{
kaynak = "Skybox";
}
void Start()
{
Debug.Log("Ambient kaynagi: " + kaynak);
}
}Expected output
Ambient kaynagi: Skybox
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Why does a scene with no light source at all not look completely black?
- Because ambient light slightly brightens the scene Correct answer
- Because shadow resolution is low
- Because spot lights are cone shaped
- Because the skybox adds lights automatically
Explanation: Ambient light is indirect light spread over the whole scene; it keeps objects visible even without a light source.
2 Set the ambient light to gray
RenderSettings.ambientLight = Color.____;
RenderSettings.ambientLight = Color.gray;
Explanation: Color.gray gives the ambient light a neutral gray tone and keeps the indirect light balanced.
3 Ambient light terms
| Term | Meaning |
|---|---|
Ambient ışık |
The indirect lighting of the scene |
Environment Lighting |
Ambient light settings section |
Skybox |
The texture that shows the sky |
Ambient Color |
The color of the indirect light |