Shadow settings
- Game Development course
- Intermediate
- Lesson 8/83
- 4 min
Learn Soft Shadows, Hard Shadows and shadow resolution.
Shadows
A light casts shadows behind objects. The shadows property of the Light component decides the shadow type: None draws no shadow, Hard Shadows draw sharp-edged shadows, and Soft Shadows draw soft-edged shadows. Soft shadows look more realistic but cost a bit more processing power.
isik.shadows = LightShadows.Hard;
isik.shadows = LightShadows.Soft;In simple scenes hard shadows can be enough as well.
Shadow resolution
Shadow resolution decides how much detail a shadow is drawn with. As resolution rises, shadow edges get cleaner, but memory and processing cost increase. So choosing a low or medium resolution depending on the number of lights in the scene keeps performance safe.
isik.shadows = LightShadows.Soft;
// higher resolution cleans the edgesResolution keeps a balance between shadow quality and performance.
Practice Update the shadow type
In a class named GolgeAyar, first define a string golge field with the value "Hard". In the Start method, set the golge value to "Soft" and print the text "Golge turu: " joined with golge using Debug.Log.
Starter code
using UnityEngine;
public class GolgeAyar : MonoBehaviour
{
// string golge alanini "Hard" degeriyle tanimla
void Start()
{
// golge degerini "Soft" yap
// "Golge turu: " metnini golge ile birlestirip yazdir
}
}Sample solution
using UnityEngine;
public class GolgeAyar : MonoBehaviour
{
string golge = "Hard";
void Start()
{
golge = "Soft";
Debug.Log("Golge turu: " + golge);
}
}Expected output
Golge turu: Soft
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Which shadow type has sharp, well-defined edges?
- Blur Shadows
- Soft Shadows
- Hard Shadows Correct answer
- None
Explanation: Hard Shadows draw sharp-edged shadows; Soft Shadows soften the edges.
2 Soft shadow setting
isik.shadows = LightShadows.____;
isik.shadows = LightShadows.Soft;
Explanation: LightShadows.Soft gives soft-edged shadows; since the setting asked for is a soft shadow, the correct answer is Soft.
3 Shadow settings
| Term | Meaning |
|---|---|
None |
No shadow is drawn |
Hard Shadows |
A sharp-edged shadow |
Soft Shadows |
A soft-edged shadow |
Çözünürlük |
The detail level of the shadow |