GLSL

Common

Utility functions required by gln other funcitons.

Methods

# inner gln_map(value, min1, max1, min2, max2) → {float}

Converts a number from one range to another.
Parameters:
Name Type Description
value Value to map
min1 float Minimum for current range
max1 float Maximum for current range
min2 float Minimum for wanted range
max2 float Maximum for wanted range
Mapped Value
float
Example
float n = gln_map(-0.2, -1.0, 1.0, 0.0, 1.0);
// n = 0.4

# inner gln_normalize(v) → {float}

Normalized a value from the range [-1, 1] to the range [0,1].
Parameters:
Name Type Description
v float Value to normalize
Normalized Value
float
Example
float n = gln_normalize(-0.2);
// n = 0.4

# inner gln_rand(n) → {float}

Generates a random number.
Parameters:
Name Type Description
n float Value to hash to generate the number from.
Random number.
float
Example
float n = gln_rand(2.5);

# inner gln_rand(p) → {float}

Generates a random number.
Parameters:
Name Type Description
p vec2 Value to hash to generate the number from.
Random number.
float
Example
float n = gln_rand(vec2(2.5, -1.8));

# inner gln_rand2(p) → {vec2}

Generates a random 2D Vector.
Parameters:
Name Type Description
p vec2 Vector to hash to generate the random numbers from.
Random vector.
vec2
Example
vec2 n = gln_rand2(vec2(1.0, -4.2));

# inner gln_rand3(p) → {vec3}

Generates a random 3D Vector.
Parameters:
Name Type Description
p vec3 Vector to hash to generate the random numbers from.
Random vector.
vec3
Example
vec3 n = gln_rand3(vec3(1.0, -4.2, 0.2));

# inner gln_rand4(p) → {vec4}

Generates a random 4D Vector.
Parameters:
Name Type Description
p vec4 Vector to hash to generate the random numbers from.
Random vector.
vec4
Example
vec4 n = gln_rand4(vec4(1.0, -4.2, 0.2, 2.2));

Type Definitions

struct

# gln_tFBMOpts

Options for fBm generators.
Properties:
Name Type Description
seed float Seed for PRNG generation.
persistance float Factor by which successive layers of noise will decrease in amplitude.
lacunarity float Factor by which successive layers of noise will increase in frequency.
scale float "Zoom level" of generated noise.
redistribution float Flatness in the generated noise.
octaves int Number of layers of noise to stack.
terbulance boolean Enable terbulance
ridge boolean Convert the fBm to Ridge Noise. Only works when "terbulance" is set to true.