8 implementation |
8 implementation |
9 uses uVariables |
9 uses uVariables |
10 , uConsts |
10 , uConsts |
11 , uRandom |
11 , uRandom |
12 , uLandOutline // FillLand |
12 , uLandOutline // FillLand |
|
13 , uUtils |
13 ; |
14 ; |
14 |
15 |
15 var p: array[0..511] of LongInt; |
16 var p: array[0..511] of LongInt; |
16 |
17 |
17 const fadear: array[byte] of LongInt = |
18 const fadear: array[byte] of LongInt = |
18 (0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 3, 4, 6, 7, 9, 10, 12, |
19 (0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 3, 4, 6, 7, 9, 10, 12, |
19 14, 17, 19, 22, 25, 29, 32, 36, 40, 45, 49, 54, 60, 65, 71, |
20 14, 17, 19, 22, 25, 29, 32, 36, 40, 45, 49, 54, 60, 65, 71, |
20 77, 84, 91, 98, 105, 113, 121, 130, 139, 148, 158, 167, 178, |
21 77, 84, 91, 98, 105, 113, 121, 130, 139, 148, 158, 167, 178, |
21 188, 199, 211, 222, 234, 247, 259, 273, 286, 300, 314, 329, 344, |
22 188, 199, 211, 222, 234, 247, 259, 273, 286, 300, 314, 329, 344, |
22 359, 374, 390, 407, 424, 441, 458, 476, 494, 512, 531, 550, |
23 359, 374, 390, 407, 424, 441, 458, 476, 494, 512, 531, 550, |
41 function fade(t: LongInt) : LongInt; inline; |
42 function fade(t: LongInt) : LongInt; inline; |
42 var t0, t1: LongInt; |
43 var t0, t1: LongInt; |
43 begin |
44 begin |
44 t0:= fadear[t shr 8]; |
45 t0:= fadear[t shr 8]; |
45 |
46 |
46 if t0 = fadear[255] then |
47 if t0 = fadear[255] then |
47 t1:= t0 |
48 t1:= t0 |
48 else |
49 else |
49 t1:= fadear[t shr 8 + 1]; |
50 t1:= fadear[t shr 8 + 1]; |
50 |
51 |
51 fade:= t0 + ((t and 255) * (t1 - t0) shr 8) |
52 fade:= t0 + ((t and 255) * (t1 - t0) shr 8) |
52 end; |
53 end; |
53 |
54 |
54 |
55 |
55 function lerp(t, a, b: LongInt) : LongInt; inline; |
56 function lerp(t, a, b: LongInt) : LongInt; inline; |
56 begin |
57 begin |
57 lerp:= a + (Int64(b - a) * t shr 12) |
58 lerp:= a + ((Int64(b) - a) * t shr 12) |
58 end; |
59 end; |
59 |
60 |
60 |
61 |
61 function grad(hash, x, y: LongInt) : LongInt; inline; |
62 function grad(hash, x, y: LongInt) : LongInt; inline; |
62 var h, v, u: LongInt; |
63 var h, v, u: LongInt; |
118 |
119 |
119 for i:= 0 to 255 do |
120 for i:= 0 to 255 do |
120 p[256 + i]:= p[i]; |
121 p[256 + i]:= p[i]; |
121 end; |
122 end; |
122 |
123 |
123 const detail = 150000; |
124 const width = 4096; |
124 width = 4096; |
125 height = 2048; |
125 height = 2048; |
126 minY = 500; |
126 minY = 500; |
|
127 |
127 |
128 //bottomPlateHeight = 90; |
128 //bottomPlateHeight = 90; |
129 //bottomPlateMargin = 1200; |
129 //bottomPlateMargin = 1200; |
130 margin = 200; |
130 margin = 200; |
131 |
131 |
132 procedure GenPerlin; |
132 procedure GenPerlin; |
133 var y, x, {dy, }di, dj, df, r, param1, param2: LongInt; |
133 var y, x, {dy, }di, dj, df, r, param1, param2, rCutoff, detail: LongInt; |
134 begin |
134 begin |
135 param1:= cTemplateFilter div 3; |
135 param1:= cTemplateFilter div 3; |
136 param2:= cTemplateFilter mod 3; |
136 param2:= cTemplateFilter mod 3; |
|
137 rCutoff:= min(max((26-cFeatureSize)*4,15),85); |
|
138 detail:= (26-cFeatureSize)*16000+50000; // feature size is a slider from 1-25 at present. flip it for perlin |
137 |
139 |
138 df:= detail * (6 - param2 * 2); |
140 df:= detail * (6 - param2 * 2); |
139 |
141 |
140 inoise_setup(); |
142 inoise_setup(); |
141 |
143 |