Version 1.0.3
[minetest_perlin_explorer.git] / README.md
blobabb42f08ddaaf6f3c7a5cc872b23dff495dc80a7
1 # Perlin Explorer [`perlin_explorer`]
3 Version: 1.0.3
5 Perlin Explorer is a mod for Minetest to allow to test and experiment around with Perlin noises.
7 This is especially useful for game and mod developers who want to fine-tune the noises in an
8 efficient manner. It’s also useful to discover useful noise parameters for the various
9 mapgen settings in Minetest.
11 This mod uses Minetest’s builtin Perlin noise, so the same rules apply here.
12 Refer to Minetest’s documentation to learn about noise parameters.
14 ## /!\ WARNING WARNING WARNING /!\
16 This mod can aggressively **grief** your world due to its
17 mapgen feature! Don’t use it in worlds with buildings
18 you care about.
20 **NEVER** use this mod on a public server, it has not been
21 security-tested.
23 ## Features
25 * Powerful noise parameter editor to quickly adjust parameters
26 * Look up Perlin noise value at a given position
27 * Special nodes to represent noise values
28         * Color denotes value, cutoff points can be customized
29         * Choose between solid nodes, transparent grid nodes, and tiny climbable cube nodes
30 * Generate a small portion of the noise as map at a given area
31 * Enable “mapgen mode” to automatically generate nodes as you move around
32 * Load predefined Perlin noises from the Minetest configuration
33 * Save noise parameters into profiles for later use
34 * Mathematical and statistical analysis of noises
36 ## Usage
37 ### Before you begin
38 This document assumes you already have a rough understanding of what
39 Perlin noises are used for.
41 To use this mod, create a brand new world to avoid accidents.
43 Everything in this mod requires the `server` privilege, so obtain
44 this privilege as well.
46 ### Overview
47 The main feature and tool in this mod is the Perlin Noise Creator. Using
48 this item opens a window in which you can view, modify, analyze and
49 manage noise parameters, generate nodes and perform some basic
50 analysis.
52 ### What are noise parameters?
53 These are used by Minetest for the Perlin noises.
54 Perlin noises are used for various things such as generating the world,
55 decorations (trees, plants, etc.), ores, biomes and much more.
57 And noise parameters are, well, the parameters that are used
58 to tweak the Perlin noises. They change the output numbers,
59 they stretch or squeeze the noise, they make more or less
60 detailed, and more.
62 The Perlin Explorer mod’s main use case is to allow you to
63 try out various parameters and to modify them in a quick
64 manner so you can quickly get results. This is much more
65 efficient than tweaking the noise in the Minetest settings
66 or Lua code.
68 This document is *not* an introduction to Perlin noises
69 and noise parameters themselves! Please refer to the Minetest
70 Lua API documentation to learn more.
72 ### Active noise
73 This mod heavily relies on something called the “active noise”
74 (or “active noise parameters”). These are the noise parameters
75 and options that the mod will use for various operations, like
76 getting values, generating nodes, using mapgen mode, etc. The “Apply” button
77 in the Perlin Noise Creator tool sets the active noise.
78 There can only be one active noise parameters. Also, the active
79 noise is always valid; if you enter invalid noise parameters,
80 the mod refuses them for the active noise.
82 Initially, there are no active noise parameters, so you have
83 to push the “Apply” button mentioned before first.
85 ### The tools
86 This section explains the various tools you have at your disposal.
87 These tools are items, so check out your Creative Inventory
88 (or something similar) to get them.
90 #### Perlin Noise Creator
91 This is the main tool of this mod. Hold this item in hand and punch
92 to open a window.
94 The window has multiple sections:
96 * Noise parameters: You specify noise parameters here
97 * Noise options: This is how the noise parameters are being interpreted
98 * Node generation: Stuff you need to specify when you want to generate
99   a chunk (or chunks) of nodes
101 ##### Noise parameters
103 This section has 2 parts: The top part is a list of profiles.
104 An explanation for that is below.
106 The bottom part contains the actual noise parameters:
108 * Offset
109 * Scale
110 * Seed
111 * X/Y/Z Spread
112 * Octaves
113 * Persistence
114 * Lacunarity
115 * Flags (defaults, eased, absvalue)
117 Please refer to Minetest Lua API documentation for a definition.
118 This mod enforces a few sanity checks on some for the values,
119 i.e. octaves can’t be lower than 1.
121 **Hint**: If you hit “Enter” while the focus is on any of the noise
122 parameters, this is the same as if you clicked “Accept” or “Accept
123 and create” (see below). Use this to your advantage to quickly
124 tweak a particular value.
126 The little dice button randomizes the seed, it’s a simple
127 convenience.
129 The “Analyze” button shows you some basic info about the
130 noise parameters as displayed in the form. First, the
131 theoretical minimum and maximum possible value
132 of the entire noise.
133 Then, the “wavelengths” for each axis. This means across
134 how many nodes (roughly) the noise is stretched out, specified
135 for each octave, beginning with the first.
136 If any wavelength reaches a number lower than 1, it will be
137 shown in red because this means your noise parameters are invalid.
138 If this happens, either increase the spread or decrease the octaves
139 or lacunarity.
141 **Note**: The Analyze feature uses the noise parameters as they
142 are displayed in the form, *not* the *active* noise parameters.
143 This is because the active noise must always be valid.
145 ###### Profiles
146 A profile is just noise parameters that you can load for later use.
147 It’s a convenience feature.
148 The drop-down list to the left is the list of all profiles.
149 This list contains three types of profiles:
151 * Active noise parameters: Special profile that represents
152   the currently active noise. Can not be deleted.
153 * Builtin profiles are the noise parameters
154   of the official Minetest mapgens, loaded from settings.
155   Their name always begins with `mg_`
156   Can not be deleted.
157 * User profiles: These are your profiles, you can
158   add and remove them at will. These are named like
159   “Profile 1”
161 User profiles will also automatically saved on disk so they
162 get restored when restarting the world.
164 The buttons do the following:
166 * Add: Save the current noise parameters into a new user profile
167 * Load: Load the currently selected profile and replace the
168         input fields
169 * Delete: Delete the currently selected user profile (not possible
170           for non-user profiles)
172 ##### Noise options
173 This section roughly says how the noise parameters are “interpreted”.
174 These fields are available:
176 * Number of dimensions (2D or 3D)
177     * 2D: Noise is 2-dimensional. In the world, only the X and Z
178       coordinates are used. The Y coordinate is ignored.
179     * 3D: Noise uses the same 3 dimensions as the Minetest world,
180       with X, Y and Z coordinates.
181 * Pixelization: If this number is higher than 1, the noise values
182   will be repeated for this number of nodes, along every axis.
183   This gives a “pixelized”/“voxelized” look. You normally don’t need
184   this but it’s useful to emulate the `sidelen` parameter of
185   mapgen decorations (relevant for game development)
186 * Statistics: Will calculate tons of values (without generating
187   nodes) in a predefined area/volume to make some statistics. This
188   will take a while to do so.
189   The main feature is a histogram which shows which values were the most
190   common. The first row shows the percentage, the 2nd and 3rd row show
191   the maximum and minimum value of that column. For example,
192   if the column says “31.4%”, “0.0” for “Max.” and “-4.2” for “Min.” that means
193   that 31.4% of all values that were calculated were greater than or equal
194   to -4.2, but smaller than 0.
195   The statistics always distributes the values into “buckets” of
196   equal sizes, beginning with the lowest theoretical value and
197   ending with the highest one.
198   The histogram is useful if you want to see how common or rare
199   each value is.
200   **Note**: This button will calculate statistics of the noise settings
201   as they were displayed in the form. It does *not* use the active noise.
203 ##### Node generation
205 Playing around with parameters isn’t very useful if you don’t
206 get a visual result. That’s where the node generation comes
207 into play. Here you specify parameters for generating nodes
208 from the noise.
209 All noise values are either high or low; they are divided
210 by the **midpoint**: Values equal to or higher than the
211 midpoint are high, otherwise low.
213 In 2D mode, the mapgen will be a flat XZ plane with nodes.
215 In 3D mode, the mapgen will place nodes at every position
216 in the 3D world.
218 ###### Build modes
220 The drop-down list to the bottom right stands for the
221 “build modes”. This sets for which noise values nodes
222 will be generated:
224 * Auto: In 2D mode, generate nodes for every value,
225         in 3D mode, only generate nodes for high values
226 * All: Generate nodes for every value
227 * High only: Only generate nodes for high values
228 * Low only: Only generate nodes for low values
230 ###### Node visualization
232 Generated nodes will be color-coded, which stands for the value:
234 * White to yellow to orange: High values
235 * Light blue to blue (with a small dot): Low values
237 There are two parameters:
239 * Low color at: The lowest noise value at which the
240   color gradient for low noise values begins.
241 * High color at: The highest noise value at which the
242   color gradient for high noise values ends.
244 The low color gradient begins at the “Low color at”
245 setting and ends right before the the midpoint.
246 The high color gradient begins at the midpoint
247 and ends at the ”High color at” setting.
249 For example, if 0 is the midpoint, and the “low/high color”
250 settings are -1 and 1, respectively, all values below 0 (the
251 midpoint) will use the ‘low values’ color gradient and all
252 values above 0 will use the ‘high values’ color gradient.
253 All values at -1 and below will have the “extreme low”
254 color (dark blue) and all values at 1 or above will have the
255 “extreme high” (orange) color.
256 Note that the colors only serve as a visual aid and
257 given the limited palette, is only an estimation
258 of the noise values. You can always use the Perlin Value
259 Getter for the exact values.
260 If you have problems seeing color differences, activate
261 the grayscale color palette in the mod settings.
263 ###### Node types
265 Right to the color settings, there is a list of node types.
266 This is for different node styles for different
267 noise visualizations:
269 * Solid Nodes: Simple, solid, opaque cubes
270 * Grid Nodes: Solid see-through nodes (like glass)
271 * Minibox Nodes: See-thorough nodes, but smaller. You can also
272   walk and climb up on down in these
273 * Stone: Places stone for high values, air otherwise.
274   This uses the stone node from the game (if it supports it).
276 Solid Nodes are recommend to use normally.
278 Grid or Minibox nodes can be useful in 3D mode if you want to
279 expose the inner structure of complex 3D noises. This can be quite
280 trippy and reduce your FPS sharply, so consider reducing the
281 render distance.
283 ###### Position settings
285 The following settings are only used when you want
286 to place nodes in a certain area:
288 * X, Y, Z: Coordinates of the bottom left front corner if you
289  want to generate an area manually with “Apply and create”
290 * Size: Side length of the square or cube of the area/volume
291   to generate, if you generate it with “Apply and create”.
292   **ATTENTION:** Don’t make this value too large
293   (especially in 3D), otherwise map generation
294   will take forever and the game freezes.
296 #### Footer (Apply / Apply and close / Enable mapgen / Disable mapgen)
298 The footer is the final part of the form. It has these buttons:
300 * Apply: Set the current noise params as the “active noise”. If the
301   mapgen is active, it will automatically update the world around
302   players
303 * Apply and create: Generate some nodes at the specified XYZ coordinates
304   with the specified size (see Position settings above)
305 * Enable mapgen: Enable the mapgen mode. In mapgen mode, nodes will
306   automatically be generated according to the settings around players.
307   This allows you to actually *explore* a world.
308   When a new part of the world is created, a little star icon will
309   appear in its center to show you this part is new.
310   Note: When mapgen mode is enabled, the XYZ, size and “Apply and create”
311   buttons disappear because those are for single generations.
312   Note: If you modify the noise parameters and hit “Accept”, the mapgen
313   will automatically update.
314 * Disable mapgen: Disables the mapgen again. The “XYZ”, “Size”
315   and “Apply and create” will appear again.
317 ### Perlin Value Getter
318 This item tells you the (nearly) exact value of the current active
319 noise parameters at a given position. You can use it on nodes
320 and in mid-air.
322 Use the “Place” key on a node to get the value of the node position.
323 Use the “Punch” key anywhere to get the value of *your* position (rounded).
324 If you hold down “Sneak” while punching, your *exact* position (not rounded)
325 will be used instead.
327 **Note**: This tool always calculates the values of the *active noise*
328 It completely ignores whatever nodes were generated and what those nodes
329 represents, so tool also works if you haven’t generated any nodes.
330 It actually only looks at the coordinates of the node or yourself.
331 If you’re unsure about what the current active noise is, just hit “Accept” again
332 in the Perlin Noise Creator.
334 ### Random Perlin seed setter
336 This is just a convenience item. Using it is the same as opening the Perlin Noise
337 Creator, changing the seed and accepting.
339 In mapgen mode, punching or placing will set a new seed only, but the mapgen
340 will then instantly update the map.
342 If mapgen mode is disabled, the meaning of this tool is this:
344 * Punch: Set a new seed of the active noise, but do not regenerate map
345 * Place: Set a new seed  of the active noise, then regenerate nodes
346   (using the XYZ and Size parameters in the Perlin Noise Creator)
348 This can be useful to look at many different variations of the noise.
350 ### Troubleshooting
352 #### The mod hangs up / is extremely slow
353 Sorry! :-(
355 This can happen if the mod tries to calculate enormous numbers of values
356 or generates a huge number of nodes.
358 Which is the case if you selected a huge number when starting to
359 generate nodes.
361 Be careful with large numbers in 3D mode as it is exponentially more
362 expensive to calculate than 2D.
364 The only thing you can do is to just not generate huge areas at once.
365 The mod doesn’t have any warnings in place for now, so you’re on
366 your own for now. Sorry! :-(
368 #### The Perlin noise gives the exact same value everywhere.
369 The most likely reason is that `scale` is exactly 0.
370 Because if `scale` is 0, the noise will return the same value
371 everywhere. Remember the result of all noise computations is multiplied
372 with `scale` at the end, so a multiplication with 0 will
373 literally nullify all that.
374 This is correct behavior but obviously useless.
375 Just pick a non-zero scale to fix this.
377 ## Credits
378 This mod was written by Wuzzy.
380 ## License
382 This program is free software; you can redistribute it and/or modify
383 it under the terms of the GNU Lesser General Public License as published by
384 the Free Software Foundation; either version 2.1 of the License, or
385 (at your option) any later version.
387 This program is distributed in the hope that it will be useful,
388 but WITHOUT ANY WARRANTY; without even the implied warranty of
389 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
390 GNU Lesser General Public License for more details.
392 You should have received a copy of the GNU Lesser General Public License along
393 with this program; if not, write to the Free Software Foundation, Inc.,
394 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.