CrawfisSoftware.Noise
1.2.1
dotnet add package CrawfisSoftware.Noise --version 1.2.1
NuGet\Install-Package CrawfisSoftware.Noise -Version 1.2.1
<PackageReference Include="CrawfisSoftware.Noise" Version="1.2.1" />
<PackageVersion Include="CrawfisSoftware.Noise" Version="1.2.1" />
<PackageReference Include="CrawfisSoftware.Noise" />
paket add CrawfisSoftware.Noise --version 1.2.1
#r "nuget: CrawfisSoftware.Noise, 1.2.1"
#:package CrawfisSoftware.Noise@1.2.1
#addin nuget:?package=CrawfisSoftware.Noise&version=1.2.1
#tool nuget:?package=CrawfisSoftware.Noise&version=1.2.1
CrawfisSoftware.Noise
CrawfisSoftware.Noise is a small .NET library that provides a couple of common procedural noise generators.
Targets:
.NET Standard 2.1.NET 8
Install
If you are consuming this as a NuGet package:
dotnet add package CrawfisSoftware.Noise
Namespace
All public types are under:
CrawfisSoftware.Noise
Noise ranges and conventions
Both generators in this library return float samples in the range [0, 1].
- The
Sample(...)overloads take continuous coordinates (float space). - The
SampleLattice(...)overloads take integer lattice coordinates and apply an optionalscale. - The
Calculate*Array(...)helpers generate entire 1D/2D/3D grids by repeatedly sampling lattice coordinates.
Classes
SimplexNoise
Implementation of Perlin Simplex Noise (band-limited gradient noise).
Key points:
- Supports 1D, 2D, and 3D sampling.
- Deterministic when using the default constructor (fixed permutation table).
- Can be seeded by providing a
System.Random, which generates a new permutation table.- Note: the constructor remarks mention that using randomized permutations may introduce low-frequency aliasing.
Constructors
SimplexNoise()- Uses an internal, fixed permutation table (deterministic output across runs).
SimplexNoise(System.Random random)- Fills permutations with random bytes from
random.
- Fills permutations with random bytes from
Sampling API
float Sample(float x)float Sample(float x, float y)float Sample(float x, float y, float z)
Each returns a float in [0, 1].
Lattice helpers
float SampleLattice(int x, float scale = 1)float SampleLattice(int x, int y, float scale = 1)float SampleLattice(int x, int y, int z, float scale = 1)
These call the corresponding Sample(...) overload using x * scale, y * scale, etc.
Array generation helpers
float[] Calculate1DArray(int width, float scale)float[,] Calculate2DArray(int width, int height, float scale)float[,,] Calculate3DArray(int width, int height, int depth, float scale)
These are convenience methods for generating grids of samples.
Example
using CrawfisSoftware.Noise;
var noise = new SimplexNoise();
// Single samples
float a = noise.Sample(0.1f);
float b = noise.Sample(12.3f, 4.56f);
float c = noise.Sample(1.0f, 2.0f, 3.0f);
// Generate a 2D heightmap
float[,] height = noise.Calculate2DArray(width: 256, height: 256, scale: 0.02f);
WhiteNoise
White noise sampler backed by a precomputed table of random integers.
Key points:
- Supports 1D, 2D, and 3D sampling.
- Intended for fast, simple “random-looking” values (no gradient continuity).
- Deterministic if you pass a seeded
System.Random.
Internals (useful for understanding output):
- A table of size
1024is filled once in the constructor. - Samples hash the input coordinates into the table by scaling and combining indices.
- Output is normalized into
[0, 1]usingminRandomValueandmaxRandomValue.
Constructors
WhiteNoise(System.Random random, int minRandomValue = 0, int maxRandomValue = int.MaxValue - 1)- Uses the provided RNG to populate the table.
- Generated values are clamped to
[minRandomValue, maxRandomValue].
WhiteNoise(int minRandomValue = 0, int maxRandomValue = int.MaxValue)- Uses a new
System.Random().
- Uses a new
Sampling API
float Sample(float x)float Sample(float x, float y)float Sample(float x, float y, float z)
Each returns a float in [0, 1].
Lattice helpers
float SampleLattice(int x, float scale = 1)float SampleLattice(int x, int y, float scale = 1)float SampleLattice(int x, int y, int z, float scale = 1)
Array generation helpers
float[] Calculate1DArray(int width, float scale)float[,] Calculate2DArray(int width, int height, float scale)float[,,] Calculate3DArray(int width, int height, int depth, float scale)
Example
using CrawfisSoftware.Noise;
// Deterministic white noise
var rng = new System.Random(1234);
var noise = new WhiteNoise(rng);
float s = noise.Sample(0.42f, 1.25f);
float[,] grid = noise.Calculate2DArray(128, 128, scale: 0.1f);
Notes
- This library focuses on lightweight sampling primitives. Any higher-level composition (octaves/fBm, domain warping, tiling, etc.) should be built on top of these samplers.
Helpers
Turbulence
Static helper for generating turbulence from SimplexNoise by summing multiple octaves.
Key points:
- Works with 1D, 2D, and 3D simplex noise.
- Octaves are summed using increasing frequency (
lacunarity) and decreasing amplitude (gain). - Since
SimplexNoise.Sample(...)returns values in[0, 1], turbulence is computed from the signed remap:abs(2*n - 1).
API:
float Turbulence.Sample(SimplexNoise noise, float x, int octaves = 4, float lacunarity = 2, float gain = 0.5f)float Turbulence.Sample(SimplexNoise noise, float x, float y, int octaves = 4, float lacunarity = 2, float gain = 0.5f)float Turbulence.Sample(SimplexNoise noise, float x, float y, float z, int octaves = 4, float lacunarity = 2, float gain = 0.5f)
Normalized variants (divide by total amplitude, producing values roughly in [0, 1]):
float Turbulence.SampleNormalized(...)
Example:
using CrawfisSoftware.Noise;
var noise = new SimplexNoise();
float t = Turbulence.SampleNormalized(noise, x: 1.25f, y: 4.5f, octaves: 6, lacunarity: 2.0f, gain: 0.5f);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Please see CHANGELOG.md for release details.