SimplexNoise
The SimplexNoise class is a one-dimensional noise generator that builds on the functionality provided by the NoiseBase class. It implements the simplex noise algorithm to produce smooth noise values that are roughly in the range [-1, 1] when the amplitude is set to 1. These values are then mapped to the [0, 1] range and scaled by the provided amplitude.
dreamplet.noise.SimplexNoise
Parameters
seed
(int, optional): An optional seed for noise generation. Providing a seed ensures that the noise sequence is reproducible.
noise
Generates a noise value for a given coordinate using the simplex noise algorithm.
Parameters
x
(floaf): The input coordinate at which to compute the noise.frequency
(float, optional): Scales the input coordinate. Default value is 1.amplitude
(float, optional): Scales the resulting noise value. Default value is 1.
Returns
- (floaf): The noise value computed at the given coordinate, mapped from the raw range of approximately [-1, 1] to [0, 1] and then scaled by the amplitude.
How it works
- Input Scaling: The input coordinate x is multiplied by frequency to control the noise detail.
- Lattice Points: The function determines the integer coordinates surrounding x (i.e., i0 and i1) and calculates the distances (x0 and x1).
- Weight Calculation: Two weights (t0 and t1) are computed using a quadratic attenuation function.
- Gradient Contributions: For each lattice point, if the corresponding weight is positive, it is squared and used to calculate a contribution via the internal _grad method.
- Noise Aggregation: The contributions are combined into a raw noise value, which is roughly in the range [-1, 1].
- Mapping and Scaling: The raw noise value is mapped to the [0, 1] range and then scaled by the provided amplitude.