HighMap library (C++)
Loading...
Searching...
No Matches
functions.hpp
Go to the documentation of this file.
1/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
16#pragma once
17#include <functional>
18
19#include "FastNoiseLite.h"
20#include "macrologger.h"
21
22#include "highmap/array.hpp"
23#include "highmap/math.hpp"
24
29#define HMAP_FCT_XY_TYPE std::function<float(float, float, float)>
30
31#define HMAP_GRADIENT_OFFSET 0.001f
32
33namespace hmap
34{
35
49std::function<float(float, float)> make_xy_function_from_array(
50 const Array &array,
51 const Vec4<float> &bbox = {0.f, 1.f, 0.f, 1.f});
52
77
78//----------------------------------------
79// Base Function class and derived
80//----------------------------------------
81
88{
89public:
94 Function() : delegate([](float, float, float) { return 0.f; })
95 {
96 }
97
101 virtual ~Function() = default;
102
107 explicit Function(HMAP_FCT_XY_TYPE delegate) : delegate(std::move(delegate))
108 {
109 }
110
115 HMAP_FCT_XY_TYPE get_delegate() const;
116
124 float get_value(float x, float y, float ctrl_param) const;
125
130 void set_delegate(HMAP_FCT_XY_TYPE new_delegate);
131
132private:
133 HMAP_FCT_XY_TYPE delegate;
134};
135
146{
147public:
156 ArrayFunction(Array array, Vec2<float> kw, bool periodic = true);
157
163 void set_array(Array new_array)
164 {
165 this->array = new_array;
166 }
167
168protected:
170 bool periodic;
171
172private:
173 Array array;
174};
175
184{
185public:
193
194protected:
195 float gain;
197};
198
206class BumpFunction : public Function
207{
208public:
216
217protected:
218 float gain;
220};
221
230{
231public:
245 float depth,
246 float lip_decay,
247 float lip_height_ratio,
249
250protected:
251 float radius;
252 float depth;
253 float lip_decay;
256};
257
262class DiskFunction : public Function
263{
264public:
273
274protected:
275 float radius;
276 float slope;
278};
279
288{
289public:
297
303 void set_sigma(float new_sigma)
304 {
305 this->sigma = new_sigma;
306 this->inv_sigma2 = 1.f / (this->sigma * this->sigma);
307 }
308
309protected:
310 float sigma;
312
313private:
314 float inv_sigma2;
315};
316
322{
323public:
333 RectangleFunction(float rx,
334 float ry,
335 float angle,
336 float slope,
338
344 void set_angle(float new_angle)
345 {
346 this->angle = new_angle;
347 this->ca = std::cos(angle / 180.f * M_PI);
348 this->sa = std::sin(angle / 180.f * M_PI);
349 }
350
351protected:
352 float rx, ry;
353 float angle;
354 float slope;
356
357private:
358 float ca;
359 float sa;
360};
361
369class RiftFunction : public Function
370{
371public:
381 RiftFunction(float angle,
382 float slope,
383 float width,
384 bool sharp_bottom,
386
392 void set_angle(float new_angle)
393 {
394 this->angle = new_angle;
395 this->ca = std::cos(angle / 180.f * M_PI);
396 this->sa = std::sin(angle / 180.f * M_PI);
397 }
398
399protected:
400 float angle;
401 float slope;
402 float width;
405
406private:
407 float ca;
408 float sa;
409};
410
419{
420public:
429
435 void set_angle(float new_angle)
436 {
437 this->angle = new_angle;
438 this->ca = std::cos(angle / 180.f * M_PI);
439 this->sa = std::sin(angle / 180.f * M_PI);
440 }
441
442protected:
443 float angle;
444 float slope;
446
447private:
448 float ca;
449 float sa;
450};
451
459class StepFunction : public Function
460{
461public:
470
476 void set_angle(float new_angle)
477 {
478 this->angle = new_angle;
479 this->ca = std::cos(angle / 180.f * M_PI);
480 this->sa = std::sin(angle / 180.f * M_PI);
481 }
482
483protected:
484 float angle;
485 float slope;
487
488private:
489 float ca;
490 float sa;
491};
492
502{
503public:
517 float angle,
518 float xtop,
519 float xbottom,
520 float phase_shift);
521
527 void set_angle(float new_angle)
528 {
529 this->angle = new_angle;
530 this->ca = std::cos(angle / 180.f * M_PI);
531 this->sa = std::sin(angle / 180.f * M_PI);
532 }
533
534protected:
536 float angle;
537 float xtop;
538 float xbottom;
541
542private:
543 float ca;
544 float sa;
545};
546
555{
556public:
566
572 void set_angle(float new_angle)
573 {
574 this->angle = new_angle;
575 this->ca = std::cos(angle / 180.f * M_PI);
576 this->sa = std::sin(angle / 180.f * M_PI);
577 }
578
579protected:
581 float angle;
583
584private:
585 float ca;
586 float sa;
587};
588
597{
598public:
608
614 void set_angle(float new_angle)
615 {
616 this->angle = new_angle;
617 this->ca = std::cos(angle / 180.f * M_PI);
618 this->sa = std::sin(angle / 180.f * M_PI);
619 }
620
621protected:
623 float angle;
625
626private:
627 float ca;
628 float sa;
629};
630
640{
641public:
652 float angle,
653 float slant_ratio,
654 float phase_shift);
655
661 void set_angle(float new_angle)
662 {
663 this->angle = new_angle;
664 this->ca = std::cos(angle / 180.f * M_PI);
665 this->sa = std::sin(angle / 180.f * M_PI);
666 }
667
668protected:
670 float angle;
673
674private:
675 float ca;
676 float sa;
677};
678
679//----------------------------------------
680// NoiseFunction class and derived
681//----------------------------------------
682
693{
694public:
699 NoiseFunction() : Function(), kw(Vec2<float>(0.f, 0.f)), seed(0)
700 {
701 }
702
708 {
709 }
710
719
725 {
726 return this->kw;
727 }
728
734 {
735 return this->seed;
736 }
737
742 virtual void set_seed(uint new_seed)
743 {
744 this->seed = new_seed;
745 }
746
751 virtual void set_kw(Vec2<float> new_kw)
752 {
753 this->kw = new_kw;
754 }
755
756protected:
759};
760
761//----------------------------------------
762// Actual functions
763//----------------------------------------
764
769{
770public:
774 float mu;
775
785
789 void initialize();
790
796 void set_seed(uint /*new_seed*/)
797 {
798 // FIX ME seed cannot be changed with current implemtantion.
799 }
800
801private:
805 int perlin_b = 0X100;
806
810 int perlin_bm = 0xff;
811
815 int perlin_n = 0x100;
816
820 std::vector<int> p;
821
825 std::vector<std::vector<float>> g2;
826
830 std::vector<float> m;
831};
832
837{
838public:
847
853 void set_seed(uint new_seed)
854 {
855 NoiseFunction::set_seed(new_seed);
856 this->noise.SetSeed(new_seed);
857 }
858
859private:
863 FastNoiseLite noise;
864};
865
870{
871public:
880
886 void set_seed(uint new_seed)
887 {
888 NoiseFunction::set_seed(new_seed);
889 this->noise.SetSeed(new_seed);
890 }
891
892private:
896 FastNoiseLite noise;
897};
898
903{
904public:
905 float k;
906
916
922 void set_seed(uint new_seed)
923 {
924 NoiseFunction::set_seed(new_seed);
925 this->noise.SetSeed(new_seed);
926 }
927
928private:
932 FastNoiseLite noise;
933};
934
939{
940public:
949
955 void set_seed(uint new_seed)
956 {
957 NoiseFunction::set_seed(new_seed);
958 this->noise.SetSeed(new_seed);
959 }
960
961private:
965 FastNoiseLite noise;
966};
967
972{
973public:
982
988 void set_seed(uint new_seed)
989 {
990 NoiseFunction::set_seed(new_seed);
991 this->noise.SetSeed(new_seed);
992 }
993
994private:
998 FastNoiseLite noise;
999};
1000
1005{
1006public:
1015
1021 void set_seed(uint new_seed)
1022 {
1023 NoiseFunction::set_seed(new_seed);
1024 this->noise.SetSeed(new_seed);
1025 }
1026
1027private:
1031 FastNoiseLite noise;
1032};
1033
1038{
1039public:
1048
1054 void set_seed(uint new_seed)
1055 {
1056 NoiseFunction::set_seed(new_seed);
1057 this->noise.SetSeed(new_seed);
1058 }
1059
1060private:
1064 FastNoiseLite noise;
1065};
1066
1071{
1072public:
1081
1087 void set_seed(uint new_seed)
1088 {
1089 NoiseFunction::set_seed(new_seed);
1090 this->noise.SetSeed(new_seed);
1091 }
1092
1093private:
1097 FastNoiseLite noise;
1098};
1099
1104{
1105public:
1113
1119 void set_kw(Vec2<float> new_kw)
1120 {
1121 NoiseFunction::set_kw(new_kw);
1123 }
1124
1130 void set_seed(uint new_seed)
1131 {
1132 NoiseFunction::set_seed(new_seed);
1134 }
1135
1140};
1141
1146{
1147public:
1155
1161 void set_kw(Vec2<float> new_kw)
1162 {
1163 NoiseFunction::set_kw(new_kw);
1165 }
1166
1172 void set_seed(uint new_seed)
1173 {
1174 NoiseFunction::set_seed(new_seed);
1176 }
1177
1182};
1183
1188{
1189public:
1197 WorleyFunction(Vec2<float> kw, uint seed, bool return_cell_value = false);
1198
1204 void set_seed(uint new_seed)
1205 {
1206 NoiseFunction::set_seed(new_seed);
1207 this->noise.SetSeed(new_seed);
1208 }
1209
1210private:
1214 FastNoiseLite noise;
1215};
1216
1221{
1222public:
1226 float ratio;
1227
1231 float k;
1232
1243
1249 void set_seed(uint new_seed)
1250 {
1251 NoiseFunction::set_seed(new_seed);
1252 this->noise1.SetSeed(new_seed);
1253 this->noise2.SetSeed(new_seed + 1);
1254 }
1255
1256private:
1260 FastNoiseLite noise1, noise2;
1261};
1262
1263//----------------------------------------
1264// Composite functions
1265//----------------------------------------
1266
1277{
1278public:
1288 explicit GenericFractalFunction(std::unique_ptr<NoiseFunction> p_base,
1289 int octaves,
1290 float weight,
1291 float persistence,
1292 float lacunarity);
1293
1299 void set_kw(Vec2<float> new_kw) override
1300 {
1301 NoiseFunction::set_kw(new_kw);
1302 this->p_base->set_kw(new_kw);
1303 }
1304
1310 void set_lacunarity(float new_lacunarity)
1311 {
1312 this->lacunarity = new_lacunarity;
1313 }
1314
1320 void set_octaves(int new_octaves)
1321 {
1322 this->octaves = new_octaves;
1323 this->update_amp0();
1324 }
1325
1331 void set_persistence(float new_persistence)
1332 {
1333 this->persistence = new_persistence;
1334 this->update_amp0();
1335 }
1336
1342 void set_seed(uint new_seed) override
1343 {
1344 NoiseFunction::set_seed(new_seed);
1345 this->p_base->set_seed(new_seed);
1346 }
1347
1353 void scale_amp0(float scale)
1354 {
1355 this->amp0 *= scale;
1356 }
1357
1363 float get_lacunarity() const
1364 {
1365 return this->lacunarity;
1366 }
1367
1373 int get_octaves() const
1374 {
1375 return this->octaves;
1376 }
1377
1383 float get_persistence() const
1384 {
1385 return this->persistence;
1386 }
1387
1393 float get_weight() const
1394 {
1395 return this->weight;
1396 }
1397
1398protected:
1403 void update_amp0();
1404
1405protected:
1406 std::unique_ptr<NoiseFunction>
1409 float weight;
1412 float amp0;
1413};
1414
1420{
1421public:
1431 FbmFunction(std::unique_ptr<NoiseFunction> p_base,
1432 int octaves,
1433 float weight,
1434 float persistence,
1435 float lacunarity);
1436};
1442{
1443public:
1454 FbmIqFunction(std::unique_ptr<NoiseFunction> p_base,
1455 int octaves,
1456 float weight,
1457 float persistence,
1458 float lacunarity,
1459 float gradient_scale);
1460
1466 void set_gradient_scale(float new_gradient_scale)
1467 {
1468 this->gradient_scale = new_gradient_scale;
1469 }
1470
1471protected:
1473};
1474
1480{
1481public:
1495 FbmJordanFunction(std::unique_ptr<NoiseFunction> p_base,
1496 int octaves,
1497 float weight,
1498 float persistence,
1499 float lacunarity,
1500 float warp0,
1501 float damp0,
1502 float warp_scale,
1503 float damp_scale);
1504
1510 void set_warp0(float new_warp0)
1511 {
1512 this->warp0 = new_warp0;
1513 }
1514
1520 void set_damp0(float new_damp0)
1521 {
1522 this->damp0 = new_damp0;
1523 }
1524
1530 void set_warp_scale(float new_warp_scale)
1531 {
1532 this->warp_scale = new_warp_scale;
1533 }
1534
1540 void set_damp_scale(float new_damp_scale)
1541 {
1542 this->damp_scale = new_damp_scale;
1543 }
1544
1545protected:
1546 float warp0;
1547 float damp0;
1550};
1551
1557{
1558public:
1568 FbmPingpongFunction(std::unique_ptr<NoiseFunction> p_base,
1569 int octaves,
1570 float weight,
1571 float persistence,
1572 float lacunarity);
1573
1579 void set_k_smoothing(float new_k_smoothing)
1580 {
1581 this->k_smoothing = new_k_smoothing;
1582 }
1583
1584protected:
1586};
1587
1593{
1594public:
1605 FbmRidgedFunction(std::unique_ptr<NoiseFunction> p_base,
1606 int octaves,
1607 float weight,
1608 float persistence,
1609 float lacunarity,
1610 float k_smoothing);
1611
1617 void set_k_smoothing(float new_k_smoothing)
1618 {
1619 this->k_smoothing = new_k_smoothing;
1620 }
1621
1622protected:
1624};
1625
1631{
1632public:
1643 FbmSwissFunction(std::unique_ptr<NoiseFunction> p_base,
1644 int octaves,
1645 float weight,
1646 float persistence,
1647 float lacunarity,
1648 float warp_scale);
1649
1655 void set_warp_scale(float new_warp_scale)
1656 {
1657 this->warp_scale = new_warp_scale;
1658 this->warp_scale_normalized = new_warp_scale / this->kw.x;
1659 }
1660
1661protected:
1664};
1665
1666//----------------------------------------
1667// Field functions
1668//----------------------------------------
1669
1675{
1676public:
1682 FieldFunction(std::unique_ptr<Function> p_base);
1683
1695 FieldFunction(std::unique_ptr<Function> p_base,
1696 std::vector<float> xr,
1697 std::vector<float> yr,
1698 std::vector<float> zr);
1699
1705 void set_xr(std::vector<float> new_xr)
1706 {
1707 this->xr = new_xr;
1708 }
1709
1715 void set_yr(std::vector<float> new_yr)
1716 {
1717 this->yr = new_yr;
1718 }
1719
1726 void set_zr(std::vector<float> new_zr)
1727 {
1728 this->zr = new_zr;
1729 }
1730
1731protected:
1732 std::vector<float> xr;
1734 std::vector<float> yr;
1736 std::vector<float>
1739
1740private:
1741 std::unique_ptr<Function> p_base;
1742
1746 void setup_delegate();
1747};
1748
1749//----------------------------------------
1750// Helpers
1751//----------------------------------------
1752
1767std::unique_ptr<hmap::NoiseFunction> create_noise_function_from_type(
1768 NoiseType noise_type,
1769 Vec2<float> kw,
1770 uint seed);
1771
1772} // namespace hmap
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
unsigned int uint
Definition array.hpp:14
Array (x, y) function class.
Definition functions.hpp:146
bool periodic
Flag indicating whether the domain is periodic or not.
Definition functions.hpp:170
Vec2< float > kw
Frequency scaling vector.
Definition functions.hpp:169
void set_array(Array new_array)
Set the array object.
Definition functions.hpp:163
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
Biquad (x, y) function class.
Definition functions.hpp:184
float gain
Gain value that controls the steepness of the bump.
Definition functions.hpp:195
Vec2< float > center
Primitive reference center.
Definition functions.hpp:196
Bump (x, y) function class.
Definition functions.hpp:207
Vec2< float > center
Primitive reference center.
Definition functions.hpp:219
float gain
Gain value that controls the steepness of the bump.
Definition functions.hpp:218
Crater (x, y) function class.
Definition functions.hpp:230
float depth
Depth of the crater.
Definition functions.hpp:252
Vec2< float > center
Primitive reference center.
Definition functions.hpp:255
float lip_decay
Decay rate of the crater's lip.
Definition functions.hpp:253
float radius
Radius of the crater.
Definition functions.hpp:251
float lip_height_ratio
Height ratio of the crater's lip.
Definition functions.hpp:254
DiskFunction (x, y) function class.
Definition functions.hpp:263
float radius
Radius of the disk.
Definition functions.hpp:275
Vec2< float > center
Primitive reference center.
Definition functions.hpp:277
float slope
Slope of the disk.
Definition functions.hpp:276
Fractional Brownian Motion (FBM) function class.
Definition functions.hpp:1420
IQ layering function class.
Definition functions.hpp:1442
float gradient_scale
Gradient scale influence.
Definition functions.hpp:1472
void set_gradient_scale(float new_gradient_scale)
Set the gradient scale.
Definition functions.hpp:1466
Jordan layering function class.
Definition functions.hpp:1480
void set_damp0(float new_damp0)
Set the initial damp.
Definition functions.hpp:1520
float warp0
Initial warp.
Definition functions.hpp:1546
void set_warp0(float new_warp0)
Set the initial warp.
Definition functions.hpp:1510
float damp_scale
Damp scale.
Definition functions.hpp:1549
float damp0
Initial damp.
Definition functions.hpp:1547
void set_warp_scale(float new_warp_scale)
Set the warp scale.
Definition functions.hpp:1530
float warp_scale
Warp scale.
Definition functions.hpp:1548
void set_damp_scale(float new_damp_scale)
Set the damp scale.
Definition functions.hpp:1540
Pingpong layering function class.
Definition functions.hpp:1557
void set_k_smoothing(float new_k_smoothing)
Set the smoothing parameter.
Definition functions.hpp:1579
float k_smoothing
Smoothing parameter.
Definition functions.hpp:1585
Ridged layering function class.
Definition functions.hpp:1593
float k_smoothing
Smoothing parameter.
Definition functions.hpp:1623
void set_k_smoothing(float new_k_smoothing)
Set the smoothing parameter.
Definition functions.hpp:1617
Swiss layering function class.
Definition functions.hpp:1631
void set_warp_scale(float new_warp_scale)
Set the warp scale.
Definition functions.hpp:1655
float warp_scale
Warping scale.
Definition functions.hpp:1662
float warp_scale_normalized
Normalized warping scale.
Definition functions.hpp:1663
Field function class.
Definition functions.hpp:1675
std::vector< float > yr
Definition functions.hpp:1734
void set_xr(std::vector< float > new_xr)
Set the x coordinates representing the centers of the primitive.
Definition functions.hpp:1705
void set_yr(std::vector< float > new_yr)
Set the y coordinates representing the centers of the primitive.
Definition functions.hpp:1715
std::vector< float > xr
Definition functions.hpp:1732
void set_zr(std::vector< float > new_zr)
Set the z coordinates used to scale the primitive in x and y directions, and also to scale the primit...
Definition functions.hpp:1726
std::vector< float > zr
Definition functions.hpp:1737
A class that wraps a callable entity taking three floats and returning a float.
Definition functions.hpp:88
Function()
Default constructor. Initializes the delegate function to a default that returns 0.
Definition functions.hpp:94
HMAP_FCT_XY_TYPE get_delegate() const
Get the current delegate function.
Definition functions.cpp:38
void set_delegate(HMAP_FCT_XY_TYPE new_delegate)
Set a new delegate function.
Definition functions.cpp:48
float get_value(float x, float y, float ctrl_param) const
Call the delegate function with given arguments.
Definition functions.cpp:43
virtual ~Function()=default
Virtual destructor to ensure proper cleanup in derived classes.
Function(HMAP_FCT_XY_TYPE delegate)
Constructor to initialize with a specific delegate function.
Definition functions.hpp:107
GaussianPulse (x, y) function class.
Definition functions.hpp:288
Vec2< float > center
Primitive reference center.
Definition functions.hpp:311
float sigma
Pulse half-width.
Definition functions.hpp:310
void set_sigma(float new_sigma)
Set the half-width.
Definition functions.hpp:303
A class for generating fractal noise functions based on an underlying noise function.
Definition functions.hpp:1277
void set_kw(Vec2< float > new_kw) override
Set the frequency scaling vector.
Definition functions.hpp:1299
float get_weight() const
Get the weight of the fractal noise.
Definition functions.hpp:1393
void set_octaves(int new_octaves)
Set the number of octaves in the fractal noise.
Definition functions.hpp:1320
void set_seed(uint new_seed) override
Set a new random seed for the noise generation.
Definition functions.hpp:1342
void set_persistence(float new_persistence)
Set the persistence of the fractal noise.
Definition functions.hpp:1331
void scale_amp0(float scale)
Scale the initial amplitude of the fractal noise.
Definition functions.hpp:1353
int octaves
Number of octaves in the fractal noise.
Definition functions.hpp:1408
float get_lacunarity() const
Get the lacunarity of the fractal noise.
Definition functions.hpp:1363
float weight
Weight of the base noise function.
Definition functions.hpp:1409
int get_octaves() const
Get the number of octaves in the fractal noise.
Definition functions.hpp:1373
float amp0
Initial amplitude of the fractal noise.
Definition functions.hpp:1412
std::unique_ptr< NoiseFunction > p_base
Unique pointer to the base noise function.
Definition functions.hpp:1407
float lacunarity
Lacunarity of the fractal noise.
Definition functions.hpp:1411
float get_persistence() const
Get the persistence of the fractal noise.
Definition functions.hpp:1383
float persistence
Persistence of the fractal noise.
Definition functions.hpp:1410
void set_lacunarity(float new_lacunarity)
Set the lacunarity of the fractal noise.
Definition functions.hpp:1310
void update_amp0()
Update the initial amplitude (amp0) based on the current octaves and persistence.
Definition fbm_functions.cpp:391
A class for generating noise functions.
Definition functions.hpp:693
virtual void set_kw(Vec2< float > new_kw)
Set a new frequency scaling vector.
Definition functions.hpp:751
uint get_seed() const
Get the random seed.
Definition functions.hpp:733
Vec2< float > kw
Frequency scaling vector.
Definition functions.hpp:757
virtual void set_seed(uint new_seed)
Set a new random seed for noise generation.
Definition functions.hpp:742
NoiseFunction()
Default constructor. Initializes with default frequency scaling and seed.
Definition functions.hpp:699
uint seed
Random seed for noise generation.
Definition functions.hpp:758
NoiseFunction(Vec2< float > kw)
Constructor to initialize with specific frequency scaling.
Definition functions.hpp:707
NoiseFunction(Vec2< float > kw, uint seed)
Constructor to initialize with specific frequency scaling and seed.
Definition functions.hpp:716
Vec2< float > get_kw() const
Get the frequency scaling vector.
Definition functions.hpp:724
Parberry (x, y) function class.
Definition functions.hpp:769
void initialize()
Initialize generator.
Definition parberry_function.cpp:25
float mu
Gradient magnitude exponent.
Definition functions.hpp:774
void set_seed(uint)
Set the seed attribute.
Definition functions.hpp:796
Perlin 'billow' (x, y) function class.
Definition functions.hpp:870
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:886
Perlin (x, y) function class.
Definition functions.hpp:837
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:853
Perlin 'half' (x, y) function class.
Definition functions.hpp:903
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:922
float k
Definition functions.hpp:905
Perlin 'mix' (x, y) function class.
Definition functions.hpp:939
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:955
RectangleFunction (x, y) function class.
Definition functions.hpp:322
void set_angle(float new_angle)
Set the angle.
Definition functions.hpp:344
float rx
Definition functions.hpp:352
float ry
Radius of the rectangle.
Definition functions.hpp:352
Vec2< float > center
Primitive reference center.
Definition functions.hpp:355
float slope
Slope of the rectangle.
Definition functions.hpp:354
float angle
Angle of the rectangle.
Definition functions.hpp:353
Rift (x, y) function class.
Definition functions.hpp:370
bool sharp_bottom
Rift bottom sharpness.
Definition functions.hpp:403
float angle
Overall rotation angle (in degrees).
Definition functions.hpp:400
float width
Rift width.
Definition functions.hpp:402
void set_angle(float new_angle)
Set the angle.
Definition functions.hpp:392
float slope
Rift slope.
Definition functions.hpp:401
Vec2< float > center
Primitive reference center.
Definition functions.hpp:404
OpenSimplex2 (x, y) function class.
Definition functions.hpp:972
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:988
OpenSimplex2S (x, y) function class.
Definition functions.hpp:1005
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:1021
Slope (x, y) function class.
Definition functions.hpp:419
float slope
Step slope.
Definition functions.hpp:444
Vec2< float > center
Primitive reference center.
Definition functions.hpp:445
void set_angle(float new_angle)
Set the angle.
Definition functions.hpp:435
float angle
Overall rotation angle (in degrees).
Definition functions.hpp:443
Step (x, y) function class.
Definition functions.hpp:460
Vec2< float > center
Primitive reference center.
Definition functions.hpp:486
float angle
Overall rotation angle (in degrees).
Definition functions.hpp:484
float slope
Step slope.
Definition functions.hpp:485
void set_angle(float new_angle)
Set the angle.
Definition functions.hpp:476
Value Cubic noise (x, y) function class.
Definition functions.hpp:1071
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:1087
ValueDelaunayNoise (x, y) function class.
Definition functions.hpp:1104
void update_interpolation_function()
Update base interpolation.
Definition noise_functions.cpp:138
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:1130
void set_kw(Vec2< float > new_kw)
Set the wavenumber attribute.
Definition functions.hpp:1119
ValueLinearNoiseFunction (x, y) function class.
Definition functions.hpp:1146
void set_kw(Vec2< float > new_kw)
Set the wavenumber attribute.
Definition functions.hpp:1161
void update_interpolation_function()
Update base interpolation.
Definition noise_functions.cpp:223
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:1172
Value noise (x, y) function class.
Definition functions.hpp:1038
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:1054
Wave dune (x, y) function class.
Definition functions.hpp:502
Vec2< float > kw
Frequency scaling vector.
Definition functions.hpp:535
float xbottom
1]).
Definition functions.hpp:538
float xtop
Relative location of the top of the dune profile (in [0, 1]).
Definition functions.hpp:537
float angle
Overall rotation angle (in degrees).
Definition functions.hpp:536
void set_angle(float new_angle)
Set the angle.
Definition functions.hpp:527
float phase_shift
Phase shift (in radians).
Definition functions.hpp:540
Wave sine (x, y) function class.
Definition functions.hpp:555
Vec2< float > kw
Frequency scaling vector.
Definition functions.hpp:580
void set_angle(float new_angle)
Set the angle.
Definition functions.hpp:572
float angle
Overall rotation angle (in degrees).
Definition functions.hpp:581
float phase_shift
Phase shift (in radians).
Definition functions.hpp:582
Wave square (x, y) function class.
Definition functions.hpp:597
Vec2< float > kw
Frequency scaling vector.
Definition functions.hpp:622
void set_angle(float new_angle)
Set the angle.
Definition functions.hpp:614
float phase_shift
Phase shift (in radians).
Definition functions.hpp:624
float angle
Overall rotation angle (in degrees).
Definition functions.hpp:623
Wave triangular (x, y) function class.
Definition functions.hpp:640
float slant_ratio
Relative location of the triangle apex, in [0, 1].
Definition functions.hpp:671
Vec2< float > kw
Frequency scaling vector.
Definition functions.hpp:669
float angle
Overall rotation angle (in degrees).
Definition functions.hpp:670
float phase_shift
Phase shift (in radians).
Definition functions.hpp:672
void set_angle(float new_angle)
Set the angle.
Definition functions.hpp:661
Worley (x, y) function class.
Definition functions.hpp:1221
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:1249
float ratio
Amplitude ratio between each Worley noise.
Definition functions.hpp:1226
float k
Transition smoothing parameter.
Definition functions.hpp:1231
Worley (x, y) function class.
Definition functions.hpp:1188
void set_seed(uint new_seed)
Set the seed attribute.
Definition functions.hpp:1204
Provides core mathematical utilities for procedural generation, including trigonometry,...
Definition algebra.hpp:28
std::unique_ptr< hmap::NoiseFunction > create_noise_function_from_type(NoiseType noise_type, Vec2< float > kw, uint seed)
Create a noise function based on the specified noise type.
Definition noise_functions.cpp:334
std::function< float(float, float)> make_xy_function_from_array(const Array &array, const Vec4< float > &bbox={0.f, 1.f, 0.f, 1.f})
Create a continuous 2D function from a sampled array.
Definition functions.cpp:10
NoiseType
Enumeration of various noise types used for procedural generation.
Definition functions.hpp:62
@ WORLEY
Worley.
Definition functions.hpp:73
@ SIMPLEX2S
OpenSimplex2S.
Definition functions.hpp:68
@ WORLEY_DOUBLE
Worley double.
Definition functions.hpp:74
@ VALUE_DELAUNAY
Value (delaunay)
Definition functions.hpp:71
@ PERLIN_BILLOW
Perlin billow.
Definition functions.hpp:65
@ PARBERRY
Parberry (Perlin variant)
Definition functions.hpp:63
@ WORLEY_VALUE
Worley (cell value return)
Definition functions.hpp:75
@ PERLIN
Perlin.
Definition functions.hpp:64
@ SIMPLEX2
OpenSimplex2.
Definition functions.hpp:67
@ PERLIN_HALF
Perlin half.
Definition functions.hpp:66
@ VALUE_LINEAR
Value (linear)
Definition functions.hpp:72
@ VALUE_CUBIC
Value (cubic)
Definition functions.hpp:70
@ VALUE
Value.
Definition functions.hpp:69
Vec2 class for basic manipulation of 2D vectors.
Definition algebra.hpp:40
T x
Definition algebra.hpp:41