My God, it's Full of Stars! (Patreon)
Content
Some HUGE quality improvements were done to the procedural particle renderer.
Here's an YouTube video showcasing everything. I'm sharing the video as a link so I can upload full-quality screenshots to this post.
Previously, the dithered particles had 8 levels of dithering. Now, this doubled to 16 levels of dithering, with ZERO impact on performance; the realtime procedural data structures and rasterization functions are exactly the same. This was achieved purely by preprocessing the procedural particle data in a more efficient way during the procedural particle data generation process.
Also, now we have a third particle shape! Thanks to the way the procedural particles are structured, they can also have horizontally concave shapes, so I implemented a 4-pointed star shape that goes really well with Quake's teleport vfx particles, because it matches the stars in the turbulent teleport texture.
Despite the particle shapes being varied, it's still important to ensure that all shapes are equally visible at any distance, so now each shape is individually scaled to its proportional area size, ensuring that all shapes covers the same amount of pixels on the screen.
Another improvement is that all particle shapes (square, circle and star) are generated simultaneously now, and they stay together in the RAM, so there's zero delay when switching particle shapes. The final purpose of this is to allow multiple different particle shapes to be used in different visual effects at once, but for now I'm switching shapes through the r_particle_shape cvar.
Naturally, generating the procedural data for all three shapes at once across over a thousand possible particle sizes takes longer than generating the same for a single shape. It involves millions of trigonometric calculations and span operations. To avoid having to do the whole particle generation process again when switching back to previously set video modes, the engine now saves the generated procedural particle data to a gzip-compressed cache file for each video resolution, so now the game can also start faster. This cache file includes a validation header containing the parameters used to generate the particles, so if anything doesn't match the current configuration, the cache is regenerated and the stale file is replaced.
Also, while the realtime rendering performance of particles is still the same, to fit all three particle shapes in the RAM some memory optimizations were done, cutting the required amount of RAM in more than half. So, despite the amount of shapes in the RAM being 3 times bigger now, the particles' RAM consumption is only 1.4 times bigger now.
And finally, non-dithered particles are back! The non-dithered procedural particle data got broken a long time ago, but it's finally fixed.
A couple other minor bugs were fixed in the particle renderer, and some further cleanup was done.
This is some of my finest work, and I truly believe Retroquad's particle renderer to be a world-class software rendering code with unmatched efficiency.