Skip to main content

Module noise

Module noise 

Source
Expand description

Procedural noise for scripts, shaders-on-the-CPU and generated textures.

Everything is a pure function of its inputs (no global state), so it is safe to call from script libraries and always deterministic for a given seed.

use kvas_engine::noise::{Noise, NoiseKind};
let (x, z) = (1.0, 2.0);
let n = Noise { kind: NoiseKind::Ridged, frequency: 0.8, octaves: 5, ..Default::default() };
let height = n.sample2(x, z);          // -1..1
let mask = n.sample01(x, z, 0.0);      // 0..1

Structs§

Noise
Full-featured fractal noise. sample* return -1..1, sample01* return 0..1.
NoiseTexture
A texture description that fits in MeshRenderer.texture, e.g. from a script: mr.texture = NoiseTexture::new(Noise::new(NoiseKind::Worley)).key();

Enums§

NoiseKind
Basic noise flavours; all can be combined with fractal octaves and domain warping.

Constants§

TEXTURE_PREFIX
Prefix for serialized procedural noise texture keys.

Functions§

perlin3
Classic gradient (Perlin) noise, roughly -1..1.
value3
Smooth value noise, -1..1.
worley3
Distances to the nearest and second nearest feature point (Worley / cellular noise).