Adding density maps to the poisson points generator

I wanted to add varying density maps to my poisson points generator. For example, I want to use this density field to generate foliage:

I started with multiplying the MinDist parameter by the density value. This broke the entire algorithm. The solution that works is to generate a rectangle full of poisson points and then roll a dice for every point and discard it if the roll of the dice is above the density value at the considered point:

			float R = RandomFloat();
			float P = g_DensityMap[ x + y * ImageSize ];
			if ( R > P ) continue;

Here is the resulting image:

The complete source code is on GitHub: https://github.com/corporateshark/poisson-disk-generator

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.