




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、County continuation records has examined and approved the draft, spirit, believe, comprehensive Yearbook of zhuanglang already prepared draft, entered the phase of evaluation. Civil air defense workPAGE County continuation records has examined and approved the draft, spirit, believe, comprehensive Y
2、earbook of zhuanglang already prepared draft, entered the phase of evaluation. Civil air defense workPAGE 6County continuation records has examined and approved the draft, spirit, believe, comprehensive Yearbook of zhuanglang already prepared draft, entered the phase of evaluation. Civil air defense
3、 workGenerating Random Fractal TerrainPart I: Generating Random Fractal TerrainIntroduction Ten years ago, I stumbled across the 1986 SIGGRAPH Proceedings and was awestruck by one paper in particular, entitled The Definition and Rendering of Terrain Maps by Gavin S. P. Miller 1 . It described a hand
4、ful of algorithms for generating fractal terrain, and the authors also introduce a new method which they considered to be an improvement.Initially I was impressed that these algorithms (even the algorithms considered flawed by the authors) could create such incredible landscape images! Then, upon re
5、ading the paper, I was floored by the simplicity of these algorithms.Ive been a fractal terrain addict ever since.The math behind the algorithm can get quite complex. However, completely understanding the math is not a prerequisite for grasping the algorithm. And thats good. Because if I had to expl
6、ain all the math to you before explaining the algorithm, wed never get to the algorithm. Besides, there is literally tons of material out there on the mathematical concepts involved in fractals. See the references at the end of this article for a good start.For the same reasons that I wont go into t
7、he math details, I cant include a broad overview of fractals and everything they can be used for. Instead, Im going describe the concepts behind fractal terrain generation, and give a focused and detailed description of my personal favorite algorithm: the diamond-square algorithm. Ill demonstrate ho
8、w to use this algorithm to statically tessellate an array of height data that can be used for geometric terrain data, terrain texture maps, and cloud texture maps.What can you do with a fractal terrain? I assume you already know that; thats why youre reading this. Random terrain maps are great for f
9、light simulators or making texture maps to use as a background (showing a distant mountain range, for example). The same algorithm that makes terrain can also be used to generate texture maps for partly cloudy skies.Before I go further, a disclaimer: I am not a game programmer. If you are reading th
10、is because you want algorithms for rendering terrain quickly, youve come to the wrong place. Ill only describe the process of generating the terrain model. How you render it is up to you.Self-Similarity The key concept behind any fractal is self-similarity. An object is said to be self-similar when
11、magnified subsets of the object look like (or identical to) the whole and to each other.2 Consider the human circulatory system. This is a fine example of self-similarity in nature. The same branching pattern is exhibited from the largest arteries and veins all the way down to the smallest capillari
12、es. If you didnt know you were using a microscope, you wouldnt be able to tell the difference between capillaries and arteries.Now consider a simple sphere. Is it self-similar? No. At significantly large magnification, it stops looking like a sphere altogether and starts looking like a flat plane. I
13、f you dont believe me, just take a look outside. Unless you happen to be in orbit while reading this, youll see no indication that the Earth is a sphere. A sphere is not self-similar. It is best described using traditional Euclidean geometry, rather than a fractal algorithm.Terrain falls into the se
14、lf-similar category. The jagged edge of a broken rock in the palm of your hand has the same irregularities as a ridgeline on a distant horizon. This allows us to use fractals to generate terrain which still looks like terrain, regardless of the scale in which it is displayed.A side note on self-simi
15、larity: In its strictest sense, it means self-identical, that is, exact miniature copies of itself are visible at increasingly small or large scales. I actually dont know of any self-identical fractals that exist in nature. But the Mandelbrot set is self-identical. I wont even go into describing the
16、 Mandelbrot set. Go dig up any of the references for more info.Midpoint Displacement in One Dimension The diamond-square algorithm, which I will describe later, uses a kind of midpoint-displacement algorithm in two dimensions. To help you get a grip on it, well look at it first in one dimension. One
17、-dimensional midpoint displacement is a great algorithm for drawing a ridgeline, as mountains might appear on a distant horizon. Heres how it works:Start with a single horizontal line segment.Repeat for a sufficiently large number of times Repeat over each line segment in the scene Find the midpoint
18、 of the line segment. Displace the midpoint in Y by a random amount. Reduce the range for random numbers. How much do you reduce the random number range? That depends on how rough you want your fractal. The more you reduce it each pass through the loop, the smoother the resulting ridgeline will be.
19、If you dont reduce the range very much, the resulting ridgeline will be very jagged. It turns out you can tie roughness to a constant; Ill explain how to do this later on.Lets look at an example. Here, we start with a line from -1.0 to 1.0 in X, with the Y value at each endpoint being zero. Initiall
20、y well set the random number range to be from -1.0 to 1.0 (arbitrary). So we generate a random number in that range, and displace the midpoint by that amount. After doing this, we have: Now the second time through the outer loop, we have two segments, each half the length of the original segment. Ou
21、r random number range is reduced by half, so it is now -0.5 to 0.5. We generate a random number in this range for each of the two midpoints. Heres the result:We shrink the range again; it is now -0.25 to 0.25. After displacing the four midpoints with random numbers in this range, we have:Two things
22、you should note about this.First, its recursive. Actually, it can be implemented quite naturally as an iterative routine. For this case, either recursive or iterative would do. It turns out that for the surface generation code, there are some advantages to using an iterative implementation over a re
23、cursive one. So for consistency, the accompanying sample code implements both the line and surface code as iterative.Second, its a very simple algorithm, yet it creates a very complex result. That is the beauty of fractal algorithms. A few simple instructions can create a very rich and detailed imag
24、e.Here I go off on a tangent: The realization that a small, simple set of instructions can create a complex image has lead to research in a new field known as fractal image compression. The idea is to store the simple, recursive instructions for creating the image rather than storing the image itsel
25、f. This works great for images which are truly fractal in nature, since the instructions take up much less space than the image itself. Chaos and Fractals, New Frontiers of Science 3 has a chapter and an appendix devoted to this topic and is a great read for any fractal nut in general.Back to realit
26、y.Without much effort, you can read the output of this function into a paint program and come up with something like this:This could be used as scenery outside a window, for example. The nice thing about it is that it wraps, so you can keep around one relatively small image and completely wrap a sce
27、ne with it. That is, if you dont mind seeing the same mountain in every direction.OK, before we go into 2D fractal surfaces, you need to know about the roughness constant. This is the value which will determine how much the random number range is reduced each time through the loop and, therefore, wi
28、ll determine the roughness of the resulting fractal. The sample code uses a floating-point number in the range 0.0 to 1.0 and calls it H. 2(-H) is therefore a number in the range 1.0 (for small H) to 0.5 (for large H). The random number range can be multiplied by this amount each time through the lo
29、op. With H set to 1.0, the random number range will be halved each time through the loop, resulting in a very smooth fractal. With H set to 0.0, the range will not be reduced at all, resulting in something quite jagged.Here are three ridgelines, each rendered with varying H valuesHeight MapsThe midp
30、oint displacement algorithm described above can be implemented using a one-dimensional array of height values which indicate the vertical location of each line segment vertex. This array is a one-dimensional height map. It maps its indices (X values) to height values (Y values).To simulate random te
31、rrain, we want to extrapolate this algorithm into 3D space, and to do so we need a two-dimensional array of height values which will map indices (X and Z values) into height values (Y values). Note that although our end goal here is to generate three-dimensional coordinates, the array only needs to
32、store the height (Y) values; the horizontal (X and Z) values can be generated on the fly as we parse through the array.By assigning a color to each height value, you could display a height map as an image. Here, high points in the terrain (large values) are represented by white, and low points (smal
33、l values) are represented by black:Rendering a height map this way is useful for generating cloud texture maps, which Ill discuss later. Such a representation could also be used to seed a height map.中文譯文:隨機分形地形的生成第一部分:生成隨機分形地形介紹十年前,我參加 1986 年 SIGGRAPH 活動, Gavin S. P. Miller 那篇題為 Definition and Rende
34、ring of Terrain Maps 的論文讓我充滿敬畏。該文描述了少數(shù)生成分形地形的算法,作者還介紹了一個他們認為更先進的新方法。開始我被這些算法能夠生成難以置信的風景圖所震驚?。ūM管這些算法被作者認為“漏洞百出”)后來,讀過論文,這些算法之簡單將我完全打敗了。我從此成為一個分形地形迷。算法背后的數(shù)學可能相當復雜。然而,完全理解這些數(shù)學并不是掌握這些算法的必要條件。很好,否則我得在解釋算法之前講解所有的數(shù),也許永遠也講不到算法。此外,關于分形數(shù)學的文字材料數(shù)以噸計,參見本文本的參考部分會有所幫助。同樣的原因,我不會深入到數(shù)學細節(jié),也不包括對分形的廣泛總覽及它們可被用來做的每樣東西。相反,
35、我將描述分形地形生成背后的概念,并集中仔細講解我個人最喜歡的 ”diamond-square” 算法。我將演示如何使用這個算法靜態(tài)拼嵌高度數(shù)據數(shù)組,這些數(shù)據可用于幾何地形數(shù)據、地形紋理數(shù)據及云紋理映射。分形有什么用呢?假定你已經知道,那正是你讀本文的原因。隨機地形圖對飛行模擬或制作背景紋理圖(如顯示一帶遠山)十分有用。生成地形的算法也可用于生成部分云天的紋理圖。在繼續(xù)之前,申明一下:我不是游戲程序員。如果你為找到一個快速繪制地形的算法而讀此文,那你來錯了地方。我只描述生成地形模型的過程。著色繪制是你自己的事。自相似任何分形最關鍵的概念是自相似。當一個物體的一部分放大后看起來仍與整個物體一樣,那
36、這個物體就是自相似??紤]一下人體的循環(huán)系統(tǒng)。這是自然界中自相似的好例子。從最大的動脈和靜脈分支直到最小的微血管,整個過程都顯現(xiàn)相同的分支模式。如果你不知道正在使用顯微鏡,將無法分辨微血管和大動脈?,F(xiàn)在再考慮一個簡單的球。它是自相似的嗎?不!大幅度放大后,它看起來不再象一個球,而象塊平板。如果你不相信,看看戶外。除非恰好你在太空軌道上看本文,否則將完全沒法看出地球是個球體。球體不是自相似的。它適用傳統(tǒng)的歐幾里德幾何描述而不是分形。地形屬于自相似范疇。手掌上的碎巖鋸齒狀邊緣與遠處地平線邊的山脊有相同的不規(guī)則形狀。這使我們可以用分形來生成地形,不管顯示時怎么放大,它看起來仍然象地面。有關自相似請注意
37、:嚴格意義下,它意味著自分辨 (self-identical) ,即,自身精確的縮略拷貝在逐漸放大縮小時可見。我并不知道自然界存在任何自分辨分形。但 mandelbrot 集是自分辨的。我不會進一步討論 Mandelbrot 集。到參考里找進一步的信息。一維中點變換后邊要講的 diamond-square 算法,在兩維上使用一種中點變換算法。為幫助你了解個大概,我們先看一維情況。當山脈出現(xiàn)在遠處地平線處時,一維中點變換是繪制山脊的好算法??纯此窃趺垂ぷ鞯模阂砸粭l水平地平線段開始重復足夠多次對場景中的每條線段做找到線段的中點在 Y 方向上隨機移動中點一段距離減小隨機數(shù)取值范圍將隨機數(shù)值域減速小多少呢?那取決于你想要分形的陡峭程度。每次循環(huán)減少的越多,所得山脊線就越平滑。但如果減得太多,則會有明顯的鋸齒感。可以粗糙度存在一個常量里。后面會解釋如何做。來
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 江蘇省淮安市四星級高中2024-2025學年高三下學期第一次質量抽測歷史試題含解析
- 遼寧省大連大世界高中2024-2025學年高考全國卷信息歸集與高考命題預測歷史試題含解析
- 山東省濟寧市泗水縣重點中學2025屆中考適應性考試語文試題試卷含解析
- 未來汽車行業(yè)技術能力測試題及答案
- 安全隱患治理及管理的實踐案例分析試題及答案
- 船舶機艙考試題及答案
- 小兒糖尿病試題及答案
- 新能源汽車產業(yè)鏈中的合作與競爭研究試題及答案
- 安全工程師考試行業(yè)變化與趨勢考題研究試題及答案
- 疾病算命測試題及答案
- 【2025二輪復習】讀后續(xù)寫專題
- 商品房門窗加工合同協(xié)議
- 四年級下冊數(shù)學口算練習題
- 《超重康復之道》課件
- 建筑圖紙識圖培訓
- 飛行員勞動合同模板及條款
- 第中西藝術時空對話 課件 2024-2025學年嶺南美版(2024) 初中美術七年級下冊
- 高氧潛水考試題及答案
- 2025年二級建造師之二建礦業(yè)工程實務通關考試題庫帶答案解析
- (四調)武漢市2025屆高中畢業(yè)生四月調研考試 物理試卷(含答案)
- 盲醫(yī)考試題及答案
評論
0/150
提交評論