Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
fc952187
Commit
fc952187
authored
10 years ago
by
kwolekr
Browse files
Options
Downloads
Patches
Plain Diff
Add eased 3d point-value noise functions
parent
7616537b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/noise.cpp
+16
-9
16 additions, 9 deletions
src/noise.cpp
src/noise.h
+8
-3
8 additions, 3 deletions
src/noise.h
with
24 additions
and
12 deletions
src/noise.cpp
+
16
−
9
View file @
fc952187
...
...
@@ -215,7 +215,7 @@ float noise2d_gradient(float x, float y, int seed)
}
float
noise3d_gradient
(
float
x
,
float
y
,
float
z
,
int
seed
)
float
noise3d_gradient
(
float
x
,
float
y
,
float
z
,
int
seed
,
bool
eased
)
{
// Calculate the integer coordinates
int
x0
=
myfloor
(
x
);
...
...
@@ -235,10 +235,17 @@ float noise3d_gradient(float x, float y, float z, int seed)
float
v011
=
noise3d
(
x0
,
y0
+
1
,
z0
+
1
,
seed
);
float
v111
=
noise3d
(
x0
+
1
,
y0
+
1
,
z0
+
1
,
seed
);
// Interpolate
return
triLinearInterpolationNoEase
(
v000
,
v100
,
v010
,
v110
,
v001
,
v101
,
v011
,
v111
,
xl
,
yl
,
zl
);
if
(
eased
)
{
return
triLinearInterpolation
(
v000
,
v100
,
v010
,
v110
,
v001
,
v101
,
v011
,
v111
,
xl
,
yl
,
zl
);
}
else
{
return
triLinearInterpolationNoEase
(
v000
,
v100
,
v010
,
v110
,
v001
,
v101
,
v011
,
v111
,
xl
,
yl
,
zl
);
}
}
...
...
@@ -275,14 +282,14 @@ float noise2d_perlin_abs(float x, float y, int seed,
float
noise3d_perlin
(
float
x
,
float
y
,
float
z
,
int
seed
,
int
octaves
,
float
persistence
)
int
octaves
,
float
persistence
,
bool
eased
)
{
float
a
=
0
;
float
f
=
1.0
;
float
g
=
1.0
;
for
(
int
i
=
0
;
i
<
octaves
;
i
++
)
{
a
+=
g
*
noise3d_gradient
(
x
*
f
,
y
*
f
,
z
*
f
,
seed
+
i
);
a
+=
g
*
noise3d_gradient
(
x
*
f
,
y
*
f
,
z
*
f
,
seed
+
i
,
eased
);
f
*=
2.0
;
g
*=
persistence
;
}
...
...
@@ -291,14 +298,14 @@ float noise3d_perlin(float x, float y, float z, int seed,
float
noise3d_perlin_abs
(
float
x
,
float
y
,
float
z
,
int
seed
,
int
octaves
,
float
persistence
)
int
octaves
,
float
persistence
,
bool
eased
)
{
float
a
=
0
;
float
f
=
1.0
;
float
g
=
1.0
;
for
(
int
i
=
0
;
i
<
octaves
;
i
++
)
{
a
+=
g
*
fabs
(
noise3d_gradient
(
x
*
f
,
y
*
f
,
z
*
f
,
seed
+
i
));
a
+=
g
*
fabs
(
noise3d_gradient
(
x
*
f
,
y
*
f
,
z
*
f
,
seed
+
i
,
eased
));
f
*=
2.0
;
g
*=
persistence
;
}
...
...
This diff is collapsed.
Click to expand it.
src/noise.h
+
8
−
3
View file @
fc952187
...
...
@@ -134,7 +134,7 @@ float noise2d(int x, int y, int seed);
float
noise3d
(
int
x
,
int
y
,
int
z
,
int
seed
);
float
noise2d_gradient
(
float
x
,
float
y
,
int
seed
);
float
noise3d_gradient
(
float
x
,
float
y
,
float
z
,
int
seed
);
float
noise3d_gradient
(
float
x
,
float
y
,
float
z
,
int
seed
,
bool
eased
=
false
);
float
noise2d_perlin
(
float
x
,
float
y
,
int
seed
,
int
octaves
,
float
persistence
);
...
...
@@ -143,10 +143,10 @@ float noise2d_perlin_abs(float x, float y, int seed,
int
octaves
,
float
persistence
);
float
noise3d_perlin
(
float
x
,
float
y
,
float
z
,
int
seed
,
int
octaves
,
float
persistence
);
int
octaves
,
float
persistence
,
bool
eased
=
false
);
float
noise3d_perlin_abs
(
float
x
,
float
y
,
float
z
,
int
seed
,
int
octaves
,
float
persistence
);
int
octaves
,
float
persistence
,
bool
eased
=
false
);
inline
float
easeCurve
(
float
t
)
{
return
t
*
t
*
t
*
(
t
*
(
6.
f
*
t
-
15.
f
)
+
10.
f
);
...
...
@@ -182,5 +182,10 @@ float contour(float v);
noise3d_perlin((float)(x) / (np)->spread.X, (float)(y) / (np)->spread.Y, \
(float)(z) / (np)->spread.Z, (s) + (np)->seed, (np)->octaves, (np)->persist))
#define NoisePerlin3DEased(np, x, y, z, s) ((np)->offset + (np)->scale * \
noise3d_perlin((float)(x) / (np)->spread.X, (float)(y) / (np)->spread.Y, \
(float)(z) / (np)->spread.Z, (s) + (np)->seed, (np)->octaves, \
(np)->persist), true)
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment