Simplex noise lands in Godot 3.1 By: Joan Fons

Make some noise for Godot 3.1!

Simplex noise generation has just landed in Godot 3.1! This noise generation algorithm, originally invented by Ken Perlin, is fast and has really good results but it is still encumbered by some patents. That's why Godot will use OpenSimplex noise, a public domain and unencumbered alternative.

Applications

Simplex noise, like any other type of noise, is especially useful in two areas of game development: procedural generation and visual effects.

Procedural generation

Generating procedural content in videogames can be challenging, completely random structures tend to turn out as a complete mess and therefore unusable. That's why the "controlled randomness" of simplex noise becomes really useful. If you want to learn more about how fractal noise works and some other terrain generation techniques I strongly recommend this article by Red Blob Games.

A Godot voxel world prototype by Zylann, using his own OpenSimplex module which can now be replaced by the built-in implementation.

Example of a simple Terraria-like world generation using Simplex noise.

Visual effects

2D noise textures are really useful when creating cloudy or wavy effects. For example, the new NoiseTexture resource can be used as a normal map to get a quick and simple water material:

Noise textures can also be used as roughness maps, 2D light textures, etc. But the true power of noise textures becomes available when used in combination with text shaders:

Getting started

Edit: After this article was published, the SimplexNoise node was renamed to OpenSimplexNoise to be more explicit on the algorithm used. The examples below have been updated accordingly.

GDScript

Generating noise from GDScript is as simple as instancing a new noise generator, setting its parameters, and sampling at the desired positions:

# Instantiate var noise = OpenSimplexNoise.new() # Configure noise.seed = randi() noise.octaves = 4 noise.period = 20.0 noise.persistence = 0.8 # Sample print(noise.get_noise_2d(1.0, 1.0)) print(noise.get_noise_3d(0.5, 3.0, 15.0)) print(noise.get_noise_3d(0.5, 1.9, 4.7, 0.0))

Another way to access noise values is to precompute a noise image:

# This creates a 512x512 image filled with simplex noise (using the currently set parameters) var noise_image = noise.get_image(512, 512) # You can now access the values at each position like in any other image print(noise_image.get_pixel(10, 20))

For more information about OpenSimplexNoise and what is the meaning of each parameter, don't forget to check out the documentation.

Noise texture