HighMap library (C++)
Loading...
Searching...
No Matches
geo.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
10#pragma once
11
12#include "highmap/array.hpp"
13#include "highmap/functions.hpp"
16
17namespace hmap
18{
19
41Array caldera(glm::ivec2 shape,
42 float radius,
43 float sigma_inner,
44 float sigma_outer,
45 float z_bottom,
46 const Array *p_noise,
47 float noise_r_amp,
48 float noise_ratio_z,
49 glm::vec2 center = {0.5f, 0.5f},
50 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
51
52Array caldera(glm::ivec2 shape,
53 float radius,
54 float sigma_inner,
55 float sigma_outer,
56 float z_bottom,
57 glm::vec2 center = {0.5f, 0.5f},
58 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
59
96Array crater(glm::ivec2 shape,
97 float radius,
98 glm::vec2 center = {0.5f, 0.5f},
99 float angle = 30.f, // degs,
100 float inner_depth = 0.1f,
101 float inner_exp = 3.f,
102 float lip_height = 0.02f,
103 float lip_extent = 0.25f,
104 float lip_exp = 2.f,
105 float asym_ratio = 0.8f,
106 float central_peak_height = 0.01f,
107 float central_peak_extent = 0.4f,
108 int n_terraces = 0,
109 float terrace_extent = 0.1f,
110 float terrace_exp = 2.f,
111 float terrace_persistence = 0.5f,
112 const Array *p_noise_r = nullptr,
113 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
114 Array *p_crater_mask = nullptr,
115 Array *p_inner_crater_mask = nullptr);
116
145Array island_land_mask(glm::ivec2 shape,
146 float radius,
147 std::uint32_t seed,
148 float displacement = 0.2f,
149 NoiseType noise_type = NoiseType::SIMPLEX2S,
150 float kw = 4.f,
151 int octaves = 8,
152 float weight = 0.f,
153 float persistence = 0.5f,
154 float lacunarity = 2.f,
155 const glm::vec2 &center = {0.5f, 0.5f},
156 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
157
194Array island_chain_land_mask(glm::ivec2 shape,
195 const Path &path,
196 std::uint32_t seed,
197 int island_count = 5,
198 float island_radius = 0.1f,
199 float size_falloff = 0.5f,
200 float size_jitter = 0.3f,
201 float scatter = 0.f,
202 float displacement = 0.2f,
203 NoiseType noise_type = NoiseType::SIMPLEX2S,
204 float kw = 4.f,
205 int octaves = 8,
206 float weight = 0.f,
207 float persistence = 0.5f,
208 float lacunarity = 2.f,
209 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
210
249Array rift(glm::ivec2 shape,
250 float angle,
251 float radius = 0.1f,
252 float axial_slope = 0.2f,
253 float depth = 0.5f,
254 bool scale_with_depth = true,
256 float profile_param = 0.f,
257 float bottom_extent = 0.1,
258 float bottom_depth = 0.05f,
259 RadialProfile bottom_profile = RadialProfile::RP_SQRT,
260 float bottom_profile_param = 0.f,
261 bool bottom_force_minimum_depth = true,
262 float outer_slope = 0.5f,
263 const Array *p_noise_r = nullptr,
264 const Array *p_noise_offset = nullptr,
265 glm::vec2 center = {0.5f, 0.5f},
266 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
267 Array *p_rift_mask = nullptr,
268 Array *p_bottom_mask = nullptr);
269
270} // namespace hmap
271
272namespace hmap::gpu
273{
274
308Array badlands(glm::ivec2 shape,
309 glm::vec2 kw,
310 std::uint32_t seed,
311 int octaves = 8,
312 float rugosity = 0.2f,
313 float angle = 30.f,
314 float k_smoothing = 0.1f,
315 float base_noise_amp = 0.2f,
316 const Array *p_noise_x = nullptr,
317 const Array *p_noise_y = nullptr,
318 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
319
396Array basalt_field(glm::ivec2 shape,
397 glm::vec2 kw,
398 std::uint32_t seed,
399 float warp_kw = 4.f,
400 float large_scale_warp_amp = 0.2f,
401 float large_scale_gain = 6.f,
402 float large_scale_amp = 0.2f,
403 float medium_scale_kw_ratio = 3.f,
404 float medium_scale_warp_amp = 1.f,
405 float medium_scale_gain = 7.f,
406 float medium_scale_amp = 0.08f,
407 float small_scale_kw_ratio = 10.f,
408 float small_scale_amp = 0.1f,
409 float small_scale_overlay_amp = 0.002f,
410 float rugosity_kw_ratio = 1.f,
411 float rugosity_amp = 1.f,
412 bool flatten_activate = true,
413 float flatten_kw_ratio = 1.f,
414 float flatten_amp = 0.f,
415 const Array *p_noise_x = nullptr,
416 const Array *p_noise_y = nullptr,
417 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
418
457Array island(const Array &land_mask,
458 const Array *p_noise_r = nullptr,
459 float apex_elevation = 1.f,
460 bool filter_distance = true,
461 int filter_ir = 32,
462 float slope_min = 0.1f,
463 float slope_max = 8.f,
464 float slope_start = 0.5f,
465 float slope_end = 1.f,
466 float slope_noise_intensity = 0.5f,
467 float k_smooth = 0.05f,
468 float radial_noise_intensity = 0.3f,
469 float radial_profile_gain = 2.f,
470 float water_decay = 0.05f,
471 float water_depth = 0.3f,
472 float lee_angle = 30.f,
473 float lee_amp = 0.f,
474 float uplift_amp = 0.f,
475 Array *p_water_depth = nullptr,
476 Array *p_inland_mask = nullptr);
477
521Array island(const Array &land_mask,
522 std::uint32_t seed,
523 float noise_amp = 0.07f,
524 glm::vec2 noise_kw = {4.f, 4.f},
525 int noise_octaves = 8,
526 float noise_rugosity = 0.7f,
527 float noise_angle = 45.f,
528 float noise_k_smoothing = 0.05f,
529 float apex_elevation = 1.f,
530 bool filter_distance = true,
531 int filter_ir = 32,
532 float slope_min = 0.1f,
533 float slope_max = 8.f,
534 float slope_start = 0.5f,
535 float slope_end = 1.f,
536 float slope_noise_intensity = 0.5f,
537 float k_smooth = 0.05f,
538 float radial_noise_intensity = 0.3f,
539 float radial_profile_gain = 2.f,
540 float water_decay = 0.05f,
541 float water_depth = 0.3f,
542 float lee_angle = 30.f,
543 float lee_amp = 0.f,
544 float uplift_amp = 0.f,
545 Array *p_water_depth = nullptr,
546 Array *p_inland_mask = nullptr);
547
595Array mountain_cone(glm::ivec2 shape,
596 std::uint32_t seed,
597 float scale = 1.f,
598 int octaves = 8,
599 float peak_kw = 4.f,
600 float rugosity = 0.f,
601 float angle = 45.f,
602 float k_smoothing = 0.f,
603 float gamma = 0.5f,
604 float cone_alpha = 1.f,
605 float ridge_amp = 0.4f,
606 float base_noise_amp = 0.05f,
607 glm::vec2 center = {0.5f, 0.5f},
608 const Array *p_noise_x = nullptr,
609 const Array *p_noise_y = nullptr,
610 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
611
657Array mountain_inselberg(glm::ivec2 shape,
658 std::uint32_t seed,
659 float scale = 1.f,
660 int octaves = 8,
661 float rugosity = 0.2f,
662 float angle = 45.f,
663 float gamma = 1.1f,
664 bool round_shape = false,
665 bool add_deposition = true,
666 float bulk_amp = 0.2f,
667 float base_noise_amp = 0.2f,
668 float k_smoothing = 0.1f,
669 glm::vec2 center = {0.5f, 0.5f},
670 const Array *p_noise_x = nullptr,
671 const Array *p_noise_y = nullptr,
672 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
673
723Array mountain_range_radial(glm::ivec2 shape,
724 glm::vec2 kw,
725 std::uint32_t seed,
726 float half_width = 0.2f,
727 float angle_spread_ratio = 0.5f,
728 float core_size_ratio = 1.f,
729 glm::vec2 center = {0.5f, 0.5f},
730 int octaves = 8,
731 float weight = 0.7f,
732 float persistence = 0.5f,
733 float lacunarity = 2.f,
734 const Array *p_ctrl_param = nullptr,
735 const Array *p_noise_x = nullptr,
736 const Array *p_noise_y = nullptr,
737 const Array *p_angle = nullptr,
738 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
739
785Array mountain_stump(glm::ivec2 shape,
786 std::uint32_t seed,
787 float scale = 1.f,
788 int octaves = 8,
789 float peak_kw = 6.f,
790 float rugosity = 0.f,
791 float angle = 45.f,
792 float k_smoothing = 0.f,
793 float gamma = 0.25f,
794 bool add_deposition = true,
795 float ridge_amp = 0.75f,
796 float base_noise_amp = 0.1f,
797 glm::vec2 center = {0.5f, 0.5f},
798 const Array *p_noise_x = nullptr,
799 const Array *p_noise_y = nullptr,
800 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
801
847Array mountain_tibesti(glm::ivec2 shape,
848 std::uint32_t seed,
849 float scale = 1.f,
850 int octaves = 8,
851 float peak_kw = 20.f,
852 float rugosity = 0.f,
853 float angle = 30.f,
854 float angle_spread_ratio = 0.25f,
855 float gamma = 1.f,
856 bool add_deposition = true,
857 float bulk_amp = 1.f,
858 float base_noise_amp = 0.1f,
859 glm::vec2 center = {0.5f, 0.5f},
860 const Array *p_noise_x = nullptr,
861 const Array *p_noise_y = nullptr,
862 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
863
890Array plates(glm::ivec2 shape,
891 glm::vec2 kw,
892 std::uint32_t seed,
893 float talus,
894 int direction = 0,
895 float mix_ratio = 0.9f,
896 float base_noise_amp = 0.05f,
897 float kw_multiplier = 2.f,
898 int octaves = 8,
899 float rugosity = 0.f,
900 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
901
946Array shattered_peak(glm::ivec2 shape,
947 std::uint32_t seed,
948 float scale = 1.f,
949 int octaves = 8,
950 float peak_kw = 4.f,
951 float rugosity = 0.f,
952 float angle = 30.f,
953 float gamma = 1.f,
954 bool add_deposition = true,
955 float bulk_amp = 0.3f,
956 float base_noise_amp = 0.1f,
957 float k_smoothing = 0.f,
958 glm::vec2 center = {0.5f, 0.5f},
959 const Array *p_noise_x = nullptr,
960 const Array *p_noise_y = nullptr,
961 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
962
963} // namespace hmap::gpu
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Defines modular function objects for procedural generation, including noise algorithms (Perlin,...
Definition blending.hpp:225
Array mountain_stump(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=6.f, float rugosity=0.f, float angle=45.f, float k_smoothing=0.f, float gamma=0.25f, bool add_deposition=true, float ridge_amp=0.75f, float base_noise_amp=0.1f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generates a mountain-like heightmap with a flattened (stump-shaped) peak.
Definition mountain_stump.cpp:19
Array plates(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float talus, int direction=0, float mix_ratio=0.9f, float base_noise_amp=0.05f, float kw_multiplier=2.f, int octaves=8, float rugosity=0.f, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generate a tectonic plate–like heightfield using Voronoi FBM and directional talus projection.
Definition plates.cpp:17
Array badlands(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, int octaves=8, float rugosity=0.2f, float angle=30.f, float k_smoothing=0.1f, float base_noise_amp=0.2f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generates a synthetic "badlands" terrain heightmap.
Definition badlands.cpp:16
Array mountain_range_radial(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float half_width=0.2f, float angle_spread_ratio=0.5f, float core_size_ratio=1.f, glm::vec2 center={0.5f, 0.5f}, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_angle=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generates a heightmap representing a radial mountain range.
Definition primitives_gpu.cpp:511
Array basalt_field(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float warp_kw=4.f, float large_scale_warp_amp=0.2f, float large_scale_gain=6.f, float large_scale_amp=0.2f, float medium_scale_kw_ratio=3.f, float medium_scale_warp_amp=1.f, float medium_scale_gain=7.f, float medium_scale_amp=0.08f, float small_scale_kw_ratio=10.f, float small_scale_amp=0.1f, float small_scale_overlay_amp=0.002f, float rugosity_kw_ratio=1.f, float rugosity_amp=1.f, bool flatten_activate=true, float flatten_kw_ratio=1.f, float flatten_amp=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generates a synthetic procedural terrain resembling basaltic landforms.
Definition basalt_field.cpp:18
Array shattered_peak(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=4.f, float rugosity=0.f, float angle=30.f, float gamma=1.f, bool add_deposition=true, float bulk_amp=0.3f, float base_noise_amp=0.1f, float k_smoothing=0.f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generates a synthetic "shattered peak" terrain heightmap.
Definition shattered_peak.cpp:18
Array rugosity(const Array &z, int ir, bool convex=true)
See hmap::rugosity.
Definition local_metrics_gpu.cpp:219
Array mountain_tibesti(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=20.f, float rugosity=0.f, float angle=30.f, float angle_spread_ratio=0.25f, float gamma=1.f, bool add_deposition=true, float bulk_amp=1.f, float base_noise_amp=0.1f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generates a synthetic "Tibesti" mountain heightmap.
Definition mountain_tibesti.cpp:19
Array island(const Array &land_mask, const Array *p_noise_r=nullptr, float apex_elevation=1.f, bool filter_distance=true, int filter_ir=32, float slope_min=0.1f, float slope_max=8.f, float slope_start=0.5f, float slope_end=1.f, float slope_noise_intensity=0.5f, float k_smooth=0.05f, float radial_noise_intensity=0.3f, float radial_profile_gain=2.f, float water_decay=0.05f, float water_depth=0.3f, float lee_angle=30.f, float lee_amp=0.f, float uplift_amp=0.f, Array *p_water_depth=nullptr, Array *p_inland_mask=nullptr)
Generates an island heightmap from a land mask using radial profiles, slope shaping,...
Definition island.cpp:119
Array mountain_inselberg(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float rugosity=0.2f, float angle=45.f, float gamma=1.1f, bool round_shape=false, bool add_deposition=true, float bulk_amp=0.2f, float base_noise_amp=0.2f, float k_smoothing=0.1f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generates a synthetic mountain-like inselberg (isolated hill) heightmap.
Definition mountain_inselberg.cpp:19
Array mountain_cone(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=4.f, float rugosity=0.f, float angle=45.f, float k_smoothing=0.f, float gamma=0.5f, float cone_alpha=1.f, float ridge_amp=0.4f, float base_noise_amp=0.05f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generates a procedural "mountain cone" heightmap using fractal noise and Voronoi patterns.
Definition mountain_cone.cpp:20
Definition algebra.hpp:23
Array rift(glm::ivec2 shape, float angle, float radius=0.1f, float axial_slope=0.2f, float depth=0.5f, bool scale_with_depth=true, RadialProfile profile=RadialProfile::RP_SMOOTHSTEP, float profile_param=0.f, float bottom_extent=0.1, float bottom_depth=0.05f, RadialProfile bottom_profile=RadialProfile::RP_SQRT, float bottom_profile_param=0.f, bool bottom_force_minimum_depth=true, float outer_slope=0.5f, const Array *p_noise_r=nullptr, const Array *p_noise_offset=nullptr, glm::vec2 center={0.5f, 0.5f}, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f}, Array *p_rift_mask=nullptr, Array *p_bottom_mask=nullptr)
Generate a rift-shaped primitive.
Definition rift.cpp:18
Array island_chain_land_mask(glm::ivec2 shape, const Path &path, std::uint32_t seed, int island_count=5, float island_radius=0.1f, float size_falloff=0.5f, float size_jitter=0.3f, float scatter=0.f, float displacement=0.2f, NoiseType noise_type=NoiseType::SIMPLEX2S, float kw=4.f, int octaves=8, float weight=0.f, float persistence=0.5f, float lacunarity=2.f, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Generates a land mask of an island chain scattered along a path.
Definition island_chain.cpp:22
Array crater(glm::ivec2 shape, float radius, glm::vec2 center={0.5f, 0.5f}, float angle=30.f, float inner_depth=0.1f, float inner_exp=3.f, float lip_height=0.02f, float lip_extent=0.25f, float lip_exp=2.f, float asym_ratio=0.8f, float central_peak_height=0.01f, float central_peak_extent=0.4f, int n_terraces=0, float terrace_extent=0.1f, float terrace_exp=2.f, float terrace_persistence=0.5f, const Array *p_noise_r=nullptr, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f}, Array *p_crater_mask=nullptr, Array *p_inner_crater_mask=nullptr)
Generate a procedural impact crater heightmap.
Definition crater.cpp:67
RadialProfile
Radial profile type.
Definition profiles.hpp:51
@ RP_SMOOTHSTEP
Definition profiles.hpp:55
@ RP_SQRT
Definition profiles.hpp:58
Array caldera(glm::ivec2 shape, float radius, float sigma_inner, float sigma_outer, float z_bottom, const Array *p_noise, float noise_r_amp, float noise_ratio_z, glm::vec2 center={0.5f, 0.5f}, glm::vec4 bbox={0.f, 1.f, 0.f, 1.f})
Return a caldera-shaped heightmap.
Definition caldera.cpp:16
Cloud scale(const Cloud &cloud, glm::vec2 scale, glm::vec2 center={0.5f, 0.5f})
Scales the point coordinates in a cloud relative to a center point.
Definition cloud_functions.cpp:165
Array island_land_mask(glm::ivec2 shape, float radius, std::uint32_t seed, float displacement=0.2f, NoiseType noise_type=NoiseType::SIMPLEX2S, float kw=4.f, int octaves=8, float weight=0.f, float persistence=0.5f, float lacunarity=2.f, const glm::vec2 &center={0.5f, 0.5f}, const glm::vec4 &bbox={0.f, 1.f, 0.f, 1.f})
Generates a 2D island mask by perturbing a radial boundary with noise.
Definition island.cpp:25
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:52
NoiseType
Enumeration of various noise types used for procedural generation.
Definition functions.hpp:66
@ SIMPLEX2S
OpenSimplex2S.
Definition functions.hpp:72
Path class for manipulating and analyzing paths in 2D space.