Blender  V2.93
Macros
noise.c File Reference
#include <math.h>
#include "BLI_compiler_compat.h"
#include "BLI_sys_types.h"
#include "BLI_noise.h"

Go to the source code of this file.

Macros

#define VALUE_AT(rx, ry, rz)   ((rx)*q[0] + (ry)*q[1] + (rz)*q[2])
 
#define SURVE(t)   ((t) * (t) * (3.0f - 2.0f * (t)))
 

Functions

Improved Perlin Noise Implementation (New)
BLI_INLINE float lerp (float t, float a, float b)
 
BLI_INLINE float npfade (float t)
 
BLI_INLINE float grad (int hash_val, float x, float y, float z)
 
static float newPerlin (float x, float y, float z)
 
static float newPerlinU (float x, float y, float z)
 
Voronoi/Worley Implementation
static float dist_Squared (float x, float y, float z, float e)
 
static float dist_Real (float x, float y, float z, float e)
 
static float dist_Manhattan (float x, float y, float z, float e)
 
static float dist_Chebychev (float x, float y, float z, float e)
 
static float dist_MinkovskyH (float x, float y, float z, float e)
 
static float dist_Minkovsky4 (float x, float y, float z, float e)
 
static float dist_Minkovsky (float x, float y, float z, float e)
 
void BLI_noise_voronoi (float x, float y, float z, float *da, float *pa, float me, int dtype)
 
static float voronoi_F1 (float x, float y, float z)
 
static float voronoi_F2 (float x, float y, float z)
 
static float voronoi_F3 (float x, float y, float z)
 
static float voronoi_F4 (float x, float y, float z)
 
static float voronoi_F1F2 (float x, float y, float z)
 
static float voronoi_Cr (float x, float y, float z)
 
static float voronoi_F1S (float x, float y, float z)
 
static float voronoi_F2S (float x, float y, float z)
 
static float voronoi_F3S (float x, float y, float z)
 
static float voronoi_F4S (float x, float y, float z)
 
static float voronoi_F1F2S (float x, float y, float z)
 
static float voronoi_CrS (float x, float y, float z)
 
Cell-Noise Implementation
static float BLI_cellNoiseU (float x, float y, float z)
 
float BLI_noise_cell (float x, float y, float z)
 
void BLI_noise_cell_v3 (float x, float y, float z, float ca[3])
 
Public API's
float BLI_noise_generic_noise (float noisesize, float x, float y, float z, bool hard, int noisebasis)
 
float BLI_noise_generic_turbulence (float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
 
float BLI_noise_mg_fbm (float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
 
float BLI_noise_mg_multi_fractal (float x, float y, float z, float H, float lacunarity, float octaves, int noisebasis)
 
float BLI_noise_mg_hetero_terrain (float x, float y, float z, float H, float lacunarity, float octaves, float offset, int noisebasis)
 
float BLI_noise_mg_hybrid_multi_fractal (float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis)
 
float BLI_noise_mg_ridged_multi_fractal (float x, float y, float z, float H, float lacunarity, float octaves, float offset, float gain, int noisebasis)
 
float BLI_noise_mg_variable_lacunarity (float x, float y, float z, float distortion, int nbas1, int nbas2)
 

Static Data

#define HASHPNT(x, y, z)   hashpntf + 3 * hash[(hash[(hash[(z)&255] + (y)) & 255] + (x)) & 255]
 
#define hash   BLI_noise_hash_uchar_512
 
static const float hashpntf [768]
 
const unsigned char BLI_noise_hash_uchar_512 [512]
 
static const float hashvectf [768]
 

Improved Perlin Noise Implementation (Original)

#define SETUP(val, b0, b1, r0, r1)
 
static const char g_perlin_data_ub [512+2]
 
static const float g_perlin_data_v3 [512+2][3]
 
static float noise3_perlin (const float vec[3])
 
static float orgBlenderNoise (float x, float y, float z)
 
static float orgBlenderNoiseS (float x, float y, float z)
 
float BLI_noise_hnoise (float noisesize, float x, float y, float z)
 
float BLI_noise_turbulence (float noisesize, float x, float y, float z, int nr)
 
static float orgPerlinNoise (float x, float y, float z)
 
static float orgPerlinNoiseU (float x, float y, float z)
 
float BLI_noise_hnoisep (float noisesize, float x, float y, float z)
 

Macro Definition Documentation

◆ hash

#define hash   BLI_noise_hash_uchar_512

Definition at line 169 of file noise.c.

◆ HASHPNT

#define HASHPNT (   x,
  y,
  z 
)    hashpntf + 3 * hash[(hash[(hash[(z)&255] + (y)) & 255] + (x)) & 255]

Definition at line 44 of file noise.c.

◆ SETUP

#define SETUP (   val,
  b0,
  b1,
  r0,
  r1 
)
Value:
{ \
t = val + 10000.0f; \
b0 = ((int)t) & 255; \
b1 = (b0 + 1) & 255; \
r0 = t - floorf(t); \
r1 = r0 - 1.0f; \
} \
(void)0
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
#define floorf(x)

Definition at line 766 of file noise.c.

◆ SURVE

#define SURVE (   t)    ((t) * (t) * (3.0f - 2.0f * (t)))

◆ VALUE_AT

#define VALUE_AT (   rx,
  ry,
  rz 
)    ((rx)*q[0] + (ry)*q[1] + (rz)*q[2])

Function Documentation

◆ BLI_cellNoiseU()

static float BLI_cellNoiseU ( float  x,
float  y,
float  z 
)
static

Returns unsigned cell-noise.

Definition at line 1125 of file noise.c.

References floor(), x, y, and z.

Referenced by BLI_noise_cell(), BLI_noise_generic_noise(), and BLI_noise_generic_turbulence().

◆ BLI_noise_cell()

float BLI_noise_cell ( float  x,
float  y,
float  z 
)

◆ BLI_noise_cell_v3()

void BLI_noise_cell_v3 ( float  x,
float  y,
float  z,
float  ca[3] 
)

Definition at line 1147 of file noise.c.

References floor(), HASHPNT, x, y, and z.

Referenced by voronoiTex().

◆ BLI_noise_generic_noise()

float BLI_noise_generic_noise ( float  noisesize,
float  x,
float  y,
float  z,
bool  hard,
int  noisebasis 
)

newnoise: generic noise function for use with different noisebasis.

Definition at line 1172 of file noise.c.

References BLI_cellNoiseU(), fabsf, float(), newPerlinU(), orgBlenderNoise(), orgPerlinNoiseU(), voronoi_Cr(), voronoi_F1(), voronoi_F1F2(), voronoi_F2(), voronoi_F3(), voronoi_F4(), x, y, and z.

Referenced by M_Noise_noise(), noise_vector(), stucci(), turb(), and wood_int().

◆ BLI_noise_generic_turbulence()

float BLI_noise_generic_turbulence ( float  noisesize,
float  x,
float  y,
float  z,
int  oct,
bool  hard,
int  noisebasis 
)

◆ BLI_noise_hnoise()

float BLI_noise_hnoise ( float  noisesize,
float  x,
float  y,
float  z 
)

Definition at line 439 of file noise.c.

References orgBlenderNoise(), x, y, and z.

Referenced by BLI_noise_turbulence().

◆ BLI_noise_hnoisep()

float BLI_noise_hnoisep ( float  noisesize,
float  x,
float  y,
float  z 
)

Definition at line 855 of file noise.c.

References noise3_perlin(), x, y, and z.

◆ BLI_noise_mg_fbm()

float BLI_noise_mg_fbm ( float  x,
float  y,
float  z,
float  H,
float  lacunarity,
float  octaves,
int  noisebasis 
)

◆ BLI_noise_mg_hetero_terrain()

float BLI_noise_mg_hetero_terrain ( float  x,
float  y,
float  z,
float  H,
float  lacunarity,
float  octaves,
float  offset,
int  noisebasis 
)

◆ BLI_noise_mg_hybrid_multi_fractal()

float BLI_noise_mg_hybrid_multi_fractal ( float  x,
float  y,
float  z,
float  H,
float  lacunarity,
float  octaves,
float  offset,
float  gain,
int  noisebasis 
)

◆ BLI_noise_mg_multi_fractal()

float BLI_noise_mg_multi_fractal ( float  x,
float  y,
float  z,
float  H,
float  lacunarity,
float  octaves,
int  noisebasis 
)

◆ BLI_noise_mg_ridged_multi_fractal()

float BLI_noise_mg_ridged_multi_fractal ( float  x,
float  y,
float  z,
float  H,
float  lacunarity,
float  octaves,
float  offset,
float  gain,
int  noisebasis 
)

◆ BLI_noise_mg_variable_lacunarity()

float BLI_noise_mg_variable_lacunarity ( float  x,
float  y,
float  z,
float  distortion,
int  nbas1,
int  nbas2 
)

◆ BLI_noise_turbulence()

float BLI_noise_turbulence ( float  noisesize,
float  x,
float  y,
float  z,
int  nr 
)

Definition at line 451 of file noise.c.

References BLI_noise_hnoise(), x, y, and z.

Referenced by fcm_noise_evaluate().

◆ BLI_noise_voronoi()

void BLI_noise_voronoi ( float  x,
float  y,
float  z,
float da,
float pa,
float  me,
int  dtype 
)

◆ dist_Chebychev()

static float dist_Chebychev ( float  x,
float  y,
float  z,
float  e 
)
static

Definition at line 894 of file noise.c.

References e, fabsf, t, x, y, and z.

Referenced by BLI_noise_voronoi().

◆ dist_Manhattan()

static float dist_Manhattan ( float  x,
float  y,
float  z,
float  e 
)
static

Definition at line 888 of file noise.c.

References e, fabsf, x, y, and z.

Referenced by BLI_noise_voronoi().

◆ dist_Minkovsky()

static float dist_Minkovsky ( float  x,
float  y,
float  z,
float  e 
)
static

Definition at line 924 of file noise.c.

References e, fabsf, powf, x, y, and z.

Referenced by BLI_noise_voronoi().

◆ dist_Minkovsky4()

static float dist_Minkovsky4 ( float  x,
float  y,
float  z,
float  e 
)
static

Definition at line 914 of file noise.c.

References e, sqrtf, x, y, and z.

Referenced by BLI_noise_voronoi().

◆ dist_MinkovskyH()

static float dist_MinkovskyH ( float  x,
float  y,
float  z,
float  e 
)
static

Definition at line 906 of file noise.c.

References e, fabsf, sqrtf, x, y, and z.

Referenced by BLI_noise_voronoi().

◆ dist_Real()

static float dist_Real ( float  x,
float  y,
float  z,
float  e 
)
static

Definition at line 882 of file noise.c.

References e, sqrtf, x, y, and z.

Referenced by BLI_noise_voronoi().

◆ dist_Squared()

static float dist_Squared ( float  x,
float  y,
float  z,
float  e 
)
static

Definition at line 876 of file noise.c.

References e, x, y, and z.

Referenced by BLI_noise_voronoi().

◆ grad()

BLI_INLINE float grad ( int  hash_val,
float  x,
float  y,
float  z 
)

Definition at line 286 of file noise.c.

References v, x, y, and z.

Referenced by adjustSwingAxisToUseEllipseNormal(), newPerlin(), and btSdfCollisionShape::queryPoint().

◆ lerp()

BLI_INLINE float lerp ( float  t,
float  a,
float  b 
)

Definition at line 276 of file noise.c.

References Freestyle::a, and t.

Referenced by newPerlin(), and noise3_perlin().

◆ newPerlin()

static float newPerlin ( float  x,
float  y,
float  z 
)
static

◆ newPerlinU()

static float newPerlinU ( float  x,
float  y,
float  z 
)
static

Definition at line 332 of file noise.c.

References newPerlin(), x, y, and z.

Referenced by BLI_noise_generic_noise(), and BLI_noise_generic_turbulence().

◆ noise3_perlin()

static float noise3_perlin ( const float  vec[3])
static

◆ npfade()

BLI_INLINE float npfade ( float  t)

Definition at line 281 of file noise.c.

References t.

Referenced by newPerlin().

◆ orgBlenderNoise()

static float orgBlenderNoise ( float  x,
float  y,
float  z 
)
static

Definition at line 344 of file noise.c.

References floor(), hash, hashvectf, x, y, and z.

Referenced by BLI_noise_generic_noise(), BLI_noise_generic_turbulence(), BLI_noise_hnoise(), and orgBlenderNoiseS().

◆ orgBlenderNoiseS()

static float orgBlenderNoiseS ( float  x,
float  y,
float  z 
)
static

◆ orgPerlinNoise()

static float orgPerlinNoise ( float  x,
float  y,
float  z 
)
static

◆ orgPerlinNoiseU()

static float orgPerlinNoiseU ( float  x,
float  y,
float  z 
)
static

Definition at line 847 of file noise.c.

References noise3_perlin(), v, x, y, and z.

Referenced by BLI_noise_generic_noise(), and BLI_noise_generic_turbulence().

◆ voronoi_Cr()

static float voronoi_Cr ( float  x,
float  y,
float  z 
)
static

Definition at line 1061 of file noise.c.

References t, voronoi_F1F2(), x, y, and z.

Referenced by BLI_noise_generic_noise(), and BLI_noise_generic_turbulence().

◆ voronoi_CrS()

static float voronoi_CrS ( float  x,
float  y,
float  z 
)
static

◆ voronoi_F1()

static float voronoi_F1 ( float  x,
float  y,
float  z 
)
static

Definition at line 1025 of file noise.c.

References BLI_noise_voronoi(), x, y, and z.

Referenced by BLI_noise_generic_noise(), and BLI_noise_generic_turbulence().

◆ voronoi_F1F2()

static float voronoi_F1F2 ( float  x,
float  y,
float  z 
)
static

Definition at line 1053 of file noise.c.

References BLI_noise_voronoi(), x, y, and z.

Referenced by BLI_noise_generic_noise(), BLI_noise_generic_turbulence(), voronoi_Cr(), and voronoi_CrS().

◆ voronoi_F1F2S()

static float voronoi_F1F2S ( float  x,
float  y,
float  z 
)
static

◆ voronoi_F1S()

static float voronoi_F1S ( float  x,
float  y,
float  z 
)
static

◆ voronoi_F2()

static float voronoi_F2 ( float  x,
float  y,
float  z 
)
static

Definition at line 1032 of file noise.c.

References BLI_noise_voronoi(), x, y, and z.

Referenced by BLI_noise_generic_noise(), and BLI_noise_generic_turbulence().

◆ voronoi_F2S()

static float voronoi_F2S ( float  x,
float  y,
float  z 
)
static

◆ voronoi_F3()

static float voronoi_F3 ( float  x,
float  y,
float  z 
)
static

Definition at line 1039 of file noise.c.

References BLI_noise_voronoi(), x, y, and z.

Referenced by BLI_noise_generic_noise(), and BLI_noise_generic_turbulence().

◆ voronoi_F3S()

static float voronoi_F3S ( float  x,
float  y,
float  z 
)
static

◆ voronoi_F4()

static float voronoi_F4 ( float  x,
float  y,
float  z 
)
static

Definition at line 1046 of file noise.c.

References BLI_noise_voronoi(), x, y, and z.

Referenced by BLI_noise_generic_noise(), and BLI_noise_generic_turbulence().

◆ voronoi_F4S()

static float voronoi_F4S ( float  x,
float  y,
float  z 
)
static

Variable Documentation

◆ BLI_noise_hash_uchar_512

const unsigned char BLI_noise_hash_uchar_512

Definition at line 135 of file noise.c.

◆ g_perlin_data_ub

const char g_perlin_data_ub[512+2]
static

Definition at line 470 of file noise.c.

Referenced by noise3_perlin().

◆ g_perlin_data_v3

const float g_perlin_data_v3[512+2][3]
static

Definition at line 506 of file noise.c.

Referenced by noise3_perlin().

◆ hashpntf

const float hashpntf[768]
static

Definition at line 45 of file noise.c.

◆ hashvectf

const float hashvectf[768]
static

Definition at line 171 of file noise.c.

Referenced by orgBlenderNoise().