diff options
Diffstat (limited to 'source/blender/blenlib/BLI_noise.hh')
-rw-r--r-- | source/blender/blenlib/BLI_noise.hh | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_noise.hh b/source/blender/blenlib/BLI_noise.hh index a7af69f42a9..ae80a98c45f 100644 --- a/source/blender/blenlib/BLI_noise.hh +++ b/source/blender/blenlib/BLI_noise.hh @@ -30,24 +30,28 @@ namespace blender::noise { * \{ */ /* Hash integers to `uint32_t`. */ + uint32_t hash(uint32_t kx); uint32_t hash(uint32_t kx, uint32_t ky); uint32_t hash(uint32_t kx, uint32_t ky, uint32_t kz); uint32_t hash(uint32_t kx, uint32_t ky, uint32_t kz, uint32_t kw); /* Hash floats to `uint32_t`. */ + uint32_t hash_float(float kx); uint32_t hash_float(float2 k); uint32_t hash_float(float3 k); uint32_t hash_float(float4 k); /* Hash integers to `float` between 0 and 1. */ + float hash_to_float(uint32_t kx); float hash_to_float(uint32_t kx, uint32_t ky); float hash_to_float(uint32_t kx, uint32_t ky, uint32_t kz); float hash_to_float(uint32_t kx, uint32_t ky, uint32_t kz, uint32_t kw); /* Hash floats to `float` between 0 and 1. */ + float hash_float_to_float(float k); float hash_float_to_float(float2 k); float hash_float_to_float(float3 k); @@ -69,30 +73,35 @@ float4 hash_float_to_float4(float4 k); * \{ */ /* Perlin noise in the range [-1, 1]. */ + float perlin_signed(float position); float perlin_signed(float2 position); float perlin_signed(float3 position); float perlin_signed(float4 position); /* Perlin noise in the range [0, 1]. */ + float perlin(float position); float perlin(float2 position); float perlin(float3 position); float perlin(float4 position); /* Fractal perlin noise in the range [0, 1]. */ + float perlin_fractal(float position, float octaves, float roughness); float perlin_fractal(float2 position, float octaves, float roughness); float perlin_fractal(float3 position, float octaves, float roughness); float perlin_fractal(float4 position, float octaves, float roughness); /* Positive distorted fractal perlin noise. */ + float perlin_fractal_distorted(float position, float octaves, float roughness, float distortion); float perlin_fractal_distorted(float2 position, float octaves, float roughness, float distortion); float perlin_fractal_distorted(float3 position, float octaves, float roughness, float distortion); float perlin_fractal_distorted(float4 position, float octaves, float roughness, float distortion); /* Positive distorted fractal perlin noise that outputs a float3. */ + float3 perlin_float3_fractal_distorted(float position, float octaves, float roughness, @@ -116,24 +125,56 @@ float3 perlin_float3_fractal_distorted(float4 position, /** \name Musgrave Multi Fractal * \{ */ +/** + * 1D Ridged Multi-fractal Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_ridged_multi_fractal(const float co, const float H, const float lacunarity, const float octaves, const float offset, const float gain); +/** + * 2D Ridged Multi-fractal Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_ridged_multi_fractal(const float2 co, const float H, const float lacunarity, const float octaves, const float offset, const float gain); +/** + * 3D Ridged Multi-fractal Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_ridged_multi_fractal(const float3 co, const float H, const float lacunarity, const float octaves, const float offset, const float gain); +/** + * 4D Ridged Multi-fractal Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_ridged_multi_fractal(const float4 co, const float H, const float lacunarity, @@ -141,24 +182,56 @@ float musgrave_ridged_multi_fractal(const float4 co, const float offset, const float gain); +/** + * 1D Hybrid Additive/Multiplicative Multi-fractal Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_hybrid_multi_fractal(const float co, const float H, const float lacunarity, const float octaves, const float offset, const float gain); +/** + * 2D Hybrid Additive/Multiplicative Multi-fractal Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_hybrid_multi_fractal(const float2 co, const float H, const float lacunarity, const float octaves, const float offset, const float gain); +/** + * 3D Hybrid Additive/Multiplicative Multi-fractal Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_hybrid_multi_fractal(const float3 co, const float H, const float lacunarity, const float octaves, const float offset, const float gain); +/** + * 4D Hybrid Additive/Multiplicative Multi-fractal Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_hybrid_multi_fractal(const float4 co, const float H, const float lacunarity, @@ -166,43 +239,140 @@ float musgrave_hybrid_multi_fractal(const float4 co, const float offset, const float gain); +/** + * 1D Musgrave fBm + * + * \param H: fractal increment parameter. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * + * \param from "Texturing and Modelling: A procedural approach". + */ float musgrave_fBm(const float co, const float H, const float lacunarity, const float octaves); + +/** + * 2D Musgrave fBm + * + * \param H: fractal increment parameter. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * + * \param from "Texturing and Modelling: A procedural approach". + */ float musgrave_fBm(const float2 co, const float H, const float lacunarity, const float octaves); +/** + * 3D Musgrave fBm + * + * \param H: fractal increment parameter. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * + * \param from "Texturing and Modelling: A procedural approach". + */ float musgrave_fBm(const float3 co, const float H, const float lacunarity, const float octaves); +/** + * 4D Musgrave fBm + * + * \param H: fractal increment parameter. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * + * \param from "Texturing and Modelling: A procedural approach". + */ float musgrave_fBm(const float4 co, const float H, const float lacunarity, const float octaves); +/** + * 1D Musgrave Multi-fractal + * + * \param H: highest fractal dimension. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + */ float musgrave_multi_fractal(const float co, const float H, const float lacunarity, const float octaves); +/** + * 2D Musgrave Multi-fractal + * + * \param H: highest fractal dimension. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + */ float musgrave_multi_fractal(const float2 co, const float H, const float lacunarity, const float octaves); +/** + * 3D Musgrave Multi-fractal + * + * \param H: highest fractal dimension. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + */ float musgrave_multi_fractal(const float3 co, const float H, const float lacunarity, const float octaves); +/** + * 4D Musgrave Multi-fractal + * + * \param H: highest fractal dimension. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + */ float musgrave_multi_fractal(const float4 co, const float H, const float lacunarity, const float octaves); +/** + * 1D Musgrave Heterogeneous Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_hetero_terrain(const float co, const float H, const float lacunarity, const float octaves, const float offset); +/** + * 2D Musgrave Heterogeneous Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_hetero_terrain(const float2 co, const float H, const float lacunarity, const float octaves, const float offset); +/** + * 3D Musgrave Heterogeneous Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_hetero_terrain(const float3 co, const float H, const float lacunarity, const float octaves, const float offset); +/** + * 4D Musgrave Heterogeneous Terrain + * + * \param H: fractal dimension of the roughest area. + * \param lacunarity: gap between successive frequencies. + * \param octaves: number of frequencies in the fBm. + * \param offset: raises the terrain from `sea level'. + */ float musgrave_hetero_terrain(const float4 co, const float H, const float lacunarity, |