I added a new texture plugin to pbrt to implement Worley noise. Worley noise is a procedural noise often compared to Perlin noise. It is defined by placing points in space in a roughly possion distribution. This can be done by breaking space apart into cells and placing around 1 to 5 random points in each cell. Call the (infinite) set of points placed in space S. Then, for the texturing, given a point p in space, determine the distance from p to the closest point in S. This is the value of the Worley noise function level F1. For F2 and F3, you must determine the second closest and third closest points in S from p and find those distances.
My implementation allows for four different types of distance functions to be used.
- Euclidean:
sqrt((p1.x - p2.x)2 + (p1.y - p2.y)2 + (p1.z - p2.z)2) - Manhattan:
|p1.x - p2.x| + |p1.y - p2.y| + |p1.z - p2.z| - Chebyshev:
max(|p1.x - p2.x|, |p1.y - p2.y|, |p1.z - p2.z|) - Minkovsky: (for a given e)
((p1.x - p2.x)e + (p1.y - p2.y)e + (p1.z - p2.z)e)(1/e)
I find F1 through F4 in my plugin and the coefficients for them can be given in the scene file. The default is [1 0 0 0], so the function output is 1*F1.
Here is a link to the source for my plugin. I used some code from Numerical Recipies in C for a cheap and easy random number generator. You can get that code here. I used a poisson distribution table from Worley's example code.
Conclusions
The code produces noise fairly quickly, but is still about 5 times slower than Perlin noise. I don't attempt any of the optimizations Worley suggests for ignoring cells based on the current closest point, since I wasn't sure how to extend them to additional distance function. Another issue is that the noise from this plugin isn't necessarily in the interval [0, 1]. Using different coefficents for the linear combination of Fs can give arbitrarily large (or small) values, so careful calibration of these values is necessary to give good results when a [0, 1] interval noise is desired. I think this noise function gives a good complement to Perlin noise, and I used a combination of those two functions to make my jade dragon image.
In manipulating the parameter values, higher F values give a rougher look.
