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"
15
16namespace hmap
17{
18
40Array caldera(glm::ivec2 shape,
41 float radius,
42 float sigma_inner,
43 float sigma_outer,
44 float z_bottom,
45 const Array *p_noise,
46 float noise_amp_r,
47 float noise_ratio_z,
48 glm::vec2 center = {0.5f, 0.5f},
49 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
50
51Array caldera(glm::ivec2 shape,
52 float radius,
53 float sigma_inner,
54 float sigma_outer,
55 float z_bottom,
56 glm::vec2 center = {0.5f, 0.5f},
57 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
58
95Array crater(glm::ivec2 shape,
96 float radius,
97 glm::vec2 center = {0.5f, 0.5f},
98 float angle = 30.f, // degs,
99 float inner_depth = 0.1f,
100 float inner_exp = 3.f,
101 float lip_height = 0.02f,
102 float lip_extent = 0.25f,
103 float lip_exp = 2.f,
104 float asym_ratio = 0.8f,
105 float central_peak_height = 0.01f,
106 float central_peak_extent = 0.4f,
107 int n_terraces = 0,
108 float terrace_extent = 0.1f,
109 float terrace_exp = 2.f,
110 float terrace_persistence = 0.5f,
111 const Array *p_noise_r = nullptr,
112 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
113 Array *p_crater_mask = nullptr,
114 Array *p_inner_crater_mask = nullptr);
115
144Array island_land_mask(glm::ivec2 shape,
145 float radius,
146 std::uint32_t seed,
147 float displacement = 0.2f,
148 NoiseType noise_type = NoiseType::SIMPLEX2S,
149 float kw = 4.f,
150 int octaves = 8,
151 float weight = 0.f,
152 float persistence = 0.5f,
153 float lacunarity = 2.f,
154 const glm::vec2 &center = {0.5f, 0.5f},
155 const glm::vec4 &bbox = {0.f, 1.f, 0.f, 1.f});
156
195Array rift(glm::ivec2 shape,
196 float angle,
197 float radius = 0.1f,
198 float axial_slope = 0.2f,
199 float depth = 0.5f,
200 bool scale_with_depth = true,
202 float profile_param = 0.f,
203 float bottom_extent = 0.1,
204 float bottom_depth = 0.05f,
205 RadialProfile bottom_profile = RadialProfile::RP_SQRT,
206 float bottom_profile_param = 0.f,
207 bool bottom_force_minimum_depth = true,
208 float outer_slope = 0.5f,
209 const Array *p_noise_r = nullptr,
210 const Array *p_noise_offset = nullptr,
211 glm::vec2 center = {0.5f, 0.5f},
212 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f},
213 Array *p_rift_mask = nullptr,
214 Array *p_bottom_mask = nullptr);
215
216} // namespace hmap
217
218namespace hmap::gpu
219{
220
254Array badlands(glm::ivec2 shape,
255 glm::vec2 kw,
256 std::uint32_t seed,
257 int octaves = 8,
258 float rugosity = 0.2f,
259 float angle = 30.f,
260 float k_smoothing = 0.1f,
261 float base_noise_amp = 0.2f,
262 const Array *p_noise_x = nullptr,
263 const Array *p_noise_y = nullptr,
264 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
265
342Array basalt_field(glm::ivec2 shape,
343 glm::vec2 kw,
344 std::uint32_t seed,
345 float warp_kw = 4.f,
346 float large_scale_warp_amp = 0.2f,
347 float large_scale_gain = 6.f,
348 float large_scale_amp = 0.2f,
349 float medium_scale_kw_ratio = 3.f,
350 float medium_scale_warp_amp = 1.f,
351 float medium_scale_gain = 7.f,
352 float medium_scale_amp = 0.08f,
353 float small_scale_kw_ratio = 10.f,
354 float small_scale_amp = 0.1f,
355 float small_scale_overlay_amp = 0.002f,
356 float rugosity_kw_ratio = 1.f,
357 float rugosity_amp = 1.f,
358 bool flatten_activate = true,
359 float flatten_kw_ratio = 1.f,
360 float flatten_amp = 0.f,
361 const Array *p_noise_x = nullptr,
362 const Array *p_noise_y = nullptr,
363 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
364
403Array island(const Array &land_mask,
404 const Array *p_noise_r = nullptr,
405 float apex_elevation = 1.f,
406 bool filter_distance = true,
407 int filter_ir = 32,
408 float slope_min = 0.1f,
409 float slope_max = 8.f,
410 float slope_start = 0.5f,
411 float slope_end = 1.f,
412 float slope_noise_intensity = 0.5f,
413 float k_smooth = 0.05f,
414 float radial_noise_intensity = 0.3f,
415 float radial_profile_gain = 2.f,
416 float water_decay = 0.05f,
417 float water_depth = 0.3f,
418 float lee_angle = 30.f,
419 float lee_amp = 0.f,
420 float uplift_amp = 0.f,
421 Array *p_water_depth = nullptr,
422 Array *p_inland_mask = nullptr);
423
467Array island(const Array &land_mask,
468 std::uint32_t seed,
469 float noise_amp = 0.07f,
470 glm::vec2 noise_kw = {4.f, 4.f},
471 int noise_octaves = 8,
472 float noise_rugosity = 0.7f,
473 float noise_angle = 45.f,
474 float noise_k_smoothing = 0.05f,
475 float apex_elevation = 1.f,
476 bool filter_distance = true,
477 int filter_ir = 32,
478 float slope_min = 0.1f,
479 float slope_max = 8.f,
480 float slope_start = 0.5f,
481 float slope_end = 1.f,
482 float slope_noise_intensity = 0.5f,
483 float k_smooth = 0.05f,
484 float radial_noise_intensity = 0.3f,
485 float radial_profile_gain = 2.f,
486 float water_decay = 0.05f,
487 float water_depth = 0.3f,
488 float lee_angle = 30.f,
489 float lee_amp = 0.f,
490 float uplift_amp = 0.f,
491 Array *p_water_depth = nullptr,
492 Array *p_inland_mask = nullptr);
493
541Array mountain_cone(glm::ivec2 shape,
542 std::uint32_t seed,
543 float scale = 1.f,
544 int octaves = 8,
545 float peak_kw = 4.f,
546 float rugosity = 0.f,
547 float angle = 45.f,
548 float k_smoothing = 0.f,
549 float gamma = 0.5f,
550 float cone_alpha = 1.f,
551 float ridge_amp = 0.4f,
552 float base_noise_amp = 0.05f,
553 glm::vec2 center = {0.5f, 0.5f},
554 const Array *p_noise_x = nullptr,
555 const Array *p_noise_y = nullptr,
556 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
557
603Array mountain_inselberg(glm::ivec2 shape,
604 std::uint32_t seed,
605 float scale = 1.f,
606 int octaves = 8,
607 float rugosity = 0.2f,
608 float angle = 45.f,
609 float gamma = 1.1f,
610 bool round_shape = false,
611 bool add_deposition = true,
612 float bulk_amp = 0.2f,
613 float base_noise_amp = 0.2f,
614 float k_smoothing = 0.1f,
615 glm::vec2 center = {0.5f, 0.5f},
616 const Array *p_noise_x = nullptr,
617 const Array *p_noise_y = nullptr,
618 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
619
669Array mountain_range_radial(glm::ivec2 shape,
670 glm::vec2 kw,
671 std::uint32_t seed,
672 float half_width = 0.2f,
673 float angle_spread_ratio = 0.5f,
674 float core_size_ratio = 1.f,
675 glm::vec2 center = {0.5f, 0.5f},
676 int octaves = 8,
677 float weight = 0.7f,
678 float persistence = 0.5f,
679 float lacunarity = 2.f,
680 const Array *p_ctrl_param = nullptr,
681 const Array *p_noise_x = nullptr,
682 const Array *p_noise_y = nullptr,
683 const Array *p_angle = nullptr,
684 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
685
731Array mountain_stump(glm::ivec2 shape,
732 std::uint32_t seed,
733 float scale = 1.f,
734 int octaves = 8,
735 float peak_kw = 6.f,
736 float rugosity = 0.f,
737 float angle = 45.f,
738 float k_smoothing = 0.f,
739 float gamma = 0.25f,
740 bool add_deposition = true,
741 float ridge_amp = 0.75f,
742 float base_noise_amp = 0.1f,
743 glm::vec2 center = {0.5f, 0.5f},
744 const Array *p_noise_x = nullptr,
745 const Array *p_noise_y = nullptr,
746 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
747
793Array mountain_tibesti(glm::ivec2 shape,
794 std::uint32_t seed,
795 float scale = 1.f,
796 int octaves = 8,
797 float peak_kw = 20.f,
798 float rugosity = 0.f,
799 float angle = 30.f,
800 float angle_spread_ratio = 0.25f,
801 float gamma = 1.f,
802 bool add_deposition = true,
803 float bulk_amp = 1.f,
804 float base_noise_amp = 0.1f,
805 glm::vec2 center = {0.5f, 0.5f},
806 const Array *p_noise_x = nullptr,
807 const Array *p_noise_y = nullptr,
808 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
809
836Array plates(glm::ivec2 shape,
837 glm::vec2 kw,
838 std::uint32_t seed,
839 float talus,
840 int direction = 0,
841 float mix_ratio = 0.9f,
842 float base_noise_amp = 0.05f,
843 float kw_multiplier = 2.f,
844 int octaves = 8,
845 float rugosity = 0.f,
846 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
847
892Array shattered_peak(glm::ivec2 shape,
893 std::uint32_t seed,
894 float scale = 1.f,
895 int octaves = 8,
896 float peak_kw = 4.f,
897 float rugosity = 0.f,
898 float angle = 30.f,
899 float gamma = 1.f,
900 bool add_deposition = true,
901 float bulk_amp = 0.3f,
902 float base_noise_amp = 0.1f,
903 float k_smoothing = 0.f,
904 glm::vec2 center = {0.5f, 0.5f},
905 const Array *p_noise_x = nullptr,
906 const Array *p_noise_y = nullptr,
907 glm::vec4 bbox = {0.f, 1.f, 0.f, 1.f});
908
909} // 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:186
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:18
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:16
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:15
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:449
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:17
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:17
Array rugosity(const Array &z, int ir, bool convex=true)
See hmap::rugosity.
Definition local_metrics_gpu.cpp:194
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:18
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:116
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:18
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:19
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:17
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:66
RadialProfile
Radial profile type.
Definition profiles.hpp:51
@ RP_SMOOTHSTEP
Definition profiles.hpp:55
@ RP_SQRT
Definition profiles.hpp:58
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:24
Array caldera(glm::ivec2 shape, float radius, float sigma_inner, float sigma_outer, float z_bottom, const Array *p_noise, float noise_amp_r, 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:13
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:46
NoiseType
Enumeration of various noise types used for procedural generation.
Definition functions.hpp:67
@ SIMPLEX2S
OpenSimplex2S.
Definition functions.hpp:73