In this tutorial repository and associated video you will learn how to apply the "LOD" (Level of Detail) concept to lights! In many cases you do not need to always have the highest quality shadows shown. Using this technique you can dramatically reduce the GPU usage and improve performance by stepping down the quality as the camera is farther away from the light source.
To use it, simply attach LightLOD
to an existing Light, or replace your Light(s) with one of the preconfigured Prefabs based on how aggressively you would like to scale the lights.
Then, on your Player's Camera, attach LightLODCamera
.
LightLODCamera
can be attached to as many cameras as you have in the scene. LightLOD will pick the first ACTIVE CAMERA in the list and adjust their LOD based on the distance from this camera. Call LightLODCamera#Activate
when the active camera should change, and the LODs will adjust automatically.
As mentioned in Issue #1 (builder-main) - this is not the most optimal performance or configurable solution.
To take this further, a better way may be to invert the control where the lights register with each Camera, instead of each light adjusting itself. Doing this allows you to extend this much further with potentially custom configurations per camera. It also allows you to consider which lights are highest priority, limit total number of lights, and much more! Since this cannot be covered in the tutorial video, this is an exercise left to you.
Have you been getting value out of these tutorials? Do you believe in LlamAcademy's mission of helping everyone make their game dev dream become a reality? Consider becoming a Patreon supporter and get your name added to this list, as well as other cool perks. Head over to the LlamAcademy Patreon Page or join as a YouTube Member to show your support.
- Andrew Bowen
- YOUR NAME HERE!
- Bruno Bozic
- YOUR NAME HERE!
- Gerald Anderson
- AudemKay
- Matt Parkin
- Ivan
- Paul Berry
- Reulan
- Iffy Obelus
- YOUR NAME HERE!
- Bastian
- Trey Briggs
- Matt Sponholz
- Dr Bash
- Tarik
- Sean
- ag10g
- Elijah Singer
- Lurking Ninja
- Josh Meyer
- Edwald Schulte
- Dom C
- Andrew Allbright
- YOUR NAME HERE!
Interested in other AI Topics in Unity, or other tutorials on Unity in general?
- This has been supported at least since Unity 5 so any modern version should work. I used a Unity 2021 LTS.