Big Potential Optimization for BSP Lighting (Patreon)
Content
I wrote a little routine to identify BSP surfaces whose lighting values are all the same, and the results were surprising. In the first episode of vanilla Quake, most maps have about 18% of such surfaces, with some maps going over 22%.
Also, this little detection algorithm can't detect non-rectangular surfaces that doesn't use all lightblocks, so there's some potential to detect even more flat lighting surfaces.
With all visible luxels being identical, this means those surfaces can be rasterized using a flat lighting algorithm, which is incredibly faster to render. They only need to be rendered with lightmaps when dynamic lights are applied to them.
In custom maps created with uniform sunlights, the speed gains may be quite big in open areas, but I can't estimate by how much.
This is some great optimization potential, but I won't work on it yet because it will take a lot of work; all BSP drawing functions will have to be duplicated, and there are many dozens of them already.
Right now I'm working on optimizing the 2D rasterizer, and after that I have to add more drawing modes to the 2D rasterizer, and finally fix the texture switching bugs in the 2D renderer.