Scripting API

Scripting API

Noise

Record struct in Abyss.Core, from Abyss.Core.

Smooth randomness: a number from -1 to 1 for each place, changing gently from place to place, and the same for the same place and Noise.Seed every time it is asked and on every system — the stuff terrain, caves, clouds and wobbles are made of.

var hills = new Noise(seed) { Kind = NoiseKind.Simplex, Frequency = 1f / 128, Fractal = NoiseFractal.Fbm, Octaves = 5 };float height = 64 + (24 * hills.Sample(x, z));
public readonly record struct Noise

Remarks

A value, safe to use from any thread at once; nothing is allocated. The numbers it gives are kept the same from one engine version to the next, since a saved world depends on them. Ranges: every kind and fractal stays within -1 to 1; Perlin and simplex rarely reach past ±0.9, as such noise rarely does.

Constructors

Noise

public Noise()

A simplex noise of seed 0, features about 100 units apart.

Noise

public Noise(int seed)

A simplex noise of seed, features about 100 units apart.

Parameters

  • seed

Properties

Seed

public int Seed { get; init; }

Which of the possible patterns: another seed, another world.

Kind

public NoiseKind Kind { get; init; }

The pattern each layer makes.

Frequency

public float Frequency { get; init; }

How many features to a unit: places are multiplied by it before anything else. The default, 0.01, puts features about 100 units apart.

Fractal

public NoiseFractal Fractal { get; init; }

How the layers are summed; NoiseFractal.None is one layer.

Octaves

public int Octaves { get; init; }

How many layers a fractal sums, 1 to 16.

Exceptions

  • ArgumentOutOfRangeException: Not 1 to 16.

Lacunarity

public float Lacunarity { get; init; }

How much finer each layer is than the last: 2 halves its features.

Gain

public float Gain { get; init; }

How much fainter each layer is than the last: 0.5 halves it.

Methods

Sample

public float Sample(float x, float y)

The noise at a place on a plane.

Parameters

  • x
  • y

Sample

public float Sample(float x, float y, float z)

The noise at a place in space.

Parameters

  • x
  • y
  • z

Fill

public void Fill(Span<float> into, float x, float y, int width, int height, float step = 1)

The noise over a grid on a plane, width by height places step apart from (x, y), into into a row at a time: the place (i, j) at into[j * width + i].

Parameters

  • into
  • x
  • y
  • width
  • height
  • step

Exceptions

  • ArgumentException: into holds fewer than width × height.

Fill

public void Fill(Span<float> into, float x, float y, float z, int width, int height, int depth, float step = 1)

The noise over a grid in space, width by height by depth places step apart from (x, y, z), into into along x first, then y, then z: the place (i, j, k) at into[(k * height + j) * width + i].

Parameters

  • into
  • x
  • y
  • z
  • width
  • height
  • depth
  • step

Exceptions

  • ArgumentException: into holds fewer than width × height × depth.

Warp

public (float X, float Y) Warp(float x, float y, float amplitude)

A place on a plane pushed by this noise up to amplitude units each way, two samples of it under other seeds giving the push: noise sampled at the pushed place swirls and folds rather than lying in even bands (domain warping).

Parameters

  • x
  • y
  • amplitude

Warp

public (float X, float Y, float Z) Warp(float x, float y, float z, float amplitude)

A place in space pushed by this noise up to amplitude units each way, as on a plane.

Parameters

  • x
  • y
  • z
  • amplitude