Skip to content

Optimization guidelines

Drawcall Batching

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 uses GPU Instancing 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.

Drawcall batching with GPU Instancing enabled

This documentation will explain you how to take advantage of this optimization, its limitations and the possible workarounds.

Platforms consideration

GPU Instancing 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.

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
PC/Mac/Linux Built-in ++ +++ x
PC/Mac/Linux URP ++ +++ +++
PC/Mac/Linux HDRP ++ x +++
Mobile Built-in ++ + x
Mobile URP ++ + +++

Debugging

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.

Debug Batching


GPU Instancing

In order to support drawcall batching, you have to switch the Rendering Mode to GPU Instancing in the configuration file.

Rendering Mode GPU Instancing

Limitation

GPU Instancing Rendering Mode will batch multiple beams together only under specific conditions, only if they all use:

Real-time Lighting

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.

Realtime Light Inspector

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.

Realtime Light Frame Debugger

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.
    Cull off beams from realtime lights

  • In the configuration file, select this Layer as the Override Layer property.
    Cull off beams from realtime lights

  • Cull off this Layer on each one of your real-time light.
    Cull off beams from realtime lights

Using this simple workaround, you can enjoy GPU Instancing optimization while still having real-time lights.


SRP Batcher

In order to support SRP Batcher, you have to switch the Rendering Mode to SRP Batcher in the configuration file.

Note

The SRP Batcher Rendering Mode is only compatible with the Scripted Render Pipelines (SRP) such as HDRP and URP.


VR

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.

Enabling Single Pass Stereo Rendering Enabling Single Pass Stereo Rendering

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.