Per-pixel Brightness Dithering Optimizations 3 (Patreon)
Content
I was cutting too many corners, and after polishing the code, the speed increase is of about 5% only. Still worthwhile.
Be aware that this speed increase won't be noticeable in timedemos, but it still makes some difference. I basically removed the per-pixel brightness value dithering from the rasterizer, and added it to the surface cache generator. This means that while the rasterization (which is done in realtime) got faster, the surface cache generation (which is only done when surfaces are updated) got slower. In timedemos the action usually happens extremely faster than in normal gameplay, so it forces the surfaces to be updated much more often than usual, negating the performance improvement of this latest optimization.
Low resolutions will also not benefit much from this optimization, because while the per-pixel performance (which has increased) scales according to the screen resolution, the surface caching performance is mostly the same across different screen resolutions. Giving priority to higher resolutions helps to future-proof the engine, because it improves its scalability.
The only thing left to optimize in the surface caching is to only update dynamically lit surfaces when needed, because dynamic lights in Quake engines causes surface caches to be updated on every frame, even when the properties of the dynamic lights hasn't changed.
Anyway, the goal right now is to implement colored lighting support in the other asset types, including MDL models.