AO

Light Clustering

Now that the eninge has been at the stable point, and our indie project is now entering its alpha production stages, I get to do some experiments for the rendering engine.

We've been improving how Lumina handles scenes with many local lights. The dream was to allow an absurd amount of lights (which directs us to deferred rendering) and as much as I wanted to, deferred rendering is still a bit odd and honestly, hard to grasp of the technique.

Forward rendering is still my go to solution, and not only that it's a straight forward technique, it's easier to take hold of it mentally espetially when doing transparent (which really needed a forward rendering anyway).

Of course the natural evolution of Forward rendering is Forward+, and I had to choose between two techniques: Tiled Lighting, or Clustered Lighting.

Tiled Lighting was the better choice for our game, but I couldn't shake my thoughts of the Clustered Lighting mainly because the implementation of it is.... well quite complex.

But first, we need to understand that in order to show lights to the scene, or even calculate them, we need to find where these lights are in the scene and figure out how they affect the view of the camera.

Of course the slowest and wasteful process of this is to iterate all the lights in the scene, and check them one by one.

image

Basically, the field of view needs to be sliced into different sections (forive my attempt to logarithmic sections) and devides each into small screen tiles and depth slices.

This list is now built on the GPU (due to the amount of checks that needed to eb done).

And then when shading the surface using the fragment shader, the shader checks if the screen position of that pixel and depth to find its cluster. If that pixel is included, then it takes the light that affects that cluster, otherwise, it simply ignores it.

image

This eliminates the need for the rest of the pixels to calculate lights on thair side.

This is applied to different types of lights too except for the directional light though spotlight can be tricky because of its shape, where I settled on a sphere area

image

So far, I am happy with the results, of course I need to check the edgest of cases but based on our project, we don't really need a Light Clustering support, so this needs to be configurable to at least a lower number of slices or regions/sections. Which ever.

I guess the next one to tackle is to revisit shadows. I heard that distance fields can be used for them :D