Summary - Lighting
- Game Development course
- Intermediate
- Lesson 12/83
- 4 min
Reinforce lighting concepts with a summary task.
Lighting summary
Lighting starts with four light types: Directional, Point, Spot and Area. Shadows can be Hard or Soft; ambient light provides the indirect lighting of the scene. Objects that do not move are marked Static and their light is precomputed with Bake.
isik.type = LightType.Point;
isik.shadows = LightShadows.Soft;Realtime light suits moving objects, baked light suits unchanging ones.
Practice Lifecycle and light summary
In a class named IsikOzet, define a string tur field with the value "Directional" and an int sayac field. In the Awake method, set the tur value to "Point". In the Start method, print the text "Isik turu: " joined with tur using Debug.Log. In the Update method, increase the sayac variable by one every frame.
Starter code
using UnityEngine;
public class IsikOzet : MonoBehaviour
{
// string tur alanini "Directional" degeriyle tanimla
// int sayac alanini tanimla
void Awake()
{
// tur degerini "Point" yap
}
void Start()
{
// "Isik turu: " metnini tur ile birlestirip yazdir
}
void Update()
{
// sayaci her karede bir artir
}
}Sample solution
using UnityEngine;
public class IsikOzet : MonoBehaviour
{
string tur = "Directional";
int sayac;
void Awake()
{
tur = "Point";
}
void Start()
{
Debug.Log("Isik turu: " + tur);
}
void Update()
{
sayac++;
}
}Expected output
Isik turu: Point
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which statement is true for baked light?
- It changes with the camera direction
- It is recomputed every frame
- It is computed before the game starts and written to the lightmap Correct answer
- It only softens shadows
Explanation: Baked light is computed once before the game starts and its result is stored in the lightmap file.
2 The property that sets the light type
isik.____ = LightType.Point;
isik.type = LightType.Point;
Explanation: In the Light component the light type is set with the type property.
3 Code pieces and their meanings
| Term | Meaning |
|---|---|
LightType |
The list of light types |
LightShadows |
The list of shadow types |
RenderSettings.ambientLight |
The color of the ambient light |
gameObject.isStatic |
Whether the object is static or not |