A Cellular Texture Basis Function
Total Page:16
File Type:pdf, Size:1020Kb
A Cellular Texture Basis Function Steven Worley 1 ABSTRACT In this paper, we propose a new set of related texture basis func- tions. They are based on scattering ªfeature pointsº throughout 3 Solid texturing is a powerful way to add detail to the surface of < and building a scalar function based on the distribution of the rendered objects. Perlin's ªnoiseº is a 3D basis function used in local points. The use of distributed points in space for texturing some of the most dramatic and useful surface texture algorithms. is not new; ªbombingº is a technique which places geometric fea- We present a new basis function which complements Perlin noise, tures such as spheres throughout space, which generates patterns based on a partitioning of space into a random array of cells. We on surfaces that cut through the volume of these features, forming have used this new basis function to produce textured surfaces re- polkadots, for example. [9, 5] This technique is not a basis func- sembling ¯agstone-like tiled areas, organic crusty skin, crumpled tion, and is signi®cantly less useful than noise. Lewis also used paper, ice, rock, mountain ranges, and craters. The new basis func- points scattered throughout space for texturing. His method forms a tion can be computed ef®ciently without the need for precalculation basis function, but it is better described as an alternative method of or table storage. generating a noise basis than a new basis function with a different appearance.[3] In this paper, we introduce a new texture basis function that has INTRODUCTION interesting behavior, and can be evaluated ef®ciently without any precomputation. After de®ning the function and its implementation, Procedural texturing has proved itself valuable in image synthesis, we show some applications demonstrating its utility. allowing for complex surfaces to be rendered without requiring im- age mapping or hand modeling of geometric details. The most use- ful texturing techniques were introduced by Perlin [7] with his in- troduction of a fractal noise basis function which has become the primary tool used in procedural texturing. Since the fractal noise basis does not need any storage or precomputation, and returns a nTH-CLOSEST POINT BASIS FUNCTION 3 value for all locations in < , it is easy to use and applicable to many applications. The scalar value can be directly mapped into a color, We can de®ne a new basis function based on the idea of random fea- but it is often used for spatially perturbing regular patterns. Its de- 3 ture points. Imagine points randomly distributed through all of < . rivatives can be used for bump mapping. [1, 3, 5, 6, 7, 8] x For any location x, there is some feature point which lies closer to Many texture algorithms are not as broadly applicable as noise F (x) x than any other feature point. De®ne 1 as the distance from to because of their limited form. For example, the class of reaction- x F that closest feature point. As is varied, 1 varies smoothly since diffusion textures, as in [10], provides interesting surfaces, with a the distance between the sample location and the ®xed feature point character that provides features such as spots and stripes. An al- varies smoothly. However, at certain cusp locations, the point x will gorithm by Miyata [4] generates impressive stone wall patterns. F (x) be equidistant between two feature points. Here, the value of 1 These methods, while powerful, aren't as generally useful as noise is still well de®ned, since the value is the same no matter which fea- since they require extensive precomputation and don't return a ture point is chosento calculate the distance. Varying the position of scalar value to be used as part of a larger texture. x F will return values of 1 that are still continuous, though the deriv- The simple functional nature of noise makes it an adaptable tool F ative of 1 will change discontinuously as the distance calculation one might call a texture ªbasisº function. A basis function should ªswitchesº from one feature point to its neighbor. 3 be a scalar value, de®ned over < . This allows it to be used in the F same manner noise is applied. Fourier methods [1, 2] produce ef- It can be seen that the locations where the function 1 ªswitchesº fective basis functions, but usually similar appearances can be pro- from one feature point to the next (where its derivative is discon- duced more easily using noise. The immense utility of the noise tinuous) are along the equidistance planes that separate two points 3 function motivates us to ®nd new texture functions that can also be in < . These planes are exactly the planes that are computed by a used as basis functions, so they may be used in the same versatile Voronoi diagram, which by de®nition partitions space into cellular manner that noise is used. regions where all the points within each region are closer to its de- ®ning point than any other point. 1 405 El Camino Real Suite 121, Menlo Park CA 94025 E- F (x) mail: [email protected] The function 2 can be de®ned as the distance between the location x and the feature point which is the second closest to the x F . With similar arguments as before, 2 is continuous everywhere, but its derivative is not at those locations where the second-closest point swaps with either the ®rst-closest or third-closest. Similarly, F (x) x n we can de®ne n as the distance between and the th closest feature point. F F The functions have some interesting properties. n is always F 0 F (x) F (x) F (x): 1 2 3 continuous. n are nondecreasing; F (x) F (x) F n+1 n In general, n by the de®nition of . The gradient F n of n is simply the unit direction vector from the th closest feature point to x. F (x) COMPUTATION OF n within a neighboring cube could quite possibly contain a feature point even closer than the ones we have found already, so we must F To evaluate the functions n , we must ®rst de®ne how feature points iterate among the boundary cubes too. Testing each of 26 bound- are spread through space. The density and distribution of points will ary cubes would be slow, but by checking the closest distance we've change the character of the basis functions. We want an isotropic computed so far (our tentative nth closest feature distance) we can distribution of points to avoid artifacts such as an obvious grid-like throw out whole rows of cubes at once by noting that no point in the pattern. This eliminates any regular lattices such as a cubic spacing. cube could possibly contribute to our list. Typically, only 1±3 cubes Even if the lattice points are jittered, the underlying lattice structure actually need to be tested. F may cause odd patterns. Note that when we compute n we are effectively ®nding val- F ;F ; :::; F 2 n The simplest distribution is simply a Poisson distribution, which ues for 1 simultaneously. In practice our routine re- speci®es a mean density of points in space, with the location of each turns all these values, plus the direction vectors corresponding to point being independent of the other points. The expected number each feature point, plus a unique ID integer for each point (equal of points in any region is simply the point density times the volume to the hashed cube ID plus the index of the feature point as it was of the region. There may be more or less than this expected num- computed). These tend to be useful when using the function to form ber of points in the region; the exact probabilities of any number of solid textures. points in a region can be computed by using the discrete Poisson In practice, computation is extremely ef®cient. A fast, linear con- distribution function. gruential (LCG) random number generator is effectively just an in- Our approach divides space into a grid of uniformly spaced teger multiply and add. By using ®xed point arithmetic, the 32 bit cubes, separated at the integer coordinate locations. Each ªcubeº in random number can be manipulated directly. We avoid square roots space can be uniquely represented by its integer coordinates, and by by sorting on squared distance. Testing a point requires generation simple ¯oor operations we can determine, for example, that a point of its coordinates (three multiplies), computing the squared distance like (1.2, 3.33, 2.3) lies within the cube indexed by (1, 3, 2). to the sample location (three multiplies), and insertion into the best Each cube in space may contain zero, one, or more feature points. candidate list (usually one to three compares.) The computation We determine this on-the-¯y quite simply by noting that the Pois- speed is therefore surprisingly fast. In our implementation, simul- F F 2 son random distribution function describes the exact probabilities of taneously computing 1 and requires about the same amount of each of the possible number of feature points occuring in the cube. time as computing one scale of Perlin's noise. We also found that by varying the point density we were able to For a mean density of feature points per unit volume , the probab- 1 m tune our algorithm. Low requires fewer points to be computed in ( e m!) ility of m points occuring in a unit cube is . Thus we each cube. Higher makes it more likely to ®nd the best points in =0;1;2;3::: can tabulate the probabilities for m and index a ran- the initial cube, reducing the number of neighboring cubes that must dom number into this table to determine how many feature points also be tested.