Today I completed the tiled deferred rendering implementation to fully support directional and spot lights as well.
For directional lights I just needed to refactor the shader to sample the G buffer just once, and use its result to process all the lights.
For spot lights, I also had to take care of culling. This is mostly done the same way as point lights, but the position and radius of the bounding sphere are preprocessed in order to calculate a fitting sphere that matches the cone as much as possible. There are probably more correct ways to tackle the problem, but this works well enough for my purpose. In the picture you can see the amount of spot lights processed for each tile, and as you can see the culling is more aggressive than with point lights.
I also wrote from scratch the code to get the outer fading of the spot lights, as the math was slightly off.
EDIT: the pic contains a bug with AABB culling, noticeable in the black edges in the bottom of the screen, which has been fixed in the evening.

Nessun commento:
Posta un commento