Batching is a optimization technique to combine several drawcalls together to reduce the amount of work sent to the GPU. The Volumetric Light Beam plugin offers 2 different techniques (GPU Instancing and SRP Batcher) in order to batch the geometry used by different volumetric light beams.
This allows to render unlimited beams using 1 single drawcall under great performance.
This documentation will explain you how to take advantage of this optimization, its limitations and the possible workarounds.
GPU Instancing is available on almost all platforms (except HDRP), but is not a magic solution to increase performance: it will highly depend on the platform.
Using GPU Instancing is particularly recommended when running on high-end platforms such as PC and Mac: it's perfect to save performance with high-end VR for example.
Otherwise on mobile, the performance can actually get worse, so it's recommended to keep using Multi-Pass or Single-Pass rendering mode on Android and iOS.
SRP Batcher is only available with SRP (URP or HDRP).
Here is a matrix showing the results of internal benchmarks made on various devices, that could help you choose which mode to choose depending on your needs.
|Platform||Render Pipeline||Single Pass||GPU Instancing||SRP Batcher|
When you select multiple VolumetricLightBeam instances in the editor, the info panel located in the inspector will tell you if they could be batched together, or why they cannot. Use this feature to debug batching issues. Note that this debugging info doesn't take account of the real-time lights limitation.
In order to support drawcall batching, you have to switch the Rendering Mode to GPU Instancing in the configuration file.
GPU Instancing Rendering Mode will batch multiple beams together only under specific conditions, only if they all use:
- The Shared Mesh Type.
- The same Color mode (all using Flat color, or all using Gradient color).
- The same Blending Mode: 2 beams using different blending modes cannot be batched.
- The same 3D Noise state (all enabled, or all disabled).
- The same Dynamic Occluding states: a dynamically occluded and a non occluded beam cannot be batched together.
- The same Dynamic Occluding (Depth Buffer) state: a beam with the Dynamic Occluding (Depth Buffer) component cannot be batched.
Be careful if you are using real-time lights in your scene: 2 beams overlapped by different real-time lights can't be batched together. This is the case if you use real-time Unity's spotlights and Volumetric Light Beams attached together.
It will generate an additive forward drawcall per beam, breaking the batching, even if using Deferred Rendering Path. Unfortunately, this is a limitation Unity carries for years, so nothing can be done on our side.
Fortunately, there is a pretty easy workaround: using the Culling Mask property, you can simply cull off from your dynamic lights the layer on which your Volumetric Light Beams are created.
Create a specific Layer for your light beams.
In the configuration file, select this Layer as the Override Layer property.
Cull off this Layer on each one of your real-time light.
Using this simple workaround, you can enjoy GPU Instancing optimization while still having real-time lights.
In order to support SRP Batcher, you have to switch the Rendering Mode to SRP Batcher in the configuration file.
Obviously the SRP Batcher option should also be enabled in your URP/HDRP asset.
The SRP Batcher Rendering Mode is only compatible with the Scripted Render Pipelines (SRP) such as HDRP and URP.
Single Pass Stereo Rendering
The plugin is compatible with Single Pass and Single Pass Instanced Stereo Rendering Methods. This is an optimization technique which heavily decreases CPU use in VR by rendering both left and right eye images at the same time.
There is unfortunately a limitation due to a bug in Unity when running on mobile VR (Gear VR, Oculus Go, Oculus Quest...): read more about this limitation and the possible workarounds in the Troubleshooting page.