Volumetric Lights uses a few shader keywords to optimize the execution of the effects. They’re needed to enable the desired functionality. However, each keyword multiplies the number of shader variants so you may want to disable or remove some of them manually if you want to optimize your build. As a result, building the shaders for the first time can take a few minutes. Once it’s built, Unity caches the compilation so next builds are much faster.
To reduce the number of shader variants and speed up the build, you can remove some keywords related to VolumetricLights options that you’re not using in your project.
Locate and edit the file VolumetricLightURP.shader inside VolumetricLights/Resources/Shaders folder. The following lines declare the keywords. Feel free to comment out or remove any of these lines or keywords to reduce the number of shader variants:
#pragma multi_compile _ VF2_DEPTH_PREPASS // used only if depth prepass is enabled #pragma multi_compile_local _ VL_NOISE // used if Noise option is enabled #pragma multi_compile_local _ VL_BLUENOISE // used if Blue Noise option is enabled #pragma multi_compile_local _ VL_DIFFUSION // used by the Diffusion Intensity option #pragma multi_compile_local _ VL_PHYSICAL_ATTEN // used by Quadratic attenuation #pragma shader_feature_local VL_CUSTOM_BOUNDS // used by Custom Bounds option
The following keywords are required per light type. If you don’t use a specific light type, you can remove that keyword:
#pragma multi_compile_local VL_SPOT VL_SPOT_COOKIE VL_POINT VL_AREA_RECT VL_AREA_DISC
If you don’t use shadows in the volumetric lights, you can remove this line. Or if you don’t use the cubemap based shadows (only for point lights), you can remove the VL_SHADOWS_CUBEMAP keyword:
#pragma multi_compile_local _ VL_SHADOWS VL_SHADOWS_CUBEMAP
Important: if you upgrade Volumetric Lights to a newer version, any changes done to the VolumetricLightURP.shader will be lost! Remember to remove any unwanted keywords again after upgrading.