A Spatial Data Structure For Fast Poisson-Disk Sample Generation
A Spatial Data Structure For Fast Poisson-Disk Sample Generation
503
cause of their blue noise properties and relationship to pho- 2 Dart-Throwing in O(N log N )
toreceptor distributions, but ultimately advocates the use
of jittered grids because the straightforward dart-throwing
The dart-throwing method for computing Poisson-disk dis-
algorithm for generating Poisson-disk distributions is pro-
tributions iteratively refines an existing point set by gen-
hibitively expensive. Since then, many algorithms have been
erating a series of random candidate points in the sample
proposed for generating point distributions; e.g. [Ulichney
domain and keeping only the first such point that is farther
1988; Shirley 1991; Hiller et al. 2001; Kollig and Keller 2002;
than the minimum distance 2r from all other points. Each
Kollig and Keller 2003].
sample effectively invalidates a disk of radius 2r centered
Mitchell’s O(N 2 ) “best-candidate” algorithm attempts to around that point.
mimic dart-throwing while providing a termination guaran- This algorithm is simple to implement and extends naturally
tee [Mitchell 1991]. Whenever a new sample is to be drawn, to any domain with a well-defined and computable distance
a number of candidate samples are randomly generated, and metric. However, the algorithm may not terminate, so in
the candidate that is farthest from the existing point set is practice the algorithm is stopped after some fixed number
accepted. This algorithm cannot guarantee the Poisson-disk of consecutive candidates have failed to be accepted.
property, but in practice it generates excellent point sets if
enough candidates are drawn. The primary drawback of this One side effect of this approximation is that the generated
technique is its long running time. point set is usually not maximal (there may be regions where
a point could be placed without violating the distance crite-
McCool and Fiume generated high-quality tile sets with a rion), so some regions of the domain may be undersampled.
toroidal distance function so that they could be repeatedly This problem is usually ignored, although Jones’ technique is
tiled across the plane [McCool and Fiume 1992] and intro- guaranteed to generate maximal distributions [Jones 2006].
duced the use of Lloyd’s relaxation to improve the blue noise Furthermore, since a large number of sample points is typ-
properties of the set. Lloyd’s relaxation transforms a point ically required, the algorithm is too slow to use directly.
set by moving each point to the center of its associated Consequently, several schemes for precomputing small dis-
Voronoi region and is typically applied iteratively or used tributions and tiling them have been proposed [Hiller et al.
to generate distributions directly [Hiller et al. 2001]. Once 2001; Cohen et al. 2003; Lagae and Dutré 2005].
the tiles have been generated, this method generates large
point sets very efficiently. However, the tiling process intro- We call the subdomain within which it is legal to add a point
duces easily recognizable structures. This is acceptable for the available subdomain. Let D(x, r) be the disk of radius r
most sampling applications as long as the tile size is large around a point x. For a domain X and existing point set P ,
enough, but is disastrous if the points are being used to dis- the available subdomain is given by
tribute objects or as part of a texture basis function. Several [
schemes have been proposed to solve this problem. AX = X − D(p, 2r).
p∈P
Multiple authors have proposed using Wang tiles to solve
this problem. Cohen et al. populated a set of Wang tiles
with small point distributions that were intended to tile the The key to emulating dart-throwing efficiently is the obser-
plane [Cohen et al. 2003]. Lagae et al. showed that cor- vation that we do not need to sample the entire available
rectly applying this technique requires careful attention to subdomain. Consider the annulus between radii 2r and 4r
how points are placed at the boundary of a tile and presented around some point. Every point in this annulus must be un-
Poisson-disk tiles to address these issues [Lagae and Dutré available in any maximal distribution and therefore within
2005]. Most recently, Kopf et al. have extended these tech- a distance of 2r from some other point. This means that
niques to allow generation of point sets with blue noise prop- there must be at least one point that lies inside the annu-
erties satisfying an arbitrary density function [Kopf et al. lus, and hence the union of all such annuli, intersected with
2006]. Their technique produces high quality point sets very the available subdomain, must contain at least one point.
efficiently once the tile set has been computed. Therefore, it is possible to emulate dart-throwing by sam-
pling from only this region, which we call the available neigh-
Ostromoukhov et al. described a fast technique for impor- borhood of a point set P . By carefully choosing the repre-
tance sampling a provided density function [Ostromoukhov sentation for this region, dart-throwing can be implemented
et al. 2004]. Their algorithm generates point sets with lo- in O(N log N ) time.
cal blue noise characteristics by using a clever modification
of Penrose tiles and exploiting the tilings’ aperiodic nature.
However, when used to generate many points from a con- 2.1 Representing the Available Neighborhood
stant density function, the resulting point sets have larger
angular anisotropy than techniques based on randomness. The problem of representing the available neighborhood can
be divided into two parts: developing a spatial structure
Jones presents an algorithm for generating 2D Poisson-disk for the available region of the annulus, and partitioning the
distributions in O(N log N ) time [Jones 2006]. Like our tech- available neighborhood so that these structures can be effi-
nique, Jones’ method builds a point set incrementally by ciently updated upon the insertion of a new point. In ad-
storing neighboring regions of points in a balanced tree and dition, it must be possible to quickly generate a uniformly
inserting points into these regions one by one. However, distributed random point inside the region.
neighbor regions are represented as Voronoi cells and Jones’
method requires an incremental Delaunay triangulation al- Our solution to the first part of this problem involves a new
gorithm with O(log N ) performance when adding a point. data structure, the scalloped region. This data structure can
This makes the implementation more complicated than that be used to efficiently represent arbitrary boolean operations
of our algorithm. Furthermore, in this paper we show a on 2D disks. We divide scalloped regions into a disjoint
variation of our algorithm that runs in linear time. union of scalloped sectors (Figure 2). A scalloped sector
504
Although we do not have a closed form equation for A−1 , A
h(α) is the integral of a function that is both non-negative and
zero only at the angular endpoints, so A is monotonically
increasing and therefore invertible. In practice binary search
is sufficient to evaluate A−1 efficiently.
A(α)
The result of a boolean union, intersection, or difference op-
eration between a single scalloped sector and a disk can al-
ways be subdivided into a small number1 of new scalloped
C2 sectors. A scalloped region maintains a list of its constituent
r2 scalloped sectors and operations are performed by replac-
g(α) ing each sector with the result of applying the operation
to each individual sector. A complete description of how
α2 to locate the new scalloped sectors requires enumerating a
r1 C1 number of cases and is omitted here for brevity; the full de-
α1 tails can be found in our extended technical report [Dunbar
and Humphreys 2006].
The available neighborhood is partitioned into scalloped sec-
tors of outer radius 4r around each point in order to restrict
the number of sectors that must be updated after point in-
sertion to a small constant. Efficient sampling, however,
requires that all of these neighborhoods be disjoint. In gen-
Figure 2: A scalloped sector is a sector bounded above and eral, if an ordering relation is defined for a set S of sets it is
below by circular arcs. In the above diagram, α ranges from possible to derive a new set S 0 of disjoint sets where
α1 to α2 , and g(α) and h(α) are the distance functions from [ [
the sector’s apex to the near and far arcs, respectively. A(α) s0 = s,
is the partial area of the sector up to α, represented by the s0 ∈S 0 s∈S
light gray area in the figure.
by subtracting from each set the union of all members of S
that are less than it in the relation.
centered at the origin is defined as the sector lying between We use the generation order of the points as an ordering re-
angles α1 and α2 and bounded by near and far circular arcs. lation and then define the available neighborhood of a point
For convenience, the circular arcs are required to be non- p ∈ P as
intersecting, although they are allowed to meet at the edge [ D(p0 , 4r), p0 < p
of the sector. Np = D(p, 4r) − .
D(p0 , 2r), p0 ≥ p
The circular arcs are each described by a center C, radius r, p0 ∈P
and a sign k ∈ {−1, 1} which selects either the near or far
arc of the circle. The distance to this circular arc along a
S
The available neighborhood is N = p∈P Np (Figure 3).
ray at angle α is then given by Each disjoint Np is computed using boolean disk subtraction.
p
d cos(α − γ) + k r2 − (d sin(α − γ))2 ,
2.2 Algorithm Details and Complexity Analysis
where (d, γ) are the polar coordinates of C (taking the apex
of the sector to be the origin). If g(α) and h(α) represent Our algorithm A1 for efficient dart-throwing begins with an
the distance functions to the inner and outer bounding arcs initial set consisting of a single point randomly chosen in
respectively then the area of the sector up to an angle α is the domain. During sample generation, we maintain an as-
given by sociative map from candidate points (points with non-empty
Z α Z h(θ)
available neighborhoods) to their associated neighborhoods.
A(α) = r dr dθ,
α1 g(θ) A candidate point is then randomly chosen (using neigh-
borhood areas as a probability distribution) and a random
and the area of the full sector is A(α2 ). point within its neighborhood is added to the point set. The
The probability of a random point in a scalloped region available neighborhood for the new point is an annulus from
falling within a particular sector is the area of the sector radii 2r to 4r, minus a disk of radius 4r around the nearby
divided by the area of the region. A uniform random point points. The maximum distance required to search for neigh-
within the region can be generated by randomly choosing bors is 8r since the scalloped region and neighbor disk are
a sector using the sectors’ areas as a probability distribu- both bounded by 4r. All nearby neighborhoods are then up-
tion and then generating a uniformly distributed point inside dated by subtracting a disk of radius 2r around the newly
the chosen sector. Generating the point inside the sector is inserted point. This process continues until no candidate
done by transforming a uniformly distributed random point points remain.
(ξ1 , ξ2 ) in [0, 1]2 to a point (d, θ) in polar coordinates, where The maximum number of scalloped sectors in an available
p neighborhood is bounded by a constant. Furthermore, the
d = g(θ)2 + ξ1 (h(θ)2 − g(θ)2 ) 1 Bounded by a constant that depends only on the particular
−1
θ = A (ξ2 A(α2 )). operation (e.g, seven for disk subtraction).
505
for applications such as randomized object placement, in
which it is desirable to tune the density of the point set.
Np1
A special case arises if r0 is taken to be the minimum value
2r. In this case, a point’s available neighborhood collapses
to a collection of circular arcs centered at the point. We
call these arcs the available boundary. By directly imple-
p1 menting boundary sampling, we no longer need to represent
the available neighborhood as scalloped regions; instead, the
available boundary is represented as a set of per-point angu-
lar ranges at which a point can be placed on the boundary.
506
N 1000 10000 100000
Average Radial Power (dB) A1
Best Candidate 1.454 157.014 6.084h
A2
Dart-throwing (A1 ) 0.573 5.905 141.901
A3
O(N) Dart-throwing (A2 ) 0.667 6.442 61.186
Ostromoukhov et al. 0.015 0.095 1.546
Boundary Sampling (A3 ) 0.001 .058 0.496
507
(a) A1 : Dart-throwing (b) Best Candidate (c) Ostromoukhov et al. (d) A3 : Boundary sampling
Figure 5: Averaged periodograms for several sampling methods. Boundary sampling generates the best blue noise spectrum
due to its extremely regular and dense sampling of the plane. Ostromoukhov et al.’s results are noisier because their technique
does not involve randomness, so averaging multiple runs does not provide smooth periodograms.
In general, this metric will not have a closed analytic form, Kollig, T., and Keller, A. 2002. Efficient multidimen-
and therefore the boundary cannot be directly determined. sional sampling. Computer Graphics Forum 21, 3, 557–
Nonetheless, it would be possible to solve for a piecewise 563.
linear (or higher order, if necessary) approximation of the
distance metric in the vicinity of a point and use that to Kollig, T., and Keller, A. 2003. Efficient illumination
represent the local boundary. By applying this technique by high dynamic range images. Rendering Techniques,
and the method in 5.1 we hope to be able to extend our 45–51.
technique to support efficient importance sampling. Kopf, J., Cohen-Or, D., Deussen, O., and Lischinski,
We intend to apply these results combined with those in the D. 2006. Recursive wang tiles for real-time blue noise.
previous section in order to be able to place objects with ACM Transactions on Graphics 25, 3.
varying radii across unbounded regions. We expect this to be Lagae, A., and Dutré, P. 2005. A procedural object
valuable for generating complex terrain and environments. distribution function. ACM Transactions on Graphics 24,
4, 1442–1461.
McCool, M., and Fiume, E. 1992. Hierarchical poisson
References disk sampling distributions. In Proceedings of the confer-
ence on Graphics interface ’92, Morgan Kaufmann Pub-
Cohen, M. F., Shade, J., Hiller, S., and Deussen, O. lishers Inc., San Francisco, CA, USA, 94–105.
2003. Wang tiles for image and texture generation. ACM
Transactions on Graphics 22, 3, 287–294. Mitchell, D. P. 1991. Spectrally optimal sampling for dis-
tribution ray tracing. In Computer Graphics (Proceedings
Cook, R. L. 1986. Stochastic sampling in computer graph- of ACM SIGGRAPH 91), ACM Press, New York, NY,
ics. ACM Transactions on Graphics 5, 1, 51–72. USA, 157–164.
Dippé, M. A. Z., and Wold, E. H. 1985. Antialiasing Ostromoukhov, V., Donohue, C., and Jodoin, P.-M.
through stochastic sampling. In Computer Graphics (Pro- 2004. Fast hierarchical importance sampling with blue
ceedings of SIGGRAPH 85), ACM Press, New York, NY, noise properties. ACM Transactions on Graphics 23, 3,
USA, 69–78. 488–495.
Dunbar, D., and Humphreys, G. 2006. Using scalloped Shirley, P. 1991. Discrepancy as a quality measure for
sectors to generate poisson-disk sampling patterns. Tech. sample distributions. In Proceedings of Eurographics, 183–
Rep. CS-2006-08, University of Virginia. 194.
Hiller, S., Deussen, O., and Kaufmann, A. 2001. Tiled Ulichney, R. A. 1988. Dithering with blue noise. In Proc.
blue noise samples. In VMV ’01: Proceedings of the Vision of the IEEE 76, 56–79.
Modeling and Visualization Conference 2001, Aka GmbH,
265–272. Yellot, J. I. 1983. Spectral consequences of photoreceptor
sampling in the rhesus retina. Science 221 , 382–385.
Jones, T. 2006. Efficient generation of poisson-disk sam-
pling patterns. Journal of Graphics Tools, to appear .
508