@@ -1118,54 +1118,112 @@ A box of a regular node would look like:
1118
1118
1119
1119
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
1120
1120
1121
+ Perlin noise
1122
+ ------------
1123
+ Perlin noise creates a continuously-varying value depending on the input values.
1124
+ Usually in Minetest the input values are either 2D or 3D co-ordinates in nodes.
1125
+ The result is used during map generation to create the terrain shape, vary heat
1126
+ and humidity to distribute biomes, vary the density of decorations or vary the
1127
+ structure of ores.
1128
+
1129
+ ### Structure of perlin noise
1130
+ An 'octave' is a simple noise generator that outputs a value between -1 and 1.
1131
+ The smooth wavy noise it generates has a single characteristic scale, almost
1132
+ like a 'wavelength', so on its own does not create fine detail.
1133
+ Due to this perlin noise combines several octaves to create variation on
1134
+ multiple scales. Each additional octave has a smaller 'wavelength' than the
1135
+ previous.
1136
+
1137
+ This combination results in noise varying very roughly between -2.0 and 2.0 and
1138
+ with an average value of 0.0, so `scale` and `offset` are then used to multiply
1139
+ and offset the noise variation.
1140
+
1141
+ The final perlin noise variation is created as follows:
1142
+
1143
+ noise = offset + scale * (octave1 +
1144
+ octave2 * persistence +
1145
+ octave3 * persistence ^ 2 +
1146
+ octave4 * persistence ^ 3 +
1147
+ ...)
1148
+
1121
1149
Noise Parameters
1122
1150
----------------
1123
- Noise Parameters, or commonly called "`NoiseParams`", define the properties of
1124
- perlin noise.
1151
+ Noise Parameters are commonly called `NoiseParams`.
1125
1152
1126
1153
### `offset`
1127
- Offset that the noise is translated by (i.e. added) after calculation.
1154
+ After the multiplication by `scale` this is added to the result and is the final
1155
+ step in creating the noise value.
1156
+ Can be positive or negative.
1128
1157
1129
1158
### `scale`
1130
- Factor that the noise is scaled by (i.e. multiplied) after calculation.
1159
+ Once all octaves have been combined, the result is multiplied by this.
1160
+ Can be positive or negative.
1131
1161
1132
1162
### `spread`
1133
- Vector containing values by which each coordinate is divided by before
1134
- calculation.
1135
- Higher spread values result in larger noise features.
1163
+ For octave1, this is roughly the change of input value needed for a very large
1164
+ variation in the noise value generated by octave1. It is almost like a
1165
+ 'wavelength' for the wavy noise variation.
1166
+ Each additional octave has a 'wavelength' that is smaller than the previous
1167
+ octave, to create finer detail. `spread` will therefore roughly be the typical
1168
+ size of the largest structures in the final noise variation.
1136
1169
1137
- A value of `{x=250, y=250, z=250}` is common.
1170
+ `spread` is a vector with values for x, y, z to allow the noise variation to be
1171
+ stretched or compressed in the desired axes.
1172
+ Values are positive numbers.
1138
1173
1139
1174
### `seed`
1140
- Random seed for the noise. Add the world seed to a seed offset for world-unique
1141
- noise. In the case of `minetest.get_perlin()`, this value has the world seed
1142
- automatically added.
1175
+ This is a whole number that determines the entire pattern of the noise
1176
+ variation. Altering it enables different noise patterns to be created.
1177
+ With other parameters equal, different seeds produce different noise patterns
1178
+ and identical seeds produce identical noise patterns.
1143
1179
1144
- ### `octaves`
1145
- Number of times the noise gradient is accumulated into the noise.
1180
+ For this parameter you can randomly choose any whole number. Usually it is
1181
+ preferable for this to be different from other seeds, but sometimes it is useful
1182
+ to be able to create identical noise patterns.
1146
1183
1147
- Increase this number to increase the amount of detail in the resulting noise.
1184
+ When used in mapgen this is actually a 'seed offset', it is added to the
1185
+ 'world seed' to create the seed used by the noise, to ensure the noise has a
1186
+ different pattern in different worlds.
1148
1187
1149
- A value of `6` is common.
1188
+ ### `octaves`
1189
+ The number of simple noise generators that are combined.
1190
+ A whole number, 1 or more.
1191
+ Each additional octave adds finer detail to the noise but also increases the
1192
+ noise calculation load.
1193
+ 3 is a typical minimum for a high quality, complex and natural-looking noise
1194
+ variation. 1 octave has a slight 'gridlike' appearence.
1195
+
1196
+ Choose the number of octaves according to the `spread` and `lacunarity`, and the
1197
+ size of the finest detail you require. For example:
1198
+ if `spread` is 512 nodes, `lacunarity` is 2.0 and finest detail required is 16
1199
+ nodes, octaves will be 6 because the 'wavelengths' of the octaves will be
1200
+ 512, 256, 128, 64, 32, 16 nodes.
1150
1201
1151
1202
### `persistence`
1152
- Factor by which the effect of the noise gradient function changes with each
1153
- successive octave.
1154
-
1155
- Values less than `1` make the details of successive octaves' noise diminish,
1156
- while values greater than `1` make successive octaves stronger.
1157
-
1158
- A value of `0.6` is common.
1203
+ Each additional octave has an amplitude that is the amplitude of the previous
1204
+ octave multiplied by `persistence`, to reduce the amplitude of finer details,
1205
+ as is often helpful and natural to do so.
1206
+ Since this controls the balance of fine detail to large-scale detail
1207
+ `persistence` can be thought of as the 'roughness' of the noise.
1208
+
1209
+ A positive or negative non-zero number, often between 0.3 and 1.0.
1210
+ A common medium value is 0.5, such that each octave has half the amplitude of
1211
+ the previous octave.
1212
+ This may need to be tuned when altering `lacunarity`; when doing so consider
1213
+ that a common medium value is 1 / lacunarity.
1159
1214
1160
1215
### `lacunarity`
1161
- Factor by which the noise feature sizes change with each successive octave.
1216
+ Each additional octave has a 'wavelength' that is the 'wavelength' of the
1217
+ previous octave multiplied by 1 / lacunarity, to create finer detail.
1218
+ 'lacunarity' is often 2.0 so 'wavelength' often halves per octave.
1162
1219
1163
- A value of `2.0` is common.
1220
+ A positive number no smaller than 1.0.
1221
+ Values below 2.0 create higher quality noise at the expense of requiring more
1222
+ octaves to cover a paticular range of 'wavelengths'.
1164
1223
1165
1224
### `flags`
1166
1225
Leave this field unset for no special handling.
1167
-
1168
- Currently supported are `defaults`, `eased` and `absvalue`.
1226
+ Currently supported are `defaults`, `eased` and `absvalue`:
1169
1227
1170
1228
#### `defaults`
1171
1229
Specify this if you would like to keep auto-selection of eased/not-eased while
@@ -1174,28 +1232,39 @@ specifying some other flags.
1174
1232
#### `eased`
1175
1233
Maps noise gradient values onto a quintic S-curve before performing
1176
1234
interpolation. This results in smooth, rolling noise.
1177
- Disable this (`noeased`) for sharp-looking noise.
1235
+ Disable this (`noeased`) for sharp-looking noise with a slightly gridded
1236
+ appearence.
1178
1237
If no flags are specified (or defaults is), 2D noise is eased and 3D noise is
1179
1238
not eased.
1239
+ Easing a 3D noise significantly increases the noise calculation load, so use
1240
+ with restraint.
1180
1241
1181
1242
#### `absvalue`
1182
- Accumulates the absolute value of each noise gradient result.
1243
+ The absolute value of each octave's noise variation is used when combining the
1244
+ octaves. The final perlin noise variation is created as follows:
1183
1245
1184
- Noise parameters format example for 2D or 3D perlin noise or perlin noise maps:
1246
+ noise = offset + scale * (abs(octave1) +
1247
+ abs(octave2) * persistence +
1248
+ abs(octave3) * persistence ^ 2 +
1249
+ abs(octave4) * persistence ^ 3 +
1250
+ ...)
1251
+
1252
+ ###Format example
1253
+ For 2D or 3D perlin noise or perlin noise maps:
1185
1254
1186
1255
np_terrain = {
1187
1256
offset = 0,
1188
1257
scale = 1,
1189
- spread = {x= 500, y= 500, z= 500},
1258
+ spread = {x = 500, y = 500, z = 500},
1190
1259
seed = 571347,
1191
1260
octaves = 5,
1192
1261
persist = 0.63,
1193
1262
lacunarity = 2.0,
1194
- flags = "defaults, absvalue"
1263
+ flags = "defaults, absvalue",
1195
1264
}
1196
- ^ A single noise parameter table can be used to get 2D or 3D noise,
1197
- when getting 2D noise spread.z is ignored.
1198
1265
1266
+ For 2D noise the Z component of `spread` is still defined but is ignored.
1267
+ A single noise parameter table can be used for 2D or 3D noise.
1199
1268
1200
1269
Ore types
1201
1270
---------
@@ -1268,6 +1337,7 @@ The following is a decent set of parameters to work from:
1268
1337
seed = 5390,
1269
1338
octaves = 4,
1270
1339
persist = 0.5,
1340
+ lacunarity = 2.0,
1271
1341
flags = "eased",
1272
1342
},
1273
1343
noise_threshold = 1.6
0 commit comments