Today i finally optimized point lights. Without this optimization deferred rendering wouldn't be much worth it probably.
Basically instead of rendering all the screen for each light, i just render those fragments that are hit by the light. To do so i calculate the area of influence of the light, and draw a cube in that position.
In the picture you can see a red cube which contains entirely the area of influence of the point light (barely visible). Of course i can make the red cube invisible.
I can also render a rough-edged sphere (an icosahedron maybe), which result in more vertices to draw, but in less fragment to render. I'll need to find a good tradeoff point.
The fragments outside the cube are not rendered in the lighning pass.
To achieve this i also had to create a simpel class to render models...i wrote the big instancing-batched renderer, but i lacked of a simple renderer for single models.
Now i will need to refactor all this light stuff in a more coherent system, and also i need to write a better obj loader.

Nessun commento:
Posta un commento