A Unity runtime system to downgrade light (Point, Spot) quality (all the way to completely disabling them or downgrading shadow quality) as the camera gets further (and also based on frustuum) in order to improve performance.
The tool has been verified on the following versions of Unity:
- 2021.3 (LTS)
- Adjustment of light LOD based on player distance
- Disable lights that have areas of influence outside the camera's frustum
- Ability to set custom LOD values for each light in the scene
- Supports different types of lights (recommended only for Point and Spot)
- Easy-to-use user interface and setup
To use the Unity Lights Lod System in your Unity project, simply:
- Clone or download the repository
- Import the
UnityLightsLodSystem
folder into your Unity project'sAssets
folder
Option B) Add the repository to the package manifest (go in YourProject/Packages/ and open the "manifest.json" file and add "com..." line in the depenencies section). If you don't have Git installed, Unity will require you to install it.
{
"dependencies": {
...
"com.razluta.unitylightslodsystem": "https://github.com/razluta/UnityLightsLodSystem.git"
...
}
}
The repository is at: https://github.com/razluta/UnityLightsLodSystem.git
While the tool has no dependencies outside of the core Unity Editor and Engine, I recommend using the Unity Lights Audit Tool to first sort the lights in the scene in order to be critical about what lights you are targetting.
To implement the Unity Lights Lod System in your Unity project, simply:
Step 01 - Add the LightLodManager.prefab in your scene (or add the 'LightModManager.cs' script to an empty GameObject in your scene)
You can simply drag the LightLodManager.prefab in your scene. The manager acts as a singleton. The main parameter in the UI is the Update Rate, which dictates how often the the LightLodManager will update LODs in the scene. By default, it is set to 0.1f, which means it will run try to run about 10 times per second.
The LightLod component will be the one to tell the manager what properties we want to LOD on each light. The "Is Disable After Last Lod" property will disable the light after the last LOD's max distance is surpassed. If the light should be visible at high distances, feel free to keep this flag disabled. Note: make sure the min and max distances are not overlapping otherwise you might experience unexpected behavior. Include as many LODs as you need. The screenshot below shows an LOD setup example.
Please note that I hightly recommend you only use the LOD component on Point and Spot lights. Any type of LODing optimizations would be very noticeable and jarring on other light types.
If you would like to contribute to the Unity Lights LOD System, please:
- Fork the repository
- Create a new branch
- Make your changes
- Submit a pull request
The Unity Lights LOD System is licensed under the MIT License. See the LICENSE
file for details.