* @brief A Perlin Simplex Noise C++ Implementation (1D, 2D, 3D, 4D). */
| 15 | * @brief A Perlin Simplex Noise C++ Implementation (1D, 2D, 3D, 4D). |
| 16 | */ |
| 17 | class SimplexNoise { |
| 18 | public: |
| 19 | // 1D Perlin simplex noise |
| 20 | float noiseX(float x); |
| 21 | // 2D Perlin simplex noise |
| 22 | float noiseXY(float x, float y); |
| 23 | // 3D Perlin simplex noise |
| 24 | float noiseXYZ(float x, float y, float z); |
| 25 | |
| 26 | // Fractal/Fractional Brownian Motion (fBm) noise summation |
| 27 | float fractalX(size_t octaves, float x); |
| 28 | float fractalXY(size_t octaves, float x, float y); |
| 29 | float fractalXYZ(size_t octaves, float x, float y, float z); |
| 30 | |
| 31 | |
| 32 | /** |
| 33 | * Constructor of to initialize a fractal noise summation |
| 34 | * |
| 35 | * @param[in] frequency Frequency ("width") of the first octave of noise (default to 1.0) |
| 36 | * @param[in] amplitude Amplitude ("height") of the first octave of noise (default to 1.0) |
| 37 | * @param[in] lacunarity Lacunarity specifies the frequency multiplier between successive octaves (default to 2.0). |
| 38 | * @param[in] persistence Persistence is the loss of amplitude between successive octaves (usually 1/lacunarity) |
| 39 | */ |
| 40 | explicit SimplexNoise(float frequency = 1.0f, |
| 41 | float lacunarity = 2.0f, |
| 42 | float persistence = 0.5f) : |
| 43 | mFrequency(frequency), |
| 44 | mAmplitude(frequency), |
| 45 | mLacunarity(lacunarity), |
| 46 | mPersistence(persistence) { |
| 47 | } |
| 48 | |
| 49 | void normalizeArray(std::vector<std::vector<float>>& pNoise); |
| 50 | std::vector<std::vector<float>> create( size_t pWidth, size_t pHeight, size_t pOctaves ); |
| 51 | |
| 52 | private: |
| 53 | // Parameters of Fractional Brownian Motion (fBm) : sum of N "octaves" of noise |
| 54 | float mFrequency; ///< Frequency ("width") of the first octave of noise (default to 1.0) |
| 55 | float mAmplitude; ///< Amplitude ("height") of the first octave of noise (default to 1.0) |
| 56 | float mLacunarity; ///< Lacunarity specifies the frequency multiplier between successive octaves (default to 2.0). |
| 57 | float mPersistence; ///< Persistence is the loss of amplitude between successive octaves (usually 1/lacunarity) |
| 58 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected