| Title: | Generate Multi-Dimensional Open Simplex Noise |
|---|---|
| Description: | Generate 2, 3 or 4-dimensional gradient noise. The noise function is comparable to classic Perlin noise, but with less directional artefacts and lower computational overhead. It can have applications in procedural generation or (flow fields) simulations. |
| Authors: | Pepijn de Vries [aut, cre] (ORCID: <https://orcid.org/0000-0002-7961-6646>), Marco Ciaramella [aut, cph], KdotJPG [aut, cph] |
| Maintainer: | Pepijn de Vries <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.0.3.0001 |
| Built: | 2026-05-28 06:45:58 UTC |
| Source: | https://github.com/pepijn-devries/opensimplex2 |
Create a regular n-dimensional grid with an OpenSimplex2 noise gradient.
You can control the noisiness to some degree with the frequency argument.
If you want more control, you should use opensimplex_space(), which
allows you to create a continuous OpenSimplex noise gradient space,
that can be sampled at any arbitrary coordinate.
opensimplex_noise(type = "S", width, height, depth, slice, frequency = 1)opensimplex_noise(type = "S", width, height, depth, slice, frequency = 1)
type |
Type of OpenSimplex2 you wish to use. Should be either
|
width, height, depth, slice
|
Positive |
frequency |
The frequency ( |
The exact state of the noise gradient space depends on R's internal, random generator. So each time you call opensimplex_space, you will get a, space in a different state. If you want to obtain a reproducible state,, you simply set the random seed with set.seed().
A matrix (in case of two dimensions) or array (in case of more
dimensions) of numeric values between -1 and +1. OpenSimplex2 uses
gradient tables that ensure that the distribution of values is centred at zero,
meaning the "peaks" and "valleys" are statistically balanced.
mat <- opensimplex_noise("S", 100, 100) image(mat)mat <- opensimplex_noise("S", 100, 100) image(mat)
Create a continuous OpenSimplex noise gradient space, that can be sampled
at any arbitrary coordinate. The gradient has numeric values between -1
and +1. OpenSimplex2 uses gradient tables that ensure that the distribution
of values is centred at zero, meaning the "peaks" and "valleys" are
statistically balanced.
The exact state of the noise gradient space depends on R's internal, random generator. So each time you call opensimplex_space, you will get a, space in a different state. If you want to obtain a reproducible state,, you simply set the random seed with set.seed().
opensimplex_space(type = "S", dimensions = 2L)opensimplex_space(type = "S", dimensions = 2L)
type |
Type of OpenSimplex2 you wish to use. Should be either
|
dimensions |
An integer value of number of dimensions to be used in your gradient space. Should be 2, 3 or 4. |
Returns a named list. It has the elements:
sample: which is a function that will return the simplex noise value (between -1 and +1)
at a given coordinate. The function takes the same number of arguments as the value of
dimensions. Each argument is a coordinate in the nth
dimension. You can provide multiple coordinates, as long as you provide the same
number of coordinates in each dimension.
dimensions: an integer value indicating the number of dimensions
available in this space object.
type: A character string indicating whether this object uses the fast
("F") or smooth ("S") variant of OpenSimplex2.
close: which is a function that closes the simplex noise gradient space. In other words, memory
used to specify the gradient space is freed, and can no longer be accessed. After closing
the space, you can no longer sample it.
## By setting a random generator seed, the example below becomes reproducible set.seed(0) ## Open a extra smooth ("S") simplex noise gradient with 3 dimensions: space <- opensimplex_space("S", 3L) ## Sample it at some random coordinates space$sample(i = 5*runif(10), j = 10*runif(10), k = 15*runif(10)) ## Close it when you are done space$close()## By setting a random generator seed, the example below becomes reproducible set.seed(0) ## Open a extra smooth ("S") simplex noise gradient with 3 dimensions: space <- opensimplex_space("S", 3L) ## Sample it at some random coordinates space$sample(i = 5*runif(10), j = 10*runif(10), k = 15*runif(10)) ## Close it when you are done space$close()