CodeBlanks Logo Icon CodeBlanks

Vignette and Depth of Field

Learn the Vignette and Depth of Field effects.

What is Vignette?

Vignette is the effect that darkens the edges of the frame and draws attention to the center. A slight vignette gives the scene depth and a cinematic mood. When overused, the image can look gloomy.

efekt.vignette.intensity.value = 0.5f;
efekt.vignette.smoothness.value = 0.4f;

It is usually used with light values.

Depth of Field

Depth of Field applies blur according to the distance from the camera; areas outside the sharp region get soft. This effect imitates the depth of field of cameras. The focus distance decides the point where the image is sharp.

efekt.depthOfField.focusDistance.value = 10f;
efekt.depthOfField.aperture.value = 5.6f;

This way the player's eye is guided to the important objects.

Practice Camera effects

In a class named KameraEtkisi, define a string kenar field with the value "Vignette" and an int bulaniklik field with the value 2. In the Start method, print the text "Kenar efekti: " joined with kenar using Debug.Log. In the Update method, increase the bulaniklik counter by one every frame.

Starter code

Player.cs
using UnityEngine;

public class KameraEtkisi : MonoBehaviour
{
    // string kenar alanini "Vignette" degeriyle tanimla
    // int bulaniklik alanini 2 degeriyle tanimla

    void Start()
    {
        // "Kenar efekti: " metnini kenar ile birlestirip yazdir
    }

    void Update()
    {
        // bulaniklik sayacini bir artir
    }
}

Sample solution

Player.cs
using UnityEngine;

public class KameraEtkisi : MonoBehaviour
{
    string kenar = "Vignette";
    int bulaniklik = 2;

    void Start()
    {
        Debug.Log("Kenar efekti: " + kenar);
    }

    void Update()
    {
        bulaniklik++;
    }
}

Expected output

Kenar efekti: Vignette

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 Which effect darkens the edges and draws attention to the center?

  • Tonemapping
  • Bloom
  • Vignette Correct answer
  • Lightmap

Explanation: Vignette darkens the edges; Bloom spreads brightness and Tonemapping adjusts the brightness range.

2 Set the focus distance

Question
    efekt.depthOfField.____ = 10f;
Answer
    efekt.depthOfField.focusDistance = 10f;

Explanation: In the Depth of Field settings the sharp point is decided by focusDistance.

3 Vignette and DoF terms

Term Meaning
Vignette The effect that darkens the edges
Depth of Field Blur based on depth
Blur The softening of the image
Odak mesafesi The point where the image is sharp

All lessons in Advanced