词条 | Diamond-square algorithm |
释义 |
The diamond-square algorithm is a method for generating heightmaps for computer graphics. It is a slightly better algorithm than the three-dimensional implementation of the midpoint displacement algorithm which produces two-dimensional landscapes. It is also known as the random midpoint displacement fractal, the cloud fractal or the plasma fractal, because of the plasma effect produced when applied. The idea was first introduced by Fournier, Fussell and Carpenter at SIGGRAPH 1982.[1] The diamond-square algorithm starts with a 2D grid then randomly generates terrain height from four seed values arranged in a grid of points so that the entire plane is covered in squares. DescriptionThe diamond-square algorithm begins with a 2D square array of width and height 2n + 1. The four corner points of the array must first be set to initial values. The diamond and square steps are then performed alternately until all array values have been set. The diamond step: For each square in the array, set the midpoint of that square to be the average of the four corner points plus a random value. The square step: For each diamond in the array, set the midpoint of that diamond to be the average of the four corner points plus a random value. At each iteration, the magnitude of the random value should be reduced. During the square steps, points located on the edges of the array will have only three adjacent values set rather than four. There are a number of ways to handle this complication - the simplest being to take the average of just the three adjacent values. Another option is to 'wrap around', taking the fourth value from the other side of the array. When used with consistent initial corner values this method also allows generated fractals to be stitched together without discontinuities. VisualizationThe image below shows the steps involved in running the diamond-square algorithm on a 5 × 5 array. ApplicationsThis algorithm can be used to generate realistic-looking landscapes, and different implementations are used in computer graphics software such as Terragen. It is also applicable as a common component in procedural textures. Artifacts and extensionsThe diamond-square algorithm was analyzed by Gavin S. P. Miller in SIGGRAPH 1986[2] who described it as flawed because the algorithm produces noticeable vertical and horizontal "creases" due to the most significant perturbation taking place in a rectangular grid. The grid artifacts were addressed in a generalized algorithm introduced by J.P. Lewis.[3] In this variant the weights on the neighboring points are obtained by solving a small linear system motivated by estimation theory, rather than being fixed. The Lewis algorithm also allows the synthesis of non-fractal heightmaps such as rolling hills or ocean waves. Similar results can be efficiently obtained with Fourier synthesis,[4] although the possibility of adaptive refinement is lost. The diamond-square algorithm and its refinements are reviewed in the book.[4] References1. ^{{cite journal|last=Fournier|first=Alain|last2=Fussell|first2=Don|last3=Carpenter|first3=Loren|title=Computer rendering of stochastic models|journal=Communications of the ACM|date=June 1982|volume=25|issue=6|pages=371–384|doi=10.1145/358523.358553}} 2. ^{{cite journal|last=Miller|first=Gavin S. P.|title=The definition and rendering of terrain maps|journal=ACM SIGGRAPH Computer Graphics|date=August 1986|volume=20|issue=4|pages=39–48|doi=10.1145/15886.15890}} 3. ^{{cite journal|last1=Lewis|first1=J. P.|title=Generalized stochastic subdivision|journal=ACM Transactions on Graphics|date=1 July 1987|volume=6|issue=3|pages=167–190|doi=10.1145/35068.35069|citeseerx=10.1.1.21.3719}} 4. ^1 {{cite book|last1=Peitgen|first1=Heinz-Otto, Dietmar Saupe|title=The Science of fractal images|date=1988|publisher=Springer-Verlag|location=New York|isbn=978-0-387-96608-3}} External links
3 : Fractals|Computer graphics algorithms|Procedural generation |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。