-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperlin.3
More file actions
87 lines (87 loc) · 2.53 KB
/
perlin.3
File metadata and controls
87 lines (87 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.Dd September 3, 2015
.Dt LIBPERLIN 3
.Os
.Sh NAME
.Nm libperlin
.Nd Perlin noise generation library
.Sh SYNOPSIS
.In perlin.h
.Ft float
.Fo perlin_1d
.Fa "float x"
.Fa "float persistence"
.Fa "unsigned char octave_begin"
.Fa "unsigned char octave_end"
.Fc
.Ft float
.Fo perlin_2d
.Fa "float x"
.Fa "float y"
.Fa "float persistence"
.Fa "unsigned char octave_begin"
.Fa "unsigned char octave_end"
.Fc
.Ft float
.Fo perlin_3d
.Fa "float x"
.Fa "float y"
.Fa "float z"
.Fa "float persistence"
.Fa "unsigned char octave_begin"
.Fa "unsigned char octave_end"
.Fc
.Ft void
.Fo set_perlin_seed
.Fa "unsigned int seed"
.Fc
.Ft void
.Fo get_perlin_minmax
.Fa "float* min"
.Fa "float* max"
.Fa "float persistence"
.Fa "unsigned char octave_begin"
.Fa "unsigned char octave_end"
.Fc
.Sh DESCRIPTION
The libperlin library generates Perlin noise (continuous fractal noise) in 1, 2, and 3 dimensions.
.Pp
Perlin noise is generated by combining a series of octaves of smooth noise. Each octave interpolates between random values at a fixed interval. By decreasing this interval for successive octaves and combining the values, complicated but continuous fractal Brownian noise patterns can be generated.
.Pp
.Fn perlin_1d ,
.Fn perlin_2d , and
.Fn perlin_3d
all provide the ability to control the starting and ending octaves, which is an indirect control over the size of the patterns generated by the noise.
.Fa octave_begin
and
.Fa octave_end
must be non-negative, with octave_begin <= octave_end.
.Pp
The
.Fa persistence
argument is the factor by which the magnitude of each successive octave is diminished. A common value is 0.5, under which every octave contributes half as much to the noise as the previous.
.Pp
.Fn get_perlin_minmax
is used to determine the largest and smallest possible values of noise for a given range of octaves and persistence.
.Pp
Perlin noise is based on psuedorandom numbers, but it also has to be repeatable. Calling a Perlin noise function twice with the same parameters will return the same number. You can seed the noise generator by calling
.Fn set_perlin_seed .
The library makes no calls to
.Fn srand
or
.Fn rand .
.Pp
Perlin noise itself can be generated in any number of dimensions, but libperlin only supports up to three at this point.
.Sh RETURN VALUES
The
.Fn perlin_1d ,
.Fn perlin_2d ,
and
.Fn perlin_3d
functions return the summed Perlin noise value at the given coordinate(s) across the given octaves.
.Pp
.Fn get_perlin_minmax
stores the maximum and minimum possible values for a given octave range and persistence in its
.Fa min
and
.Fa max
arguments.