Skip to content

Commit

Permalink
pdVoronoi: 2x perf improvements in preparation for new effect(s)
Browse files Browse the repository at this point in the history
This primarily affects two items in the Effects menu:
- Effects > Artistic > Stained Glass
- Effects > Pixelate > Crystallize

Both of these effects rely on pdVoronoi for their behavior, and both are now much faster, particularly while previewing on large images.

I've spent the past few days aggressively optimizing this class in preparation for a feature request to add Voronoi (or Worley) Noise to the Effects > Render menu.  This type of noise looks like this:

https://en.wikipedia.org/wiki/Worley_noise

It's a component of many automated texture algorithms, and since PD already has a capable Worley engine "under the hood", it shouldn't be hard to add a high-quality rendering filter.

Before tackling that, however, I wanted to improve performance as much as possible.  A ton of little optimizations have added up to a nearly 2x performance increase over the old version, with a 10-megapixel photo now processing in 3-4 seconds instead of 7-8 (Stained Glass, specifically - Crystallize is much faster than this, owing to its simplicity).  Gains will be even larger on more modern CPUs, since data locality is a challenge with this filter and larger caches will make a disproportionately large difference.

I've also fully migrated the engine to floating-point calculations, which allows for prettier rendering at a (after-much-work-minor) cost to performance.

Next up is to improve flexibility by not requiring the points to lie on a strict grid.  I'm going to test several approaches to this as it has significant performance repercussions, but if successful, it should allow for more natural-looking variations.
  • Loading branch information
tannerhelland committed Dec 7, 2020
1 parent baae27c commit 02f60a5
Show file tree
Hide file tree
Showing 4 changed files with 386 additions and 355 deletions.
Loading

0 comments on commit 02f60a5

Please sign in to comment.