LibGame  v0.4.0
The LG Game Engine - Copyright (C) 2024-2025 ETMSoftware
lg_perlin_noise.c File Reference

Functions

fnl_state fnlCreateState ()
 
float fnlGetNoise2D (fnl_state *state, FNLfloat x, FNLfloat y)
 
float fnlGetNoise3D (fnl_state *state, FNLfloat x, FNLfloat y, FNLfloat z)
 
void fnlDomainWarp2D (fnl_state *state, FNLfloat *x, FNLfloat *y)
 
void fnlDomainWarp3D (fnl_state *state, FNLfloat *x, FNLfloat *y, FNLfloat *z)
 

Detailed Description

=== Perlin noise funcs ===

  • Range = [-sqrt(n / 4), sqrt(n / 4)] with n = dim
  • n = 2 -> [-0.7, 0.7]
  • Often and typically normalized to [-1.0, 1.0] in implementations

Now using FastNoiseLite lib by Jordan Peck - seems pretty good

NOTE: FOLLOWING CODE IS COPYRIGHT(C) 2023 JORDAN PECK

=== Fast Noise Lite ===

Function Documentation

◆ fnlCreateState()

fnl_state fnlCreateState ( )

Creates a noise state with default values.

Parameters
seedOptionally set the state seed.

◆ fnlGetNoise2D()

float fnlGetNoise2D ( fnl_state state,
FNLfloat  x,
FNLfloat  y 
)

2D noise at given position using the state settings

Returns
Noise output bounded between -1 and 1.

◆ fnlGetNoise3D()

float fnlGetNoise3D ( fnl_state state,
FNLfloat  x,
FNLfloat  y,
FNLfloat  z 
)

3D noise at given position using the state settings

Returns
Noise output bounded between -1 and 1.

◆ fnlDomainWarp2D()

void fnlDomainWarp2D ( fnl_state state,
FNLfloat *  x,
FNLfloat *  y 
)

2D warps the input position using current domain warp settings.

Example usage with fnlGetNoise2D:

fnlDomainWarp2D(&state, &x, &y);
noise = fnlGetNoise2D(&state, x, y);

◆ fnlDomainWarp3D()

void fnlDomainWarp3D ( fnl_state state,
FNLfloat *  x,
FNLfloat *  y,
FNLfloat *  z 
)

3D warps the input position using current domain warp settings.

Example usage with fnlGetNoise3D:

fnlDomainWarp3D(&state, &x, &y, &z);
noise = fnlGetNoise3D(&state, x, y, z);
fnlDomainWarp2D
void fnlDomainWarp2D(fnl_state *state, FNLfloat *x, FNLfloat *y)
Definition: lg_perlin_noise.c:2121
fnlGetNoise3D
float fnlGetNoise3D(fnl_state *state, FNLfloat x, FNLfloat y, FNLfloat z)
Definition: lg_perlin_noise.c:2104
fnlDomainWarp3D
void fnlDomainWarp3D(fnl_state *state, FNLfloat *x, FNLfloat *y, FNLfloat *z)
Definition: lg_perlin_noise.c:2136
fnlGetNoise2D
float fnlGetNoise2D(fnl_state *state, FNLfloat x, FNLfloat y)
Definition: lg_perlin_noise.c:2088