Skip to content

Performance

Ryan Sweeney edited this page May 19, 2024 · 17 revisions

Calculating the Distance Field is rather expensive, as such I've added a few ways to optimise the process.

V 1.2

In progress - to see the spreadsheet containing the data visit the following link - Google Sheets

V 1.1

Max Pixel Distance

This reduces the number of passes performed. If you only need say, an outline 24px thick, then you don't need to run the full JFA set of passes. You can start with a step size of 32px and this means you can still get a distance field but only up to the distance specified. It is highly recommended to use this.

Process Mask

This downsamples the stencil to create a mask that allows an early exit in the shaders. This step incurs an overhead so at lower resolution it can take as much if not more time than it saves. Can be set to be based on the Max Pixel Distance. If any DFO setting is using this value, all Simple (Single In/Out and Double) outlines will automatically use it even if the setting is disabled. Simple outlines using this will only use the first downsample level as anything more is redundant.

Half JFA

This reduces the resolution by half and increases performance at the cost of quality. During upscaling a smoothing operation is performed. This option is good for thicker outlines.

Performance Testing

I've performed some rudimentary performance testing. The setup is 1 object with a simple outline (single inside/outside or double) or 1 object with a distance field outline both with and without any of the optimisation options. And then the same again with 4 objects and 4 unique outlines active at the same time.

There should be some more performance gains with version 1.2!

The method of capture was capturing the frame with RenderDoc and using the timing function, hitting the timing function several times to get a rough middle value.

Simple Outlines - Single & 4 Unique Outlines

From left to right, Simple unoptimised, Simple optimised, 4 Simple unoptimised, 4 Simple optimised outlines.

Distance Field - Single

From left to right, Distance Field unoptimised, Distance Field optimised, Distance Field optimised at half res

Distance Field - 4 Unique Outlines

From left to right, 4 Distance Field unoptimised, 4 Distance Field optimised, 4 Distance Field optimised at half res