Particle Trimming on OpenGL

This sample demonstrates how trimming particle quads down in size can increase performance by decreasing the amount of unnecessary texture sampling. This technique has been around for a while, but still isn’t very prevalent. The basis for this sample is a particle trimming tool created by Emil Persson, described in detail on his blog here. This sample takes our pregenerated output from this tool and uses it to calculate the trimmed particle coordinates.

The sample implements a very simple particle system, designed to show off a “real world” use case for particle trimming. The particle can be toggled between optimized (trimmed) and unoptimized using the P key. The simulation update can be paused with U. One modification to the original technique that was implemented was the addition of a single vertex in the center of the optimized particle. This center vertex helps ensure every triangle of the particle is of a reasonably uniform size. This helps avoid a performance penalty on Intel platforms of “long skinny” triangles.

The performance benefit from particle trimming is approximately proportional to the number of pixels that are trimmed from the full quad and can thus be quite significant. While this technique does add a small amount of vertex processing, a vast majority of games are pixel-bound, making this tradeoff worthwhile.

Screenshot of particle emitter - not-trimmed.

Screenshot of Particle Emitter - trimmed

Written by and developed by - Kyle Weicht 

Archivo adjuntoTamaño
Icono de paquete particletrimming-windows-binaries.zip118.03 KB
Icono de paquete particletrimming-source.zip123.18 KB
Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.