Avoiding Per-pixel Cost with Enlighten-only Point Lights
This blog describes the performance findings and considerations during the creation of the 3rd VRX demo prototype.
When we add dynamic lights to the scene we incur a per-pixel cost on the GPU in order to evaluate the shaders on the meshes affected by the light. In UE4, we can use the ‘light complexity’ view to see this cost visualised. We see the attenuation radius of the light and the parts of the scene affected by the light coloured in blue.
For multiple lights we need to evaluate the shader multiple times per-pixel where the attenuation volumes overlap. In this example we see eight point lights with the colours indicating the cost of the rendering. Red is more expensive and blue is cheaper.
Our VR prototype required the player to be able to spawn multiple light-balls and throw them into the environment. As the light-balls were the only light sources in the scene, it was necessary to come up with a performant solution for achieving this effect.
Below is a scene where we spawned ~150 light-balls – where each with one movable point light and no shadow maps.
We notice that DirectLighting is taking 15.15 ms as we have a cost per-light which wouldn’t allow our prototype to scale well performance wise.
With Enlighten we can switch lights to be Enlighten Only. This disables the direct rendering path of the light whilst maintaining the injection of light into the indirect lighting. As we’re using Enlighten’s dynamic lightmaps for this, we no longer have a per-light + per-pixel GPU cost.
Below is the result spawning 150 lights with Enlighten only enabled. The overall effect is preserved well. We’re not seeing some effects from the direct lighting such as the analytic reflection of the lightsource, but for our prototype framerate is a much higher priority.
The associated GPU profile shows no cost for the direct GPU lighting. This means that we’re not bound per-light on the GPU anymore and don’t need to worry about traditional per-pixel costs of rendering direct lighting for our spawned light sources.
CPU: Intel Xeon E5-2650 2.6 ghz
GPU Nvidia GeForce GTX TITAN X