Noise Scripts

Emoticone11

The Dark Lord Sauron
Staff member
Hi everyone,

I got tired of having to look up the format of the Perlin noise command every time I want to use it, so I made some very simple scripts (for use with the macro+keybind mod) to help assist the process (as well as for two other noise functions I uncovered, Voronoi noise and RidgedMulti noise). They're uploaded as attachments to this thread. All of the scripts will simply prompt for a number of parameters, and then execute the noise command after you enter a value for each one. The mask and pattern parameters correspond to the blocks you want the noise to be applied to, and the blocks you want to be used for the noise, respectively, in standard WE syntax. The other parameters are command-specific, but should all be numbers.

For anyone who's technically inclined, here's a really nice blog describing how Perlin noise works, and what the parameters mean:


Summarizing the above, here's how you can interpret the parameters that the Perlin script asks for:

seed: due to the limitations of computers, noise commands are not truly random, but rather pseudorandom. This means that if you execute the command multiple times with the same parameters over and over again, you'll get the same result every single time, since it's generated by a deterministic algorithm. This can be controlled using a seed, which is sort of like an initial value used by the pseudorandom algorithm to generate the noise. So if you don't like a given outcome, but the other parameters are correct, you can keep trying again and again with different seeds until you get one you like.

xscale, yscale, zscale: each of these parameters controls the scale of the coordinate system used to generate the noise. xscale and zscale correspond to the cardinal directions, and yscale corresponds to height. Using larger values for any of these will "stretch" the noise in that direction, and using smaller values will "shrink" it in that direction. Using 1 for each of these is a good default. If you want to make nice striations in a cliff, try using a larger value for xscale or zscale relative to the others.

frequency: must be a value between 0 and 1 (exclusive). Corresponds roughly to how "jagged" the noise function looks like. This is just like high frequency vs low frequency waves (but imagine the waves being noise rather than sinusoidal). Practically speaking, a very low frequency will result in smoother, more "blob-like" noise which occurs in specific spots, whereas a very high frequency will result in more random noise which is more evenly distributed across the whole selection.

octaves: this is the cool part of Perlin noise. Just like real life has different "levels" of terrain (mountains, hills, boulders, pebbles, etc.), Perlin noise can iteratively apply many octaves of noise, each one corresponding to a different "level" of noise. The first octave will always be the base frequency defined in the previous parameter, so if you use a value of 1 for octaves, you'll just get that. For every subsequent octave, it'll use a higher frequency (specifically, for octave n, it'll use the base frequency to the power of n). Much like the terrain analogy above, using higher octaves will give you more "fine-grained" noise.

persistence: this is a discount factor on octaves showing how each octave is weighted, i.e. how much of each octave it lets through. If you use a value of 0 for this, only the first octave will be applied (so it's essentially the same as if you just gave a value of 1 for octaves). If you use a value of 1, then every octave will have the same weight. For any value between 0 and 1, then the effect of each subsequent octave will decay by that constant.

threshold: the noise algorithm basically assigns a value between 0 and 1 to every single coordinate in your selection. In order to use the noise to set some pattern, you need to first set some threshold (between 0 and 1), such that every coordinate with a value above that threshold is set to your pattern, and the ones below that threshold are left alone. You can create a "nested" effect with noise, then, by using increasing thresholds while keeping the other parameters exactly the same.

The other noise commands that I've uploaded all work similarly to this, but with some slight differences in the algorithm and parameters. RidgedMulti is like Perlin, but uses an absolute value function on the generated gradients, which supposedly makes the noise more "ridge-like". Voronoi noise creates a bunch of polygonal cell-like regions.

Just as a final note, when deciding to use noise for a given terraforming task, first ask yourself whether the task can be realistically modelled as noise. For macroscopic features like mountains, rivers, sand dunes, etc., it's not easy to replicate them purely with noise functions. Instead, you want to think about the physical processes (water flow, wind, etc.) that generated these over time, and try to replicate them with your WE/voxel tools (unfortunately there's no way to "simulate" these physical erosion processes within a selection in MC - that'd be cool, huh?). However, you can use noise to do things like generating ground cover, striations in rock, placing foliage, and even providing a base for hills/mountains to make it easier to terraform them. It's a pretty powerful tool altogether.
 

Attachments

  • voronoi.txt
    118 bytes · Views: 27
  • ridgedmulti.txt
    134 bytes · Views: 22
  • perlin.txt
    145 bytes · Views: 52

Emoticone11

The Dark Lord Sauron
Staff member
Attached updated versions of the scripts to the OP; the previous versions were having some issues with sometimes not applying the mask correctly.
 
  • Like
Reactions: Ric