SimplexNoise C# Implementation

repository·master·Indexed 41 days ago

https://github.com/wardbenjamin/simplexnoise

A C# library for 1D, 2D, and 3D Simplex Noise generation designed for procedural content generation. Features include deterministic noise via Noise.Seed and methods for generating noise arrays (Noise.Calc1D, Noise.Calc2D, Noise.Calc3D) or individual values (Noise.CalcPixel1D, Noise.CalcPixel2D, Noise.CalcPixel3D).

Tokens
905
Snippets
6
Records
6
Agent score
2%

What's inside SimplexNoise

  1. Get individual noise values with CalcPixel methods

    master

    If you need to calculate the noise value for a specific coordinate without generating an entire array, use the CalcPixel methods. These return a single float value.

    Methods:

    • Noise.CalcPixel1D(int x, float scale): Returns the value at index x.
    • Noise.CalcPixel2D(int x, int y, float scale): Returns the value at index x, y.
    • Noise.CalcPixel3D(int x, int y, int z, float scale): Returns the value at index x, y, z.
    // Example 2D pixel access
    int x = 10, y = 15;
    float scale = 0.10f;
    float pixel = Noise.CalcPixel2D(x, y, scale);
  2. Reference: Simplex Noise API Summary

    master

    The following methods are available in the Noise class for generating noise values in various dimensions and formats.

    - Noise.Seed (int) - Arbitrary integer seed
    - Noise.Calc1D(int width, float scale) -> float[]
    - Noise.Calc2D(int width, int height, float scale) -> float[,]
    - Noise.Calc3D(int width, int height, int length, float scale) -> float[,,]
    - Noise.CalcPixel1D(int x, float scale) -> float
    - Noise.CalcPixel2D(int x, int y, float scale) -> float
    - Noise.CalcPixel3D(int x, int y, int z, float scale) -> float
  3. Generate 3D Simplex noise arrays with Noise.Calc3D

    master

    Use Noise.Calc3D to generate a 3D array of Simplex noise values.

    Parameters:

    • width (int): The number of points to generate in the 1st dimension.
    • height (int): The number of points to generate in the 2nd dimension.
    • length (int): The number of points to generate in the 3rd dimension.
    • scale (float): The scale of the noise. A greater scale results in denser noise.
    int width = 10, height = 15, length = 20;
    float scale = 0.10f;
    float[,,] noise = Noise.Calc3D(width, height, length, scale);
  4. Configure deterministic noise with Noise.Seed

    master

    The Noise.Seed property accepts an arbitrary integer to generate the internal lookup table. Setting a specific seed ensures that the generated noise is deterministic (the same seed will always produce the same noise pattern). If not explicitly set, the seed defaults to 0.

    Noise.Seed = 123456;
  5. Generate 1D Simplex noise arrays with Noise.Calc1D

    master

    Use Noise.Calc1D to generate a 1D array of Simplex noise values.

    Parameters:

    • width (int): The number of points to generate.
    • scale (float): The scale of the noise. A greater scale results in denser noise.
    int width = 10;
    float scale = 0.10f;
    float[] noise = Noise.Calc1D(width, scale);
  6. Generate 2D Simplex noise arrays with Noise.Calc2D

    master

    Use Noise.Calc2D to generate a 2D array of Simplex noise values.

    Parameters:

    • width (int): The number of points to generate in the 1st dimension.
    • height (int): The number of points to generate in the 2nd dimension.
    • scale (float): The scale of the noise. A greater scale results in denser noise.
    int width = 10, height = 15;
    float scale = 0.10f;
    float[,] noise = Noise.Calc2D(width, height, scale);