PopcornFX DEV. NOTE #1

PopcornFX screenshot

Feature curve quality


Since the release of PopcornFX V1.12.0, it is possible to drastically improve curve sampling performances by using a new “Quality” setting in the curve sampler.

Four presets are available: “Exact”, “High”, “Medium”, and “Low”.

The “Exact” setting gives the same results as previous versions of PopcornFX, and evaluates the precise curve cubic spline equation using the artist-specified control-points and tangents. This is expensive.
Various optimizations are already made for a low number of control-points, but the generic case for a higher number of control-points requires a per-particle search to find the two control-points enclosing the sampling cursor.

All the lower settings pre-sample the curve at fixed steps into an array (think of it as baking the curve to a texture). No need to search anymore, when sampling the curve, PopcornFX´s runtime knows instantly where to look in the array and linearly interpolates the two samples enclosing the sampling cursor.
This is much faster!

How much faster? It depends on the exact platform, CPU, and the number of original control-points. Anyway, it is a 6x – 8x speedup for real-world curves compared to the exact sampling.
The only difference between “High”, “Medium”, and “Low” is the size of the array, which is respectively 512, 128 and 8 for desktop, PS4 and Xbox One, and 256, 64 and 8 for all other platforms.

Below is an example of the same curve sampled with all four quality types. The exact curve is shown in green, the curve sampled using the specific quality setting is shown in purple, and the overall curve appears whitewhere the sampled curve fits the exact curve.

Original curve

Exact quality curve sample

The sampling of the curve is quite costly, there is no memory overhead, and obviously the sampling fits perfectly the curve.

High quality curve sample

The sampling of the curve is ~6 times faster than exact, but there is a memory overhead of 8Kb for each curve sampler in the effect. The sampling errors are unnoticeable.

Medium quality curve sample

The sampling of the curve is ~6.5 times faster than exact, the memory overhead is 2Kb per sampler, we can see some artefacts on sharp parts, but it’s still hardly noticable.

Low quality curve sample

The sampling of the curve is ~7.5 times faster than exact, the memory overhead is insignificant (128 bytes per sampler), but the quality is pretty low.

Examples with a real effect

This effect contains two curves, one for the size of particles and the other one for color.


As you can notice, the difference is really hard to see when the curves are smooth.

Gain in performance is notable in this case. The whole effect takes 1.3 ms with exact sampling vs 0.8 ms for all others quality settings.


This is a great option to further optimize your effects. It’s always a win on the performance side, but care must be taken on the memory usage, especially on mobile.

Ideally you should use the PopcornFX editor built-in profiling tools to spot which layers are the most performance-hungry, if curves are a bottleneck, and focus on optimizing those first.
Low settings is excellent for both performance and memory, and can be used without any visual degradation for any curve that has a smooth shapes with no spikes, or for far-away effects if you’re doing LOD.

Also keep in mind curves are usually a small part of a complete effect, so this trick is not a silver bullet that will magically make the effects twice faster. Even if the sampling in itself can be measured to be 7 times faster, the final performance gains will be much lower, as it will be a small part of a much larger system.