Jump flooding algorithm
This article, Jump flooding algorithm, has recently been created via the Articles for creation process. Please check to see if the reviewer has accidentally left this template after accepting the draft and take appropriate action as necessary.
Reviewer tools: Inform author |
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:
- Iterate over every pixel at .
- Query each neighbor at where .
- If:
- is "undefined" and a neighbor is colored, change 's color to 's
- 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
- ^ 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) - ^ "Optimized Gradient Border Rendering in Imperator: Rome". Intel. Retrieved 2021-03-28.
- ^ 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.
- ^ 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