Jump to content

Jump flooding algorithm

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by GoldtoothFour (talk | contribs) at 09:13, 28 March 2021 (Base change). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

The jump flooding algorithm (JFA) is a flooding algorithm used in the construction of voronoi diagrams and distance transforms. The JFA was introduced at an ACM symposium in 2006[1].

The JFA has desireable attributes in GPU computation, notably constant-time performance.

Grand strategy game developer Paradox Interactive uses the JFA to render borders between countries and provinces[2].

Implementation

The JFA original formulation is simple to implement.

Take an grid[3] (like an image or texture). All pixels will start with an "undefined" color unless it is a uniquely-colored "seed" pixel. As the JFA progresses, each "undefined" pixel will be filled with a color corresponding to that of a "seed" pixel's.

For each step size , run one iteration of the JFA:

  1. Iterate over every pixel at .
  2. Query each neighbor at where .
  3. If:
    1. is "undefined" and a neighbor is colored, change 's color to 's
    2. is colored and a neighbor is colored, if where and are the seed pixels for and , respectively, then change 's color to 's.[4]

The JFA finishes after evaluating the last pixel in the last step size. It walks a total of times over each pixel.

References

  1. ^ Rong, Guodong; Tan, Tiow-Seng (14-17 March). "Jump Flooding in GPU with Applications to Voronoi Diagram and Distance Transform" (PDF). Association for Computing Machinery. {{cite journal}}: Check date values in: |date= (help)
  2. ^ "Optimized Gradient Border Rendering in Imperator: Rome". Intel. Retrieved 2021-03-28.
  3. ^ The original paper uses the optimal case, a square grid, as an example, but a grid of any size works. Albeit with reduced efficiency. See this StackOverflow question for more.
  4. ^ Note that the JFA does not specify a method for resolving cases where distances are equal, therefore the last-checked pixel's color is used above