Volumetric Lights relies on the scene depth buffer to compute where objects are. Since transparent objects do not write to depth buffer, they might get overdrawn by the volumetric light effect.
There’re two ways to solve this issue:
- Render queues:
You can change the render queue of the volumetric light, so it has a lower value than your transparent objects. Note that transparent queue starts at 3000. With this solution, volumetric light effect will render always before your transparent objects, regardless the position in the scene.
If this option works for you, perfect! This solution is fast and easy to implement.
- Alternatively, you can add the “Volumetric Light Depth Pre-Pass Render Feature” to the URP renderer:
Once you add the feature, you will see 3 parameters:
- Transparent Layer Mask. Specify which layer contains the transparent objects that you want to be considered when rendering the volumetric light effect.
- Alpha Cutout Layer Mask: if you have semi-transparent objects in the scene, you can use this mask to also include them but only the solid parts. Note that this option can be expensive.