|
HighMap library (C++)
|
Namespaces | |
| namespace | gpu |
| namespace | va |
| namespace | neighborhood |
| namespace | log |
| namespace | cte |
Classes | |
| struct | IVec2Hash |
| struct | IVec2Eq |
| struct | IVec4Hash |
| struct | IVec4Eq |
| struct | Mat |
| Mat class for basic manipulation of 2D matrices. More... | |
| class | Array |
| Array class, helper to manipulate 2D float array with "(i, j)" indexing. More... | |
| struct | DeformationConstraint |
| Per-vertex penalty term used by sls_deformation. More... | |
| struct | GaussianPush |
| Truncated-Gaussian push operation, the elementary deformation used by sls_deformation. More... | |
| struct | ColorAdjust |
| struct | TerrainTextureParams |
| struct | AffineTransform2D |
| Lightweight 2D affine transformation mapping (x, y) -> (ax*x + bx*y + cx, ay*x + by*y + cy). More... | |
| class | CoordFrame |
| class | ICommunicator |
| Abstract communicator interface providing MPI-style collective directives for single-source SPMD Array algorithms. More... | |
| class | SingleArrayComm |
| Default standalone communicator for single-array computation. All collective calls are identity or no-ops, resulting in zero overhead. More... | |
| struct | MiseParams |
| Parameters for the MISE (Multiscale Implicit Stream-power Erosion) solver. More... | |
| class | BigTiffWriter |
| struct | ImageWriterConfig |
| class | ImageWriter |
| class | OpenCVWriter |
| class | OpenEXRWriter |
| struct | PointOfInterest |
| Represents a terrain-aware point of interest with physical descriptors. More... | |
| struct | PoiGenerationOptions |
| Configuration parameters for procedural point-of-interest generation. More... | |
| class | ArrayFunction |
| Array (x, y) function class. More... | |
| class | BiquadFunction |
| Biquad (x, y) function class. More... | |
| class | BumpFunction |
| Bump (x, y) function class. More... | |
| class | CraterFunction |
| Crater (x, y) function class. More... | |
| class | DiskFunction |
| DiskFunction (x, y) function class. More... | |
| class | GaussianPulseFunction |
| GaussianPulse (x, y) function class. More... | |
| class | QuadSurfaceFunction |
| Quadratic surface function defined by four corner values. More... | |
| class | RectangleFunction |
| RectangleFunction (x, y) function class. More... | |
| class | RiftFunction |
| Rift (x, y) function class. More... | |
| class | SlopeFunction |
| Slope (x, y) function class. More... | |
| class | StepFunction |
| Step (x, y) function class. More... | |
| class | WaveDuneFunction |
| Wave dune (x, y) function class. More... | |
| class | WaveSineFunction |
| Wave sine (x, y) function class. More... | |
| class | WaveSquareFunction |
| Wave square (x, y) function class. More... | |
| class | WaveTriangularFunction |
| Wave triangular (x, y) function class. More... | |
| class | NoiseFunction |
| A class for generating noise functions. More... | |
| class | ParberryFunction |
| Parberry (x, y) function class. More... | |
| class | PerlinFunction |
| Perlin (x, y) function class. More... | |
| class | PerlinBillowFunction |
| Perlin 'billow' (x, y) function class. More... | |
| class | PerlinHalfFunction |
| Perlin 'half' (x, y) function class. More... | |
| class | PerlinMixFunction |
| Perlin 'mix' (x, y) function class. More... | |
| class | Simplex2Function |
| OpenSimplex2 (x, y) function class. More... | |
| class | Simplex2SFunction |
| OpenSimplex2S (x, y) function class. More... | |
| class | ValueNoiseFunction |
| Value noise (x, y) function class. More... | |
| class | ValueCubicNoiseFunction |
| Value Cubic noise (x, y) function class. More... | |
| class | ValueDelaunayNoiseFunction |
| ValueDelaunayNoise (x, y) function class. More... | |
| class | ValueLinearNoiseFunction |
| ValueLinearNoiseFunction (x, y) function class. More... | |
| class | WorleyFunction |
| Worley (x, y) function class. More... | |
| class | WorleyDoubleFunction |
| Worley (x, y) function class. More... | |
| class | GenericFractalFunction |
| A class for generating fractal noise functions based on an underlying noise function. More... | |
| class | FbmFunction |
| Fractional Brownian Motion (FBM) function class. More... | |
| class | FbmIqFunction |
| IQ layering function class. More... | |
| class | FbmJordanFunction |
| Jordan layering function class. More... | |
| class | FbmPingpongFunction |
| Pingpong layering function class. More... | |
| class | FbmRidgedFunction |
| Ridged layering function class. More... | |
| class | FbmSlopeFunction |
| Slope-weighted FBM layering function class. More... | |
| class | FbmSwissFunction |
| Swiss layering function class. More... | |
| class | FieldFunction |
| Field function class. More... | |
| struct | AABB2D |
| 2D Axis-Aligned Bounding Box (AABB). More... | |
| struct | Segment2D |
| 2D Directed line segment with metadata. More... | |
| class | BVH2D |
| 2D Linear Bounding Volume Hierarchy for line segments. More... | |
| class | CellPath |
| Ordered path of grid cell indices. More... | |
| class | Cloud |
| Represents a collection of unordered points in 2D space. More... | |
| struct | Edge |
| Graph edge connecting two node indices with an associated weight. More... | |
| struct | Neighbor |
| Graph neighbor information for adjacency representation. More... | |
| class | Graph |
| Graph class, to manipulate graphs in 2D. More... | |
| class | InverseSampler2D |
| Sequential 2D inverse transform point sampler based on a 2D density array. More... | |
| class | KDTree |
| 2D KD-Tree for spatial point queries. More... | |
| class | Path |
| Represents an ordered set of points in 2D, forming a polyline (open or closed). More... | |
| class | Point |
| A class to represent and manipulate 2D points that can carry a value. More... | |
| struct | FlowGraph |
| struct | AssertResults |
| struct | RadixHeap |
| struct | Recorder |
| The Recorder class is responsible for recording timing information for individual events. More... | |
| class | Timer |
| The Timer class is a singleton that manages multiple Recorders and provides an interface for timing events. More... | |
| struct | ScopedTimer |
| class | Interpolator1D |
| A class for performing 1D interpolation using the GSL library. More... | |
| class | NaturalNeighborInterpolator |
| class | InterpolatorCurve |
| Class for performing curve interpolation on a set of points. More... | |
| class | ChebyshevEvaluator |
| Evaluates a Chebyshev polynomial series using Clenshaw recurrence. More... | |
| class | ArrayControlFunction |
| class | XyControlFunction |
| class | PdfSampler |
| Samples indices from a discrete probability distribution. More... | |
| class | ScatterField |
| Container and processor for spatial ScatterItem collections. More... | |
| class | ScatterItem |
| Represents a single spatial instance (tree, rock, prop) with position, class identifier, and radius. More... | |
| struct | ScatterSeedingOptions |
| Configuration parameters for scatter seeding algorithms. More... | |
| struct | BBox2D |
| Axis-aligned 2D bounding box in world coordinates. More... | |
| struct | UvRect |
| Axis-aligned rectangle in normalized [0, 1]^2 domain/UV space. More... | |
| struct | TileKey |
| struct | UvTile |
| Describes an Array tile's position within the normalized [0, 1]^2 UV domain and global index grid. More... | |
| class | TerrainTriMesh |
| Triangle mesh representation of a terrain surface. More... | |
| class | Texture |
| A class to represent a multi-channel texture using planar hmap::Array storage. More... | |
| struct | TerrainAlignment |
| Elevation offset and tilt parameters for aligning an upper terrain. More... | |
| class | SequentialTileComm |
| Communicator for single-threaded sequential tile traversal. Supports cooperative fiber suspension (Option A2) so iterative collective calls (sync_overlap_buffers, all_reduce, all_union, barrier) synchronize across all tiles using a disk-backed temporary VirtualArray (VA_DISK_LRU_STREAM). More... | |
| class | ThreadedCollectiveState |
| Shared synchronization state for multi-threaded tile communication. More... | |
| class | ThreadedTileComm |
| Thread-local communicator proxy connected to a ThreadedCollectiveState. More... | |
| struct | TileKeyHash |
| class | TileStorage |
| class | RamTileStorage |
| struct | LruTileEntry |
| class | DiskLruTileStorage |
| struct | ComputeMode |
| struct | VirtualArray |
| class | VirtualTexture |
| struct | VirtualTextureStorage |
| Storage manager for VirtualTexture. More... | |
| class | Forest |
| Container class representing a collection of Tree instances. More... | |
| struct | InteractionMatrix |
| Generic S x S matrix representing pair-wise interaction properties between species. More... | |
| struct | ForestScaleSampler |
| Helper for sampling spatial scaling maps over a 2D bounding box with blending. More... | |
| struct | SpeciesLookup |
| Helper for querying species traits and pairwise competition factors. More... | |
| struct | ForestSeedingOptions |
| Configuration parameters for forest seeding algorithms. More... | |
| struct | Species |
| Encapsulates biological and geometric traits of a tree species. More... | |
| struct | RockDistribution |
| Parameters defining the size, power-law scaling, and embedding traits of rocks. More... | |
| class | RockField |
| Container class representing a field of rocks/boulders (scree, talus, or boulder field). More... | |
| struct | RockSeedingOptions |
| Configuration parameters for rock field seeding algorithms. More... | |
| struct | RockSimulationOptions |
| Configuration parameters for GPU-based rock and debris trajectory simulation. More... | |
Typedefs | |
| using | UvTile = UvTile |
| using | Tree = ScatterItem |
| Represents a single tree instance. | |
| using | Rock = ScatterItem |
| Represents a single rock or boulder instance. | |
Functions | |
| Array | cv_mat_to_array (const cv::Mat &mat, bool remap_values=true, bool flip_j=false) |
| Converts an OpenCV cv::Mat to a 2D Array with optional value scaling to [0, 1]. | |
| std::string | get_opencv_build_information () |
| Returns OpenCV build information string. | |
| cv::Mat | to_cv_mat (Array &array) |
| Converts a 2D Array to a non-owning OpenCV cv::Mat (CV_32FC1). | |
| void | to_csv (const std::vector< glm::vec3 > &xyz, const std::string &fname) |
| glm::vec4 | adjust (const glm::vec4 &v, float dx, float dy, float dz, float dw) |
| glm::vec4 | adjust (const glm::vec4 &v, float dr) |
| size_t | count_non_zero (const Array &array) |
| Count the number of non-zero elements in the array. | |
| size_t | count_zero (const Array &array) |
| Count the number of zero elements in the array. | |
| template<typename Fn> | |
| void | for_each_cell (Array &a, Fn &&fn) |
| Apply a function to every cell (mutable). | |
| template<typename Fn> | |
| void | for_each_cell (const Array &a, Fn &&fn) |
| Apply a function to every cell (read-only). | |
| void | alter_elevation (Array &array, const Cloud &cloud, int ir, float footprint_ratio=1.f, glm::vec2 shift={0.f, 0.f}, glm::vec2 scale={1.f, 1.f}) |
| Point-wise alteration: locally enforce a new elevation value while maintaining the 'shape' of the heightmap. | |
| void | apply_gaussian_pushes (Array &array, const std::vector< GaussianPush > &pushes) |
| Apply a sequence of truncated-Gaussian pushes to a heightmap. | |
| Array | base_elevation (glm::ivec2 shape, const std::vector< std::vector< float > > &values, float width_factor=1.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_stretching=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Generate a heightmap from a coarse grid of control points with defined elevation values. | |
| Array | elevation_from_contours (glm::ivec2 shape, const std::vector< Path > &contours, const std::vector< float > &elevations, const Array *p_probability=nullptr, float randomness=1.f, std::uint32_t seed=0, float peak_ratio=0.5f, float outside_ratio=1.f, bool smoothstep=false, const UvRect &uv_rect=UvRect::unit()) |
| Synthesize a heightmap from sparse closed iso-contours with known elevations using stochastic front propagation (proof of concept). | |
| Array | elevation_from_contours (const Array &contours, const Array *p_probability=nullptr, float randomness=1.f, std::uint32_t seed=0, float peak_ratio=0.5f, float outside_ratio=1.f, bool smoothstep=false) |
| Synthesize a heightmap from a raster of sparse iso-contours with known elevations using stochastic front propagation. | |
| Array | elevation_from_sparse_constraints (const Array &mountains, const Array *p_coastline=nullptr, const Array *p_boundary=nullptr, float mountain_elevation=1.0f, float coastline_elevation=0.0f, float boundary_elevation=-1.0f, int iterations_max=500, float tolerance=1e-5f, const Array *p_noise=nullptr, float noise_amplitude=0.0f) |
| Synthesize a smooth heightmap from sparse elevation constraints using GPU harmonic interpolation (Laplacian PDE). | |
| Array | reverse_midpoint (const Array &array, std::uint32_t seed, float noise_scale=1.f, float threshold=0.f) |
| Apply the reverse midpoint displacement algorithm to the input array. | |
| Array | ridgelines (glm::ivec2 shape, const std::vector< float > &xr, const std::vector< float > &yr, const std::vector< float > &zr, float slope, float k_smoothing=1.f, float width=0.1f, float vmin=0.f, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_stretching=nullptr, const UvRect &uv_rect_array=UvRect::unit()) |
| Generate a heightmap based on a set of ridgelines and a specified slope. | |
| Array | ridgelines_bezier (glm::ivec2 shape, const std::vector< float > &xr, const std::vector< float > &yr, const std::vector< float > &zr, float slope, float k_smoothing=1.f, float width=0.1f, float vmin=0.f, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_stretching=nullptr, const UvRect &uv_rect_array=UvRect::unit()) |
| Generate a heightmap based on a set of ridgelines with quadratic Bezier interpolation. | |
| Array | sls_deformation (const Array &z, const std::vector< DeformationConstraint > &constraints, std::uint32_t seed, int iterations=200, int ir_min=4, int ir_max=64, int n_radii=7, float talus_max=0.f, int n_candidates=512, float p_best=0.65f, float top_fraction=0.1f, float tolerance=1e-3f, std::vector< GaussianPush > *p_pushes=nullptr) |
| Deform a heightmap to satisfy a set of constraints using stochastic local search over truncated-Gaussian push operations. | |
| Array | stamping (glm::ivec2 shape, const std::vector< float > &xr, const std::vector< float > &yr, const std::vector< float > &zr, Array kernel, int kernel_ir, bool kernel_scale_radius, bool kernel_scale_amplitude, StampingBlendMethod blend_method, std::uint32_t seed, float k_smoothing=0.1f, bool kernel_flip=true, bool kernel_rotate=false, const UvRect &uv_rect_array=UvRect::unit()) |
| Generate a heightmap by stamping a kernel at predefined locations. | |
| Array | blend_exclusion (const Array &array1, const Array &array2) |
| Return the 'exclusion' blending of two arrays. | |
| Array | blend_gradients (const Array &array1, const Array &array2, int ir=4) |
| Return the blending of two arrays based on their gradients. | |
| Array | blend_negate (const Array &array1, const Array &array2) |
| Return the 'negate' blending of two arrays. | |
| Array | blend_overlay (const Array &array1, const Array &array2) |
| Return the 'overlay' blending of two arrays. | |
| Array | blend_soft (const Array &array1, const Array &array2) |
| Return the 'soft' blending of two arrays. | |
| Array | blend_power_law (const std::vector< const Array * > &arrays, float alpha=0.f) |
| Return the power law blending of a set of arrays. | |
| Array | blend_power_law (const Array &array1, const Array &array2, float alpha=0.f) |
| Return the power law blending of two arrays. | |
| Array | mixer (const Array &t, const std::vector< const Array * > &arrays, float gain_factor=1.f) |
| Return the mixing of a set of arrays based on a parameter t. | |
| Array | transfer (const Array &source, const Array &target, int ir, float amplitude, bool target_prefiltering=false) |
| Transfers spatial details from a source array onto a target array. | |
| void | blend_terrains (Array &lower, const CoordFrame &frame_lower, const Array &upper, const CoordFrame &frame_upper, TerrainBlendMode mode, float param=0.2f) |
| Blend an upper terrain onto a lower terrain in-place, taking their CoordFrame transforms into account. | |
| void | blend_terrains (VirtualArray &lower, const CoordFrame &frame_lower, const VirtualArray &upper, const CoordFrame &frame_upper, TerrainBlendMode mode, float param=0.2f, const ComputeMode &cm=ComputeMode{}) |
| Blend an upper VirtualArray terrain onto a lower VirtualArray terrain in-place, taking their CoordFrame transforms into account. | |
| void | blend_terrains_height (Array &lower, const CoordFrame &frame_lower, const Array &upper, const CoordFrame &frame_upper, float feather_width=0.2f, float height_offset=0.f, float height_range=0.2f) |
| Height-aware terrain blending for Array inputs. | |
| void | blend_terrains_height (VirtualArray &lower, const CoordFrame &frame_lower, const VirtualArray &upper, const CoordFrame &frame_upper, float feather_width=0.2f, float height_offset=0.f, float height_range=0.2f, const ComputeMode &cm=ComputeMode{}) |
| Height-aware terrain blending for VirtualArray inputs. | |
| void | blend_terrains_multiscale (Array &lower, const CoordFrame &frame_lower, const Array &upper, const CoordFrame &frame_upper, float feather_width=0.25f, int n_levels=3, int base_radius=16, float detail_gain=1.f) |
| Multiscale (frequency-band) terrain blending for Array inputs. | |
| void | blend_terrains_multiscale (VirtualArray &lower, const CoordFrame &frame_lower, const VirtualArray &upper, const CoordFrame &frame_upper, float feather_width=0.25f, int n_levels=3, int base_radius=16, float detail_gain=1.f, int coarse_size=128, const ComputeMode &cm=ComputeMode{}) |
| Multiscale (frequency-band) terrain blending for VirtualArray inputs using a coarse global proxy for low-frequency bands and tile-local detail blending with halo synchronization. | |
| void | blend_terrains_poisson (Array &lower, const CoordFrame &frame_lower, const Array &upper, const CoordFrame &frame_upper, int iterations=400, float feather_width=0.15f, bool mixed_gradients=true) |
| Poisson / gradient-domain terrain blending for Array inputs. | |
| void | blend_terrains_poisson (VirtualArray &lower, const CoordFrame &frame_lower, const VirtualArray &upper, const CoordFrame &frame_upper, int iterations=400, float feather_width=0.15f, bool mixed_gradients=true, int coarse_size=128, int sync_interval=25, const ComputeMode &cm=ComputeMode{}) |
| Poisson / gradient-domain terrain blending for VirtualArray inputs using a two-level coarse-proxy + tile-local Red-Black SOR solver with halo synchronization. | |
| void | blend_terrains_seamless (Array &lower, const CoordFrame &frame_lower, const Array &upper, const CoordFrame &frame_upper, float feather_width=0.2f, int boundary_samples=64) |
| Seamless boundary blending (harmonic MVC membrane) for Array inputs. | |
| void | blend_terrains_seamless (VirtualArray &lower, const CoordFrame &frame_lower, const VirtualArray &upper, const CoordFrame &frame_upper, float feather_width=0.2f, int boundary_samples=64, const ComputeMode &cm=ComputeMode{}) |
| Seamless boundary blending (harmonic MVC membrane) for VirtualArray inputs. | |
| void | blend_terrains_slope (Array &lower, const CoordFrame &frame_lower, const Array &upper, const CoordFrame &frame_upper, float feather_width=0.2f, float slope_scale=0.1f, int ir_slope=2) |
| Slope-aware terrain blending for Array inputs. | |
| void | blend_terrains_slope (VirtualArray &lower, const CoordFrame &frame_lower, const VirtualArray &upper, const CoordFrame &frame_upper, float feather_width=0.2f, float slope_scale=0.1f, int ir_slope=2, const ComputeMode &cm=ComputeMode{}) |
| Slope-aware terrain blending for VirtualArray inputs. | |
| void | extrapolate_borders (Array &array, int nbuffer=1, float sigma=0.f, float vmin=-FLT_MAX) |
| Performs linear extrapolation of values at the borders of an array (e.g., i = 0, j = 0, etc.) based on the inner values of the array. | |
| void | falloff (Array &array, float strength=1.f, DistanceFunction dist_fct=DistanceFunction::EUCLIDIAN, const Array *p_noise=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Applies a falloff effect to the input array based on distance. | |
| void | fill_borders (Array &array) |
| Fills the border values of an array (e.g., i = 0, j = 0, etc.) based on the values of the first neighboring cells. | |
| void | fill_borders (Array &array, int nbuffer) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array | generate_buffered_array (const Array &array, glm::ivec4 buffers, bool zero_padding=false) |
| Creates and returns a new array with additional buffer zones at the boundaries, where the buffer values are filled either by symmetry or by zero-padding. | |
| void | make_periodic (Array &array, int nbuffer, const PeriodicityType &periodicity_type=PeriodicityType::PERIODICITY_XY) |
| Adjusts the input array to be periodic in both directions by transitioning smoothly at the boundaries. | |
| Array | make_periodic_stitching (const Array &array, float overlap) |
| Creates a periodic array in both directions using a stitching operation that minimizes errors at the boundaries. | |
| Array | make_periodic_tiling (const Array &array, float overlap, glm::ivec2 tiling) |
| Creates a tiled, periodic array by applying a transition with overlap in both directions. | |
| glm::ivec2 | pick_boundary_cell (const Array &z, DomainBoundary boundary, std::uint32_t seed, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true) |
| Picks a boundary cell using weighted random selection. | |
| void | set_borders (Array &array, glm::vec4 border_values, glm::ivec4 buffer_sizes) |
| Enforces specific values at the boundaries of the array. | |
| void | set_borders (Array &array, glm::vec4 border_values, glm::vec4 buffer_sizes, const UvRect &uv_rect=UvRect::unit()) |
| Enforces specific values at the domain boundaries based on distance. | |
| void | set_borders (Array &array, float border_values, int buffer_sizes) |
| Enforces a uniform value at all boundaries of the array. | |
| void | set_borders (Array &array, float border_values, float buffer_sizes, const UvRect &uv_rect=UvRect::unit()) |
| Enforces a uniform value at all domain boundaries based on distance. | |
| void | sym_borders (Array &array, glm::ivec4 buffer_sizes) |
| Fills the values at the domain borders using symmetry over a specified buffer depth. | |
| void | zeroed_borders (Array &array) |
| Fills the border values (e.g., i = 0, j = 0, etc.) of the array with zeros. | |
| void | zeroed_edges (Array &array, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP, float profile_param=0.f, float amount=1.f, DistanceFunction distance=DistanceFunction::EUCLIDIAN, DistanceFunctionAxis dfa=DistanceFunctionAxis::DFA_XY, glm::vec2 center={0.5f, 0.5f}, float radius=0.5f, const Array *p_noise_r=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Smoothly attenuates array values toward zero near the domain boundaries. | |
| void | carve_river (Array &z, const Graph &graph, float talus, float outlet_width, float headwater_width=0.f, float width_exponent=0.5f, float depth=0.05f, float depth_exponent=0.3f, std::uint32_t seed=0, float talus_noise_ratio=0.f, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP_UPPER, float radial_profile_parameter=2.f, Array *p_river_mask=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Carves a continuous river network into a heightmap along a directed flow Graph. | |
| void | dig_path (Array &z, Path &path, int width=1, int decay=2, int flattening_radius=16, bool force_downhill=false, const UvRect &uv_rect=UvRect::unit(), float depth=0.f) |
| Dig a path on a heightmap. | |
| void | flatten_around_points (Array &z, const std::vector< float > &xp, const std::vector< float > &yp, const std::vector< float > &zp, const std::vector< float > &radius, float strength=1.0f, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP, float profile_param=1.0f, Array *p_mask=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Flattens a heightmap locally around a set of reference points. | |
| void | flatten_around_points (Array &z, const std::vector< float > &xp, const std::vector< float > &yp, const std::vector< float > &zp, float radius=0.2f, float strength=1.0f, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP, float profile_param=1.0f, Array *p_mask=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Overload of flatten_around_points with a single radius shared by all points. | |
| void | flatten_around_points_terrain_aware (Array &z, const std::vector< float > &xp, const std::vector< float > &yp, const std::vector< float > &zp, const std::vector< float > &radius, float slope_weight=1.f, float uphill_weight=2.f, float max_height_above=-1.f, float terrain_follow=0.5f, float strength=1.f, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP, float profile_param=1.f, Array *p_mask=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Terrain-aware flattening around a set of seed points. | |
| void | flatten_around_points_terrain_aware (Array &z, const std::vector< float > &xp, const std::vector< float > &yp, const std::vector< float > &zp, float radius, float slope_weight=1.f, float uphill_weight=2.f, float max_height_above=-1.f, float terrain_follow=0.5f, float strength=1.f, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP, float profile_param=1.f, Array *p_mask=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Overload with a single radius shared by all seeds. | |
| void | flatbed_carve (Array &z, const Path &path, float bottom_extent=32.f, float vmin=0.1f, float depth=0.05f, float falloff_distance=128.f, float outer_slope=0.1f, bool preserve_bedshape=true, RadialProfile radial_profile=RadialProfile::RP_GAIN, float radial_profile_parameter=2.f, Array *p_falloff_mask=nullptr, const Array *p_noise_r=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Blends a flatbed carve into an existing heightmap. | |
| void | trench (Array &z, const Path &path, float width, bool enable_width_depth_scaling=true, bool enable_width_distance_scaling=true, bool enable_width_curvature_scaling=false, float curvature_radius_min=1.f, float curv_width_ratio_min=0.5f, float curv_width_ratio_max=2.f, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP_UPPER, float radial_profile_parameter=2.f, ElevationLongitudinalProfile longitudinal_profile=ElevationLongitudinalProfile::ELP_DECREASING, float elevation_shift=-0.05f, float shift_ramp_start_ratio=0.f, float shift_ramp_end_ratio=0.f, float min_slope=0.001f, size_t k_neighbors=8, const Array *p_noise_r=nullptr, Array *p_bending_mask=nullptr, int tile_size=32, const UvRect &uv_rect=UvRect::unit()) |
| Carves a trench along a given path into a heightmap. | |
| void | trench (Array &z, const std::vector< Path > &paths, float width, bool enable_width_depth_scaling=true, bool enable_width_distance_scaling=true, bool enable_width_curvature_scaling=false, float curvature_radius_min=1.f, float curv_width_ratio_min=0.5f, float curv_width_ratio_max=2.f, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP_UPPER, float radial_profile_parameter=2.f, ElevationLongitudinalProfile longitudinal_profile=ElevationLongitudinalProfile::ELP_DECREASING, float elevation_shift=-0.05f, float shift_ramp_start_ratio=0.f, float shift_ramp_end_ratio=0.f, float min_slope=0.001f, size_t k_neighbors=8, const Array *p_noise_r=nullptr, Array *p_bending_mask=nullptr, int tile_size=32, const UvRect &uv_rect=UvRect::unit()) |
| void | trench (Array &z, const Graph &graph, const std::vector< float > &relative_widths, float width, bool enable_width_depth_scaling=true, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP_UPPER, float radial_profile_parameter=2.f, ElevationLongitudinalProfile longitudinal_profile=ElevationLongitudinalProfile::ELP_DECREASING, float elevation_shift=-0.05f, float min_slope=0.001f, const Array *p_noise_r=nullptr, Array *p_bending_mask=nullptr, int tile_size=32, const UvRect &uv_rect=UvRect::unit()) |
| Carves river channels for an entire flow network represented by a Graph with per-node relative widths. | |
| void | trench (Array &z, const Graph &graph, float width, float width_exponent=1.0f, bool enable_width_depth_scaling=true, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP_UPPER, float radial_profile_parameter=2.f, ElevationLongitudinalProfile longitudinal_profile=ElevationLongitudinalProfile::ELP_DECREASING, float elevation_shift=-0.05f, float min_slope=0.001f, const Array *p_noise_r=nullptr, Array *p_bending_mask=nullptr, int tile_size=32, const UvRect &uv_rect=UvRect::unit()) |
| Carves river channels for an entire flow network represented by a Graph, computing relative widths from distance to outlet. | |
| void | apply_hillshade (Texture &img, const Array &array, float vmin=0.f, float vmax=1.f, float exponent=1.f) |
| Apply hillshading to a Tensor image. | |
| void | apply_hillshade (std::vector< uint8_t > &img, const Array &array, float vmin=0.f, float vmax=1.f, float exponent=1.f, bool is_img_rgba=false) |
| Apply hillshading to an 8-bit image. | |
| void | color_adjust (Array &r, Array &g, Array &b, ColorAdjust param, glm::ivec2 dither_seed) |
| Apply color correction and tonemapping to RGB arrays. | |
| Array | color_match_mask (const Array &r, const Array &g, const Array &b, const glm::vec3 &color, float tolerance=0.f) |
| Create a mask of pixels matching a target color within a tolerance. | |
| Texture | colorize (const Array &array, float vmin, float vmax, int cmap, bool hillshading, bool reverse=false, const Array *p_noise=nullptr) |
| Apply colorization to an array. | |
| Texture | colorize (const Array &array, float vmin, float vmax, const std::vector< float > &positions, const std::vector< glm::vec3 > &colormap_colors, bool reverse=false, const Array *p_noise=nullptr) |
| Colorize a scalar field into a Texture using a custom colormap. | |
| Texture | colorize_bivariate (const Array &a1, const Array &a2, const glm::vec2 range1, const glm::vec2 range2, const std::vector< float > &positions1, const std::vector< float > &positions2, const std::vector< glm::vec3 > &colormap_colors1, const std::vector< glm::vec3 > &colormap_colors2, MixMethod method=MM_SQRT_AVG, bool reverse1=false, bool reverse2=false, const Array *p_noise1=nullptr, const Array *p_noise2=nullptr) |
| Colorize two scalar fields into a Texture using two custom colormaps and a color mixing method. | |
| Texture | colorize_grayscale (const Array &array) |
| Convert an array to a grayscale image. | |
| Texture | colorize_histogram (const Array &array) |
| Convert an array to a histogram-based grayscale image. | |
| Texture | colorize_slope_height_heatmap (const Array &array, int cmap) |
| Colorizes a slope height heatmap based on the gradient norms of a given array. | |
| Texture | colorize_vec2 (const Array &array1, const Array &array2) |
| Combine two arrays into a colored image. | |
| Array | luminance (const Texture &tex) |
| Compute luminance from a Texture. | |
| Texture | mix (const Texture &tex1, const Texture &tex2, MixMethod method=MM_SQRT_AVG) |
| Mix two textures into an output texture. | |
| Texture | mix (const Texture &tex1, const Texture &tex2, const Array &mask, MixMethod method=MM_SQRT_AVG, float gain=1.f) |
| Mix two textures based on a transparency mask. | |
| Texture | mix (const std::vector< const Texture * > &texs, MixMethod method=MM_SQRT_AVG) |
| Mix a list of textures sequentially. | |
| Texture | mix_normal_map (const Texture &nmap_base, const Texture &nmap_detail, float detail_scaling, NormalMapBlendingMethod blending_method) |
| Blend two normal maps into a single output normal map. | |
| glm::vec3 | shade_color (const glm::vec3 &color, float t) |
| Adjust color by shading parameter t clamped to [0, 1]. | |
| void | shade_color (Texture &tex, const Array &factor) |
| Apply shade_color to each pixel of a Texture using values from an Array. | |
| void | shade_topographic_residual (Texture &tex, const Array &z, int ir, float strength=1.0f) |
| Apply shade_color to a Texture based on topographic residuals of an elevation array. | |
| Texture | terrain_texture (const Array &z, const Array *p_deposition=nullptr, const Array *p_snow_depth=nullptr, const TerrainTextureParams ¶ms=TerrainTextureParams(), const BBox2D &bbox=BBox2D::unit(), const Array *p_noise=nullptr, ICommunicator &comm=SingleArrayComm::instance()) |
| Generate a procedural terrain texture from elevation and surface analysis. | |
| std::vector< glm::vec3 > | get_colormap_data (int cmap) |
| std::string | to_string (ReduceOp op) |
| Array | level_set_curvature (const Array &array, int prefilter_ir) |
| Computes a signed level-set curvature. | |
| Array | curvature_quadric (const Array &z, int ir, CurvatureType curvature_type) |
| Compute curvature measures on a scalar field. | |
| void | aeolian_erosion (Array &z, int steps=300, std::uint32_t seed=1337u, glm::vec2 wind={3.f, 0.f}, const Array *p_bedrock=nullptr, const Array *p_vegetation=nullptr, const Array *p_abrasion_mask=nullptr, Array *p_sediment_map=nullptr, Array *p_bedrock_map=nullptr, float cell_size=-1.f, float matter_to_move=0.001f, int samples_per_step=0, float sand_repose_angle=33.f, float shadow_angle_min=5.f, float shadow_angle_max=15.f, float max_shadow_dist=12.f, float abrasion_rate=0.f, float repose_rate=0.35f, int sync_interval=0, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance(), int shadow_map_interval=1, int repose_interval=2) |
| Simulates wind-driven aeolian terrain erosion, sand transport, and dune dynamics on GPU. | |
| void | aeolian_erosion_multiscale (Array &z, int steps=300, std::uint32_t seed=1337u, glm::vec2 wind={3.f, 0.f}, const Array *p_bedrock=nullptr, const Array *p_vegetation=nullptr, const Array *p_abrasion_mask=nullptr, Array *p_sediment_map=nullptr, Array *p_bedrock_map=nullptr, float cell_size=-1.f, float matter_to_move=0.001f, float sand_repose_angle=33.f, float shadow_angle_min=5.f, float shadow_angle_max=15.f, float max_shadow_dist=12.f, float abrasion_rate=0.f, float repose_rate=0.35f, int levels=3, float coarse_fraction=0.7f, int min_level_size=64, int shadow_map_interval=1, int repose_interval=2) |
| Multiscale (coarse-to-fine) variant of hmap::aeolian_erosion. | |
| void | coastal_erosion_diffusion (Array &z, Array &water_depth, float additional_depth, int iterations=10, const Array *p_mask=nullptr, Array *p_water_mask=nullptr) |
| Simulates terrain diffusion due to coastal erosion. | |
| void | coastal_erosion_profile (Array &z, Array &water_depth, float shore_ground_extent, float shore_water_extent, float slope_shore=0.5f, float slope_shore_water=0.5f, float scarp_extent_ratio=0.5f, bool apply_post_filter=true, int post_filter_iterations=3, bool solid_shore_mask=true, float scarp_mask_transition_ratio=0.2f, const Array *p_noise=nullptr, Array *p_shore_mask=nullptr, Array *p_scarp_mask=nullptr) |
| Applies a coastal erosion profile to a terrain elevation field. | |
| void | coastal_erosion_profile (Array &z, const Array *p_mask, Array &water_depth, float shore_ground_extent, float shore_water_extent, float slope_shore=0.5f, float slope_shore_water=0.5f, float scarp_extent_ratio=0.5f, bool apply_post_filter=true, int post_filter_iterations=3, bool solid_shore_mask=true, float scarp_mask_transition_ratio=0.2f, const Array *p_noise=nullptr, Array *p_shore_mask=nullptr, Array *p_scarp_mask=nullptr) |
| void | hydraulic_algebric (Array &z, Array *p_mask, float talus_ref, int ir, Array *p_bedrock=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float c_erosion=0.05f, float c_deposition=0.05f, int iterations=1) |
| Apply an algerbic formula based on the local gradient to perform erosion/deposition. | |
| void | hydraulic_algebric (Array &z, float talus_ref, int ir, Array *p_bedrock=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float c_erosion=0.05f, float c_deposition=0.05f, int iterations=1) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | hydraulic_benes (Array &z, Array *p_mask, int iterations=50, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float c_capacity=40.f, float c_erosion=0.2f, float c_deposition=0.8f, float water_level=0.005f, float evap_rate=0.01f, float rain_rate=0.5f) |
| Apply cell-based hydraulic erosion/deposition based on Benes et al. procedure. | |
| void | hydraulic_benes (Array &z, int iterations=50, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float c_capacity=40.f, float c_erosion=0.2f, float c_deposition=0.8f, float water_level=0.005f, float evap_rate=0.01f, float rain_rate=0.5f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | hydraulic_blur (Array &z, float radius, float vmax, float k_smoothing=0.1f) |
| Apply cell-based hydraulic erosion using a nonlinear diffusion model. | |
| void | hydraulic_diffusion (Array &z, float c_diffusion, float talus, int iterations) |
| Apply cell-based hydraulic erosion using a nonlinear diffusion model. | |
| void | hydraulic_musgrave (Array &z, Array &moisture_map, int iterations=100, float c_capacity=1.f, float c_erosion=0.1f, float c_deposition=0.1f, float water_level=0.01f, float evap_rate=0.01f) |
| Apply cell-based hydraulic erosion/deposition of Musgrave et al. (1989). | |
| void | hydraulic_musgrave (Array &z, int iterations=100, float c_capacity=1.f, float c_erosion=0.1f, float c_deposition=0.1f, float water_level=0.01f, float evap_rate=0.01f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | hydraulic_stream (Array &z, float c_erosion, float talus_ref, const Array *p_bedrock=nullptr, const Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, int ir=1, float clipping_ratio=10.f) |
| Apply hydraulic erosion based on a flow accumulation map. | |
| void | hydraulic_stream (Array &z, const Array *p_mask, float c_erosion, float talus_ref, const Array *p_bedrock=nullptr, const Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, int ir=1, float clipping_ratio=10.f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | hydraulic_stream_log (Array &z, float c_erosion, float talus_ref, int deposition_ir=32, float deposition_scale_ratio=1.f, float gradient_power=0.8f, float gradient_scaling_ratio=1.f, int gradient_prefilter_ir=16, float saturation_ratio=1.f, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, Array *p_flow_map=nullptr) |
| Apply hydraulic erosion based on a flow accumulation map, alternative formulation. | |
| void | hydraulic_stream_log (Array &z, float c_erosion, float talus_ref, const Array *p_mask, int deposition_ir=32, float deposition_scale_ratio=1.f, float gradient_power=0.8f, float gradient_scaling_ratio=1.f, int gradient_prefilter_ir=16, float saturation_ratio=1.f, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, Array *p_flow_map=nullptr) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | hydraulic_stream_log_multiscale (Array &z, float c_erosion, float talus_ref, int levels=3, int deposition_ir=32, float deposition_scale_ratio=1.f, float gradient_power=0.8f, float gradient_scaling_ratio=1.f, int gradient_prefilter_ir=16, float saturation_ratio=1.f, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, Array *p_flow_map=nullptr, float mix=1.f, float warp=0.35f, std::uint32_t seed=1) |
| Multiscale stream-power hydraulic erosion cascade. | |
| void | hydraulic_stream_log_multiscale (Array &z, float c_erosion, float talus_ref, const Array *p_mask, int levels=3, int deposition_ir=32, float deposition_scale_ratio=1.f, float gradient_power=0.8f, float gradient_scaling_ratio=1.f, int gradient_prefilter_ir=16, float saturation_ratio=1.f, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, Array *p_flow_map=nullptr, float mix=1.f, float warp=0.35f, std::uint32_t seed=1) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | hydraulic_saleve (TerrainTriMesh &mesh, const std::vector< float > &erodibility, const std::vector< float > &max_slope, float m_exp=0.8f, float uplift_rate=1.f, float tolerance=1e-3f, int max_iterations=200, float noise_strength=0.f, std::uint32_t seed=0, bool enable_post_slope_limiter=false, float post_slope_limit=0.f, bool enable_post_smoothing=false) |
| Perform hydraulic erosion on a triangulated terrain mesh. | |
| Array | hydraulic_saleve (const Array &z, std::uint32_t seed, size_t control_points_count=10000, float m_exp=0.8f, float uplift_rate=1.f, float tolerance=1e-3f, int max_iterations=200, float smin=0.f, float smax=6.f, float strength=0.5f, bool scale_erodibility_with_z=true, float erodibility_distrib_exp=1.f, float noise_strength=0.f, bool enable_post_slope_limiter=false, float post_slope_limit=0.f, bool enable_post_smoothing=false, InterpolationMethod2D interpolation_method=InterpolationMethod2D::ITP2D_DELAUNAY_GRADIENT, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Apply hydraulic erosion to a heightmap using an adaptive mesh. | |
| Array | hydraulic_saleve (const Array &z, const Array *p_mask, std::uint32_t seed, size_t control_points_count=10000, float m_exp=0.8f, float uplift_rate=1.f, float tolerance=1e-3f, int max_iterations=200, float smin=0.f, float smax=6.f, float strength=0.5f, bool scale_erodibility_with_z=true, float erodibility_distrib_exp=1.f, float noise_strength=0.f, bool enable_post_slope_limiter=false, float post_slope_limit=0.f, bool enable_post_smoothing=false, InterpolationMethod2D interpolation_method=InterpolationMethod2D::ITP2D_DELAUNAY_GRADIENT, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | depression_filling (Array &z, int iterations=1000, float epsilon=1e-4f, bool outflow_left=true, bool outflow_right=true, bool outflow_bottom=true, bool outflow_top=true, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Fill the depressions of the heightmap using the Planchon-Darboux algorithm. | |
| void | depression_filling_priority_flood (Array &z, bool apply_post_filter=false, bool outflow_left=true, bool outflow_right=true, bool outflow_bottom=true, bool outflow_top=true, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Fill depressions in a heightmap using the Priority-Flood algorithm. | |
| void | erosion_maps (Array &z_before, Array &z_after, Array &erosion_map, Array &deposition_map, float tolerance=0.f) |
| Computes erosion and deposition delta maps from terrain states before and after erosion. | |
| Array | generate_bedrock (const Array &z, float elevation_strength, float slope_strength, float slope_limit, float zmin=0.f, float zmax=-1.f) |
| Generates a modified bedrock heightmap from an input elevation array. | |
| void | hydraulic_mise (Array &z, const MiseParams ¶ms=MiseParams(), const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, const Array *p_outlet=nullptr, Array *p_sediment=nullptr, Array *p_flow=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr) |
| Simulates multiscale implicit stream-power hydraulic erosion (MISE). | |
| void | hydraulic_mise (Array &z, const Array *p_mask, const MiseParams ¶ms=MiseParams(), const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, const Array *p_outlet=nullptr, Array *p_sediment=nullptr, Array *p_flow=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr) |
| Simulates multiscale implicit stream-power hydraulic erosion (MISE) with an intensity mask. | |
| bool | export_asset (const std::string &fname, const Array &array, MeshType mesh_type=MeshType::TRI, AssetExportFormat export_format=AssetExportFormat::GLB2, float elevation_scaling=0.2f, const std::string &texture_fname="", const std::string &normal_map_fname="", float max_error=5e-4f, bool fit_boundaries=false) |
| Exports a heightmap to various 3D file formats. | |
| bool | export_asset (const std::string &fname, const Array &array, const Array &mask, AssetExportFormat export_format=AssetExportFormat::GLB2, float elevation_scaling=0.2f, const std::string &texture_fname="", const std::string &normal_map_fname="", bool fit_boundaries=false) |
| void | export_points_to_ply (const std::string &fname, const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &z, const std::map< std::string, std::vector< float > > &custom_fields={}) |
| Exports 3D points with optional custom fields to an ASCII PLY file. | |
| void | write_raw_16bit (const std::string &fname, const Array &array) |
| Exports an array to a 16-bit 'raw' file format, commonly used for Unity terrain imports. | |
| std::string | export_as_ascii (const Array &array, const glm::ivec2 &export_shape={64, 64}, const std::string chars_map=" .:-=+*#%@") |
| Export a 2D array as an ASCII-art string representation. | |
| void | export_as_cubemap (const std::string &fname, const Array &z, int cubemap_resolution=128, float overlap=0.25f, int ir=16, Cmap cmap=static_cast< Cmap >(0), bool splitted=false, Array *p_cubemap=nullptr) |
| Exports a 2D array as a cubemap texture with continuity enforcement and overlapping regions. | |
| void | export_banner_png (const std::string &fname, const std::vector< Array > &arrays, int cmap, bool hillshading=false, bool normalize_arrays=false) |
| Exports a set of arrays as a banner PNG image file. | |
| bool | export_image (const Array &array, const std::string &fname, const ImageWriterConfig &config={}) |
| Exports an array using the generic ImageWriter pipeline. | |
| bool | export_image (const VirtualArray &va, const std::string &fname, const ImageWriterConfig &config={}) |
| Exports a VirtualArray incrementally using the generic ImageWriter pipeline. | |
| bool | export_image (const VirtualArray &va, const std::string &fname, const ImageWriterConfig &config, const ComputeMode &cm) |
| Exports a VirtualArray incrementally with custom compute mode. | |
| bool | export_image (const VirtualTexture &vt, const std::string &fname, const ImageWriterConfig &config={}) |
| Exports a VirtualTexture incrementally using the generic ImageWriter pipeline. | |
| bool | export_image (const VirtualTexture &vt, const std::string &fname, const ImageWriterConfig &config, const ComputeMode &cm) |
| Exports a VirtualTexture incrementally with custom compute mode. | |
| bool | export_virtual_array (const VirtualArray &va, ImageWriter &writer) |
| Streams a VirtualArray tile-by-tile into an already opened ImageWriter. | |
| bool | export_virtual_array (const VirtualArray &va, ImageWriter &writer, const ComputeMode &cm) |
| Streams a VirtualArray tile-by-tile into an already opened ImageWriter with custom compute mode. | |
| bool | export_virtual_array (const VirtualTexture &vt, ImageWriter &writer) |
| Streams a VirtualTexture tile-by-tile into an already opened ImageWriter. | |
| bool | export_virtual_array (const VirtualTexture &vt, ImageWriter &writer, const ComputeMode &cm) |
| Streams a VirtualTexture tile-by-tile into an already opened ImageWriter with custom compute mode. | |
| void | export_normal_map_png (const std::string &fname, const Array &array, int depth=CV_8U) |
| Exports the heightmap normal map as an 8-bit PNG file. | |
| void | export_splatmap_png (const std::string &fname, const Array *p_r, const Array *p_g=nullptr, const Array *p_b=nullptr, const Array *p_a=nullptr, int depth=CV_8U) |
| Exports four arrays as an RGBA PNG splatmap. | |
| void | export_tiled (const std::string &fname_radical, const std::string &fname_extension, const Array &array, const glm::ivec2 &tiling, int leading_zeros=0, int depth=CV_8U, bool overlapping_edges=false, bool reverse_tile_y_indexing=false) |
| Exports a 2D array as a set of grayscale PNG image tiles. | |
| Array | read_to_array (const std::string &fname, bool flip_j=false, bool remap=true) |
| Reads an image file and converts it to a 2D array. | |
| bool | export_usd (const std::string &fname, const Array &elevation={}, const std::vector< Forest > &forests={}, const std::vector< RockField > &rock_fields={}, const std::vector< Cloud > &clouds={}, const std::vector< Path > &paths={}, MeshType mesh_type=MeshType::TRI, float elevation_scaling=0.2f, const std::string &texture_fname="", const std::string &normal_map_fname="", float max_error=5e-4f, bool fit_boundaries=false) |
| Exports a composite scene (terrain, forests, rock fields, clouds, and paths) to Universal Scene Description (USD). | |
| Array | compute_poi_suitability_field (const Array &heightmap, PoiType type, const PoiGenerationOptions &options) |
| Computes a normalized suitability/score field in [0, 1] for a given terrain feature type. | |
| Cloud | generate_points_of_interest_cloud (const Array &heightmap, PoiType type, const PoiGenerationOptions &options) |
| Generates a Cloud of points of interest from a heightmap. | |
| std::vector< PointOfInterest > | generate_points_of_interest (const Array &heightmap, PoiType type, const PoiGenerationOptions &options) |
| Generates a list of PointOfInterest objects from a heightmap. | |
| std::vector< glm::vec2 > | generate_points_of_interest_positions (const Array &heightmap, PoiType type, const PoiGenerationOptions &options) |
| Generates 2D positions of points of interest from a heightmap. | |
| std::vector< PointOfInterest > | generate_points_from_score_field (const Array &score_field, const Array &heightmap, const PoiGenerationOptions &options, PoiType type=PoiType::CUSTOM) |
| Generates a list of PointOfInterest objects from a precomputed score field. | |
| Array | connected_components (const Array &array, float surface_threshold=0.f, float background_value=0.f, std::map< float, float > *p_surfaces=nullptr, std::map< float, std::array< float, 2 > > *p_centroids=nullptr) |
| Identifies and labels connected components within a binary or labeled array, with optional filtering by size. | |
| Array | geomorphons (const Array &array, int irmin, int irmax, float epsilon) |
| Classifies terrain into geomorphological features based on the geomorphons method. | |
| Array | kmeans_clustering2 (const Array &array1, const Array &array2, int nclusters, std::vector< Array > *p_scoring=nullptr, Array *p_aggregate_scoring=nullptr, glm::vec2 weights={1.f, 1.f}, std::uint32_t seed=1) |
| Performs k-means clustering on two input arrays, grouping similar data points into clusters. | |
| Array | kmeans_clustering3 (const Array &array1, const Array &array2, const Array &array3, int nclusters, std::vector< Array > *p_scoring=nullptr, Array *p_aggregate_scoring=nullptr, glm::vec3 weights={1.f, 1.f, 1.f}, std::uint32_t seed=1) |
| Performs k-means clustering on three input arrays. | |
| Array | bulkify (const Array &z, const PrimitiveType &primitive_type, float amp=1.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Applies a primitive-based displacement to an array. | |
| void | canyonize (Array &array, std::uint32_t seed=0, int nlevels=6, float convex_ratio=3.0f, float gamma_convex=3.0f, float gamma_concave=0.3f, float clamp_min_val=-std::numeric_limits< float >::infinity(), float k_smooth=0.1f, float noise_ratio=0.2f, const Array *p_noise=nullptr, float vmin=1.f, float vmax=0.f) |
| Applies a canyonize filter to a heightmap. | |
| void | canyonize (Array &array, std::uint32_t seed, int nlevels, const Array *p_mask, float convex_ratio=3.0f, float gamma_convex=3.0f, float gamma_concave=0.3f, float clamp_min_val=-std::numeric_limits< float >::infinity(), float k_smooth=0.1f, float noise_ratio=0.2f, const Array *p_noise=nullptr, float vmin=1.f, float vmax=0.f) |
| Applies a masked canyonize filter to a heightmap. | |
| Array | dequantize (const Array &array, std::uint32_t seed, float dither_amplitude=0.01f, int filtering_iterations=1) |
| Reduce quantization artifacts using dithering and smoothing. | |
| Array | distance_shaper (const Array &array, float falloff=0.05f, int directions=8, float skew=0.f, float angle=0.f, DistanceMode mode=DistanceMode::PYRAMID, DistanceMethod method=DistanceMethod::RT, float angular_jitter=0.f, float falloff_jitter=0.f, float threshold=0.f, bool invert_input=false, bool invert_output=false, float mix_ratio=1.f, std::uint32_t seed=0, const Array *p_mask=nullptr, const Array *p_dx=nullptr, const Array *p_dy=nullptr) |
| Generates sloped, stratified terrain profiles from shapes and masks using directional distance fields. | |
| void | equalize (Array &array) |
| Apply histogram equalization to the array values. | |
| void | equalize (Array &array, const Array *p_mask) |
| Apply histogram equalization to the array values with a mask. | |
| void | expand (Array &array, int ir, const Array *p_mask, int iterations=1) |
| Apply expansion, or "inflation", to emphasize the bulk of the terrain. | |
| void | expand (Array &array, int ir, int iterations=1) |
| Apply expansion to emphasize the bulk of the terrain using a filter radius. | |
| void | expand (Array &array, const Array &kernel, int iterations=1) |
| Apply expansion using a custom kernel. | |
| void | expand (Array &array, const Array &kernel, const Array *p_mask, int iterations=1) |
| Apply expansion using a custom kernel with an optional mask. | |
| void | expand_directional (Array &array, int ir, float angle, float aspect_ratio, float anisotropy=1.f, const Array *p_mask=nullptr) |
| Apply expansion, or "inflation", to emphasize the bulk of the terrain, using a directional kernel. | |
| void | expand_talus (Array &z, const Array &mask, float talus, std::uint32_t seed, int ir=1, float noise_ratio=0.2f) |
| Expand heights outward from a masked region with a talus slope limit. | |
| void | fill_talus (Array &z, float talus, std::uint32_t seed, int ir=1, float noise_ratio=0.2f, const Array *p_seed_mask=nullptr) |
| Enforce a talus slope constraint on a height field. | |
| void | fill_talus (Array &z, const Array &talus, std::uint32_t seed, int ir=1, float noise_ratio=0.2f, const Array *p_seed_mask=nullptr) |
| void | fold (Array &array, float vmin, float vmax, int iterations=3, float k=0.05f) |
| Apply a "folding" filter (successive absolute values) to the array elements. | |
| void | fold (Array &array, int iterations=3, float k=0.05f) |
| Apply a "folding" filter with default reference values and parameters. | |
| void | fold_periodic (Array &array, PhasorProfile phasor_profile, float vmin, float vmax, int iterations=3, float delta=0.f) |
| Apply a periodic "folding" filter to the array elements using a periodic phasor profile. | |
| void | fold_periodic (Array &array, PhasorProfile phasor_profile=PhasorProfile::PP_COSINE_STD, int iterations=3, float delta=0.f) |
| Apply a periodic "folding" filter with default reference values. | |
| void | gain (Array &array, float factor, const Array *p_mask) |
| Apply a gain correction to the array elements. | |
| void | gain (Array &array, float factor) |
| Apply a gain correction to the array elements without a mask. | |
| void | gamma_correction (Array &array, float gamma, const Array *p_mask) |
| Apply gamma correction to the input array. | |
| void | gamma_correction (Array &array, float gamma) |
| Apply gamma correction to the input array without a mask. | |
| void | gamma_correction_local (Array &array, float gamma, int ir, float k=0.1f) |
| Apply a "local" gamma correction to the input array. | |
| void | gamma_correction_local (Array &array, float gamma, int ir, const Array *p_mask, float k=0.1f) |
| Apply a "local" gamma correction with a mask to the input array. | |
| void | kuwahara (Array &array, int ir, float mix_ratio=1.f) |
| Applies the Kuwahara filter to an array with optional per-pixel masking. | |
| void | kuwahara (Array &array, int ir, const Array *p_mask, float mix_ratio=1.f) |
| Applies the Kuwahara filter to an array with optional per-pixel masking. | |
| void | laplace (Array &array, float sigma=0.125f, int iterations=3) |
| Applies an iterative 8-neighbor Laplacian smoothing filter on an array. | |
| void | laplace (Array &array, const Array *p_mask, float sigma=0.125f, int iterations=3) |
| Apply a low-pass Laplace filter with a mask. | |
| void | laplace1d (std::vector< float > &v, float sigma=0.5f, int iterations=1) |
| Apply a low-pass Laplace filter to a vector. | |
| void | laplace_edge_preserving (Array &array, float talus, float sigma=0.2f, int iterations=3) |
| Apply a low-pass anisotropic Laplace filter to the input array. | |
| void | laplace_edge_preserving (Array &array, float talus, const Array *p_mask, float sigma=0.2f, int iterations=3) |
| Apply a low-pass anisotropic Laplace filter with a mask. | |
| void | low_pass_high_order (Array &array, int order=9, float sigma=1.f) |
| Apply a low-pass high-order filter to the input array. | |
| void | make_binary (Array &array, float threshold=0.f) |
| Convert array values to binary using a threshold. | |
| void | match_histogram (Array &array, const Array &array_reference) |
| Transform the input array elevation to match the histogram of a reference array. | |
| Array | mean_shift (const Array &array, int ir, float talus, int iterations=1, bool talus_weighted=true) |
| Applies the mean shift algorithm to the input array. | |
| Array | mean_shift (const Array &array, int ir, float talus, const Array *p_mask, int iterations=1, bool talus_weighted=true) |
| void | median_3x3 (Array &array, const Array *p_mask) |
| Apply a 3x3 median filter to the input array. | |
| void | median_3x3 (Array &array) |
| Apply a 3x3 median filter to the input array without a mask. | |
| Array | median_pseudo (const Array &array, int ir) |
| Computes a fast pseudo-median approximation of a local neighborhood in an array. | |
| void | normal_displacement (Array &array, float amount=0.1f, int ir=0, bool reverse=false) |
| Apply a displacement to the terrain along the normal direction. | |
| void | normal_displacement (Array &array, const Array *p_mask, float amount=0.1f, int ir=0, bool reverse=false) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | plateau (Array &array, const Array *p_mask, int ir, float factor) |
| Apply a plateau-shape filter to the input array. | |
| void | plateau (Array &array, int ir, float factor) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array | quantize (const Array &array, int nlevels, float vmin, float vmax) |
| Quantize array values into discrete levels. | |
| Array | quantize (const Array &array, int nlevels) |
| Quantize array values using the array min/max range. | |
| void | recast_billow (Array &array, float vref, float k) |
| Transform heightmap to give a "billow" like appearance. | |
| void | recast_canyon (Array &array, const Array &vcut, float gamma=4.f) |
| Transform heightmap to give a "canyon" like appearance. | |
| void | recast_canyon (Array &array, const Array &vcut, const Array *p_mask, float gamma=4.f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recast_canyon (Array &array, float vcut, const Array *p_mask, float gamma=4.f, const Array *p_noise=nullptr) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recast_canyon (Array &array, float vcut, float gamma=4.f, const Array *p_noise=nullptr) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recast_cracks (Array &array, float cut_min=0.05f, float cut_max=0.5f, float k_smoothing=0.01f, float vmin=0.f, float vmax=-1.f) |
| void | recast_escarpment (Array &array, int ir=16, float ratio=0.1f, float scale=1.f, bool reverse=false, bool transpose_effect=false, float global_scaling=0.f) |
| Applies an escarpment effect to the given 2D array, modifying its values based on cumulative displacement with optional directional and transpositional transformations. | |
| void | recast_escarpment (Array &array, const Array *p_mask, int ir=16, float ratio=0.1f, float scale=1.f, bool reverse=false, bool transpose_effect=false, float global_scaling=0.f) |
| Applies an escarpment effect to the given 2D array, with an optional mask to blend the effect. | |
| void | recast_peak (Array &array, int ir, float gamma=2.f, float k=0.1f) |
| Transform heightmap to give a "peak" like appearance. | |
| void | recast_peak (Array &array, int ir, const Array *p_mask, float gamma=2.f, float k=0.1f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recast_rocky_slopes (Array &array, float talus, int ir, float amplitude, std::uint32_t seed, float kw, float gamma=0.5f, const Array *p_noise=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Transform heightmap by adding "rock-like" features at higher slopes. | |
| void | recast_rocky_slopes (Array &array, float talus, int ir, float amplitude, std::uint32_t seed, float kw, const Array *p_mask, float gamma=0.5f, const Array *p_noise=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recast_sag (Array &array, float vref, float k) |
| Transform heightmap to give a "cliff" like appearance. | |
| void | recast_sag (Array &array, float vref, float k, const Array *p_mask) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recurve (Array &array, const std::vector< float > &t, const std::vector< float > &v) |
| Apply a curve adjustment filter to the array. | |
| void | recurve (Array &array, const std::vector< float > &t, const std::vector< float > &v, const Array *p_mask) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recurve_bexp (Array &array, float tau=0.5f) |
| Apply a curve adjustment filter using a "bumpy exponential-shape" curve. | |
| void | recurve_bexp (Array &array, const Array *p_mask, float tau=0.5f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recurve_exp (Array &array, float tau=0.5f) |
| Apply a curve adjustment filter using a "sharp exponential-shape" curve. | |
| void | recurve_exp (Array &array, const Array *p_mask, float tau=0.5f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recurve_kura (Array &array, float a, float b) |
| Apply a curve adjustment filter using Kumaraswamy's cumulative distribution function (CDF). | |
| void | recurve_kura (Array &array, float a, float b, const Array *p_mask) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recurve_s (Array &array) |
| Apply a curve adjustment filter using a smooth "S-shape" curve. | |
| void | recurve_s (Array &array, const Array *p_mask) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | recurve_smoothstep_rational (Array &array, float n) |
| Apply a curve adjustment filter using an nth-order smoothstep curve. | |
| void | recurve_smoothstep_rational (Array &array, float n, const Array *p_mask) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | reverse_above_theshold (Array &array, const Array &threshold, float scaling=1.f, float transition_extent=0.f) |
| Applies a smooth reversal of values above a given threshold. | |
| void | reverse_above_theshold (Array &array, float threshold, float scaling=1.f, float transition_extent=0.f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | reverse_above_theshold (Array &array, const Array &threshold, const Array *p_mask, float scaling=1.f, float transition_extent=0.f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | reverse_above_theshold (Array &array, float threshold, const Array *p_mask, float scaling=1.f, float transition_extent=0.f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | ridge_accentuate (Array &array, float strength=0.1f, int ir=0, bool reverse=false) |
| Accentuate ridges by gradient-directed resampling along the normal direction. | |
| void | ridge_accentuate (Array &array, const Array *p_mask, float strength=0.1f, int ir=0, bool reverse=false) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | saturate (Array &array, float vmin, float vmax, float from_min, float from_max, float k=0.f) |
| Saturate the array values based on the input interval [vmin, vmax] (the output amplitude is not modified). | |
| void | saturate (Array &array, float vmin, float vmax, float k=0.f) |
| void | saturate_percentile (Array &array, float percentile_low, float percentile_high, float k=0.f) |
| Saturate values based on percentile range. | |
| void | sharpen (Array &array, float ratio=1.f) |
| Apply a sharpening filter based on the Laplace operator. | |
| void | sharpen (Array &array, const Array *p_mask, float ratio=1.f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | sharpen_cone (Array &array, int ir, float intensity=0.5f) |
| Apply a sharpening filter based on a smooth cone filter. | |
| void | sharpen_cone (Array &array, const Array *p_mask, int ir, float scale=0.5f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | shrink (Array &array, int ir, int iterations=1) |
| Apply shrinking, or "deflating", to emphasize the ridges in the heightmap. | |
| void | shrink (Array &array, int ir, const Array *p_mask, int iterations=1) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | shrink (Array &array, const Array &kernel, int iterations=1) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | shrink (Array &array, const Array &kernel, const Array *p_mask, int iterations=1) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | shrink_directional (Array &array, int ir, float angle, float aspect_ratio, float anisotropy=1.f, const Array *p_mask=nullptr) |
| Apply directional shrinking, or "deflating", to emphasize the ridges in the terrain. | |
| void | smooth_cone (Array &array, int ir) |
| Apply a convolution filter with a cone kernel to smooth the array. | |
| void | smooth_cone (Array &array, int ir, const Array *p_mask) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | smooth_cpulse (Array &array, int ir, const Array *p_mask=nullptr, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Apply filtering to the array using convolution with a cubic pulse kernel. | |
| void | smooth_cpulse_edge_removing (Array &array, float talus, float talus_width, int ir) |
| Smooths an array while attenuating edges using a gradient-based pulse. | |
| void | smooth_flat (Array &array, int ir) |
| Applies a smoothing average filter to the given 2D array in both dimensions. | |
| void | smooth_gaussian (Array &array, int ir) |
| Apply Gaussian filtering to the array. | |
| void | smooth_gaussian (Array &array, int ir, const Array *p_mask) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | smooth_fill (Array &array, int ir, float k=0.1f, Array *p_deposition_map=nullptr) |
| Apply cubic pulse smoothing to fill lower flat regions while preserving some sharpness. | |
| void | smooth_fill (Array &array, int ir, const Array *p_mask, float k=0.1f, Array *p_deposition_map=nullptr) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | smooth_fill_holes (Array &array, int ir) |
| Apply smoothing to fill holes (elliptic concave surfaces). | |
| void | smooth_fill_holes (Array &array, int ir, const Array *p_mask) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | smooth_fill_smear_peaks (Array &array, int ir) |
| Apply smoothing to smear peaks (elliptic convex surfaces). | |
| void | smooth_fill_smear_peaks (Array &array, int ir, const Array *p_mask) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | smoothstep_local (Array &array, int ir) |
| Applies a localized smoothstep operation to the provided array. | |
| void | smoothstep_local (Array &array, int ir, const Array *p_mask) |
| Applies a localized smoothstep operation to the provided array with an optional mask. | |
| void | steepen (Array &array, float scale, int ir=8) |
| Steepen (or flatten) the array map. | |
| void | steepen (Array &array, float scale, const Array *p_mask, int ir=8) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | steepen_convective (Array &array, float angle, int iterations=1, int ir=0, float dt=0.1f) |
| Steepen array values by applying a nonlinear convection operator in a given direction. | |
| void | steepen_convective (Array &array, float angle, const Array *p_mask, int iterations=1, int ir=0, float dt=0.1f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | terrace (Array &array, std::uint32_t seed, int nlevels, float gain=0.9f, float noise_ratio=0.f, const Array *p_noise=nullptr, float vmin=0.f, float vmax=-1.f) |
| Applies a terrace effect to the values in an array. | |
| void | terrace (Array &array, std::uint32_t seed, int nlevels, const Array *p_mask, float gain=0.9f, float noise_ratio=0.f, const Array *p_noise=nullptr, float vmin=0.f, float vmax=-1.f) |
| Applies a terrace effect to an array with optional masking. | |
| std::function< float(float, float)> | make_xy_function_from_array (const Array &array, const BBox2D &bbox=BBox2D::unit()) |
| Create a continuous 2D function from a sampled array. | |
| template<typename Fn> | |
| decltype(auto) | with_noise_function (NoiseType noise_type, glm::vec2 kw, std::uint32_t seed, Fn &&fn) |
| Dispatch a noise functor based on the specified noise type. | |
| void | add_line_bresenham (CellPath &out, glm::ivec2 a, glm::ivec2 b) |
| Rasterizes a segment between two integer points using Bresenham's algorithm. | |
| void | add_noise (CellPath &path, std::uint32_t seed, float kw, float amp, const glm::ivec2 &shape, NoiseType noise_type=NoiseType::PERLIN, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f) |
| Applies transverse noise displacement along an integer path. | |
| void | enforce_path_adjacency (CellPath &path) |
| Ensures that an integer path is grid-adjacent and gap-free. | |
| bool | is_path_adjacent (const CellPath &path) |
| Checks if a grid path has no gaps (8-connectivity). | |
| Array | cloud_sdf_to_array (const Cloud &cloud, glm::ivec2 shape, const BBox2D &bbox_array=BBox2D::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Compute a distance field from a point cloud. | |
| bool | has_duplicates (const Cloud &cloud, float eps=1e-9f, bool xy_only=true) |
| Checks whether the point cloud contains duplicate points. | |
| std::vector< float > | interpolate_values_from_array (const Cloud &cloud, const Array &array, const BBox2D &bbox) |
| Interpolate values from an array at the points' (x, y) locations. | |
| Cloud | merge_cloud (const Cloud &cloud1, const Cloud &cloud2) |
| Merges two point clouds into one. | |
| Cloud | merge_clouds (const std::vector< Cloud > &clouds) |
| Merges multiple point clouds into a single cloud. | |
| Cloud | random_cloud (size_t count, std::uint32_t seed, const PointSamplingMethod &method=PointSamplingMethod::RND_LHS, const BBox2D &bbox=BBox2D{}) |
| Generates a random cloud of points within a bounding box. | |
| Cloud | random_cloud_density (size_t count, const Array &density, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates a random cloud of points based on a spatial density map. | |
| Cloud | random_cloud_inverse_sampling (size_t count, const Array &density, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates a random cloud of points using inverse transform sampling on a 2D density array. | |
| Cloud | random_cloud_distance (float min_dist, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates a random cloud of points separated by at least a given minimum distance. | |
| Cloud | random_cloud_distance (float min_dist, float max_dist, const Array &density, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates a random cloud of points separated by a distance range, influenced by a density map. | |
| Cloud | random_cloud_distance_power_law (float dist_min, float dist_max, float alpha, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates a random cloud of points with distances drawn from a power-law distribution. | |
| Cloud | random_cloud_distance_weibull (float dist_min, float lambda, float k, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates a random cloud of points with distances drawn from a Weibull distribution. | |
| Cloud | random_cloud_jittered (size_t count, const glm::vec2 &jitter_amount, const glm::vec2 &stagger_ratio, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates a jittered grid cloud of points. | |
| void | rejection_filter_density (Cloud &cloud, const Array &density_mask, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Filter a point cloud using rejection sampling based on a density mask. | |
| 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. | |
| Cloud | scale (const Cloud &cloud, float scale, glm::vec2 center={0.5f, 0.5f}) |
| int | convert_length_to_pixel (float x, int nx, bool lim_inf=true, bool lim_sup=false, float scale=1.f) |
| Converts a length value to a pixel index in a discretized space. | |
| void | grid_xy_vector (std::vector< float > &x, std::vector< float > &y, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), bool endpoint=false) |
| Return x and y coordinates of a regular grid, as two 1D vectors. | |
| void | rescale_grid_from_unit_square_to_bbox (std::vector< float > &x, std::vector< float > &y, const UvRect &uv_rect) |
| Rescale 1D grid vectors from unit square [0, 1] to target UV rectangle. | |
| Path | bezier (const Path &path, float curvature_ratio=0.3f, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE) |
| Smooth the path using Bezier curves. | |
| Path | bezier_round (const Path &path, float curvature_ratio=0.3f, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE) |
| Smooth the path using Bezier curves (alternative method). | |
| Path | bspline (const Path &path, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE) |
| Smooth the path using B-Spline curves. | |
| Path | catmullrom (const Path &path, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE) |
| Smooth the path using Catmull-Rom curves. | |
| Path | decasteljau (const Path &path, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE) |
| Smooth the path using De Casteljau curves. | |
| Path | decimate_vw (const Path &path, int n_points_target=3) |
| Simplifies the current path using the Visvalingam-Whyatt algorithm. | |
| Path | fractalize (const Path &path, int iterations, std::uint32_t seed, float sigma=0.2f, int orientation=0, float persistence=1.f, Array *p_control_field=nullptr, const BBox2D &bbox=BBox2D{}, bool bounded=false) |
| Applies fractalization to the path by adding points and randomly displacing their positions. | |
| Path | inflate (const Path &path, float strength, bool resample=true) |
| Inflate (offset) a path along its normals using curvature. | |
| Path | meanderize (const Path &path, float ratio, float noise_ratio=0.1f, std::uint32_t seed=1, int iterations=1, int edge_divisions=10, Path::EdgeDivisionMode edm=Path::EdgeDivisionMode::EDM_PER_EDGE) |
| Add "meanders" to the path. | |
| Array | path_sdf_bezier_to_array (const Path &path, glm::ivec2 shape, const BBox2D &bbox_array=BBox2D::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, bool use_bvh=true) |
| Converts a 2D path treated as a piecewise quadratic Bezier curve to a signed distance field (SDF) array. | |
| Array | path_sdf_bezier_to_array_brute_force (const Path &path, glm::ivec2 shape, const BBox2D &bbox_array=BBox2D::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | path_sdf_bezier_to_array_bvh (const Path &path, glm::ivec2 shape, const BBox2D &bbox_array=BBox2D::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | path_sdf_to_array (const Path &path, glm::ivec2 shape, const BBox2D &bbox_array=BBox2D::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, bool use_bvh=true) |
| Compute a distance field from a point path. | |
| Array | path_sdf_to_array_brute_force (const Path &path, glm::ivec2 shape, const BBox2D &bbox_array=BBox2D::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | path_sdf_to_array_bvh (const Path &path, glm::ivec2 shape, const BBox2D &bbox_array=BBox2D::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Path | remove_geometric_loops (const Path &path) |
| Removes geometric loops in a 2D path caused by self-intersections. | |
| Path | scale (const Path &path, glm::vec2 scale, glm::vec2 center={0.5f, 0.5f}) |
| Scales the point coordinates in a path relative to a center point. | |
| Path | scale (const Path &path, float scale, glm::vec2 center={0.5f, 0.5f}) |
| Path | smooth (const Path &path, int navg=1, float averaging_intensity=1.f, float inertia=0.f) |
| Applies a smoothing operation to the path points using a moving average filter. | |
| Path | squiggle (const Path &path, int iterations=4, std::uint32_t seed=0, float height_ratio=0.5f, int orientation=0, const Array *p_weights=nullptr, const Array *p_mask=nullptr, const BBox2D &bbox=BBox2D{}) |
| Generates a continuous, non-self-intersecting squiggle curve by applying the squiggle recursive triangle subdivision algorithm to each edge of the input path. | |
| std::vector< Path > | squiggle_branches (const Path &path, int iterations=4, std::uint32_t seed=0, float branch_probability=0.3f, int max_branches=8, float height_ratio=0.5f, int orientation=0, const Array *p_weights=nullptr, const Array *p_mask=nullptr, const BBox2D &bbox=BBox2D{}) |
| Generates squiggle paths with secondary tributary branches along each edge. | |
| Path | truncate_at_first_intersection (const Path &path, const std::vector< Path > &existing_paths) |
| Truncates a path at its first intersection with any path in a given set of existing paths. The intersection point is included as the new end point. | |
| bool | assert_start_end_points (const Path &path1, const Path &path2, float tol=1e-6f, bool verbose=false) |
| Asserts that the start and end points of two paths are within a specified tolerance. | |
| float | chamfer_distance (const Path &a, const Path &b) |
| Calculate the chamfer distance between two paths. | |
| bool | has_duplicates (const Path &path, float tol=1e-6f) |
| Check if a path contains duplicate points within a given tolerance. | |
| float | angle (const Point &p1, const Point &p2) |
| Computes the angle between two points relative to the x-axis. | |
| float | angle (const Point &p0, const Point &p1, const Point &p2) |
| Computes the angle formed by three points with p0 as the origin. | |
| float | classify_point (const Point &p_prev, const Point &p, const Point &p_next, const Point &pq) |
| Classify point convexity relative to neighboring curve vertices. | |
| float | cross_product (const Point &p0, const Point &p1, const Point &p2) |
| Computes the 2D cross product of vectors (p1 - p0) and (p2 - p0). | |
| float | cross_product (const Point &p1, const Point &p2) |
| Computes the 2D cross product of vectors p1 and p2. | |
| float | curvature (const Point &p1, const Point &p2, const Point &p3) |
| Calculates the curvature formed by three points in 2D space. | |
| float | curvature_signed (const Point &p1, const Point &p2, const Point &p3) |
| Calculates the signed curvature formed by three points in 2D space. | |
| float | distance (const Point &p1, const Point &p2) |
| Calculates the Euclidean distance between two points. | |
| float | distance_squared (const Point &p1, const Point &p2) |
| Calculates the squared Euclidean distance between two points. | |
| Point | interp_bezier (const Point &p_start, const Point &p_ctrl_start, const Point &p_ctrl_end, const Point &p_end, float t) |
| Performs a cubic Bezier interpolation. | |
| Point | interp_bspline (const Point &p0, const Point &p1, const Point &p2, const Point &p3, float t) |
| Performs a cubic B-spline interpolation. | |
| Point | interp_catmullrom (const Point &p0, const Point &p1, const Point &p2, const Point &p3, float t) |
| Performs a Catmull-Rom spline interpolation. | |
| Point | interp_decasteljau (const std::vector< Point > &points, float t) |
| Performs a De Casteljau algorithm-based interpolation for Bezier curves. | |
| BBox2D | intersect_bounding_boxes (const BBox2D &bbox1, const BBox2D &bbox2) |
| Determines the intersection of two bounding boxes. | |
| bool | is_point_within_bounding_box (const Point &p, const BBox2D &bbox) |
| Checks if a point is within a specified bounding box. | |
| bool | is_point_within_bounding_box (float x, float y, const BBox2D &bbox) |
| Checks if a point with coordinates (x, y) is within a specified bounding box. | |
| Point | lerp (const Point &p1, const Point &p2, float t) |
| Linearly interpolates between two points. | |
| Point | midpoint (const Point &p1, const Point &p2, int orientation, float distance_ratio, float t=0.5f) |
| Computes the midpoint displacement with a perpendicular offset. | |
| Point | scale (const Point &p, glm::vec2 scale, glm::vec2 center={0.5f, 0.5f}) |
| Scales a point relative to a center point. | |
| Point | scale (const Point &p, float scale, glm::vec2 center={0.5f, 0.5f}) |
| Scales a point uniformly relative to a center point. | |
| std::optional< Point > | segment_intersection (const Point &p1, const Point &p2, const Point &q1, const Point &q2) |
| Computes the intersection point of two 2D segments, if it exists. | |
| float | side (const Point &p1, const Point &p2, const Point &p3, const Point &p_query) |
| Determines the relative side of a query point with respect to a curve segment. | |
| void | sort_points (std::vector< Point > &points) |
| Sorts a vector of points in ascending order (x, then y, then v). | |
| float | triangle_area (const Point &p1, const Point &p2, const Point &p3) |
| Calculates the unsigned area of a triangle formed by three points. | |
| float | triangle_area_signed (const Point &p1, const Point &p2, const Point &p3) |
| Calculates the signed area of a triangle formed by three points. | |
| BBox2D | unit_square_bbox () |
| Constructs a 4D bounding box for a unit square {0, 1, 0, 1}. | |
| std::array< std::pair< float, float >, 2 > | bbox_to_ranges2d (const BBox2D &bbox) |
| Converts a 2D bounding box into coordinate ranges. | |
| void | expand_points_domain (std::vector< float > &x, std::vector< float > &y, std::vector< float > &value, const BBox2D &bbox=BBox2D{}) |
| Expand grid by translating and copying the values of the current bounding box to the 8 first neighboring bounding boxes. | |
| void | expand_points_at_domain_boundaries (std::vector< float > &x, std::vector< float > &y, std::vector< float > &value, const BBox2D &bbox=BBox2D{}, float boundary_value=0.f) |
| Expand the grid by adding points on the boundaries of the bounding box. | |
| void | expand_points_domain_corners (std::vector< float > &x, std::vector< float > &y, std::vector< float > &value, const BBox2D &bbox=BBox2D{}, float corner_value=0.f) |
| Expand the grid by adding four points at the corner of the bounding box. | |
| std::function< float(const ps::Point< float, 2 > &)> | make_pointwise_function_from_array (const Array &array, const BBox2D &bbox) |
| Create a continuous 2D function from a sampled array. | |
| std::array< std::vector< float >, 2 > | random_points (size_t count, std::uint32_t seed, const PointSamplingMethod &method=PointSamplingMethod::RND_RANDOM, const BBox2D &bbox=BBox2D{}) |
| Generates random 2D points within a bounding box using a sampling method. | |
| std::array< std::vector< float >, 2 > | random_points_density (size_t count, const Array &density, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates random 2D points within a bounding box based on a density map. | |
| std::array< std::vector< float >, 2 > | random_points_inverse_sampling (size_t count, const Array &array, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates random 2D points within a bounding box using inverse transform sampling on a 2D density array. | |
| std::array< std::vector< float >, 2 > | random_points_distance (float min_dist, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates random 2D points with a minimum separation distance. | |
| std::array< std::vector< float >, 2 > | random_points_distance (float min_dist, float max_dist, const Array &density, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates random 2D points with distance constraints and a density map. | |
| std::array< std::vector< float >, 2 > | random_points_distance_power_law (float dist_min, float dist_max, float alpha, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates random 2D points with distances drawn from a power-law distribution. | |
| std::array< std::vector< float >, 2 > | random_points_distance_weibull (float dist_min, float lambda, float k, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates random 2D points with distances drawn from a Weibull distribution. | |
| std::array< std::vector< float >, 2 > | random_points_jittered (size_t count, const glm::vec2 &jitter_amount, const glm::vec2 &stagger_ratio, std::uint32_t seed, const BBox2D &bbox=BBox2D{}) |
| Generates jittered grid-based 2D points. | |
| void | remove_points_outside_bbox (std::vector< float > &x, std::vector< float > &y, std::vector< float > &value, const BBox2D &bbox=BBox2D{}) |
| Remove grid points that are outside a given bounding box. | |
| void | rescale_points_to_unit_square (std::vector< float > &x, std::vector< float > &y, const BBox2D &bbox) |
| Rescale coordinate (x, y) so that they fit in a unit-square box based on a given initial bounding box. | |
| Array | divergence_from_gradients (const Array &dx, const Array &dy) |
| Compute the divergence of a 2D gradient field. | |
| std::vector< float > | gradient1d (const std::vector< float > &v) |
| Compute the gradient of a 1D vector. | |
| Array | gradient_angle (const Array &array, bool downward=false) |
| Compute the polar angle of the gradient of a 2D array. | |
| Array | gradient_angle_circular_smoothing (const Array &array, int ir, bool downward=false) |
| Computes a smoothed gradient angle (aspect) field with circular unwrapping. | |
| Array | gradient_norm (const Array &array, Array *p_dx=nullptr, Array *p_dy=nullptr) |
| Compute the gradient norm of a 2D array. | |
| Array | gradient_norm_filtered (const Array &array, int ir) |
| Compute a smoothed gradient magnitude map. | |
| Array | gradient_norm_prewitt (const Array &array, Array *p_dx=nullptr, Array *p_dy=nullptr) |
| Compute the gradient norm of a 2D array using the Prewitt filter. | |
| Array | gradient_norm_scharr (const Array &array, Array *p_dx=nullptr, Array *p_dy=nullptr) |
| Compute the gradient norm of a 2D array using the Scharr filter. | |
| Array | gradient_norm_sobel (const Array &array, Array *p_dx=nullptr, Array *p_dy=nullptr) |
| Compute the gradient norm of a 2D array using the Sobel filter. | |
| Array | gradient_talus (const Array &array) |
| Compute the gradient talus slope of a 2D array. | |
| void | gradient_talus (const Array &array, Array &talus) |
| Compute the gradient talus slope and store it in the provided array. | |
| Array | gradient_x (const Array &array) |
| Compute the gradient in the x-direction of a 2D array. | |
| void | gradient_x (const Array &array, Array &dx) |
| Compute the gradient in the x-direction of a 2D array and store it. | |
| Array | gradient_y (const Array &array) |
| Compute the gradient in the y-direction of a 2D array. | |
| void | gradient_y (const Array &array, Array &dy) |
| Compute the gradient in the y-direction of a 2D array and store it. | |
| Array | laplacian (const Array &array) |
| Compute the Laplacian of a 2D array. | |
| Texture | normal_map (const Array &array) |
| Generates a normal map from a given 2D array. | |
| Array | normal_map_to_heightmap (const Texture &nmap) |
| Converts a normal map to a heightmap using direct summation of gradients. | |
| Array | normal_map_to_heightmap_poisson (const Texture &nmap, int iterations=500, float omega=1.5f) |
| void | solve_poisson_gauss_seidel (const Array &rhs, Array &h, int iterations=500, float omega=1.0f) |
| Solve the Poisson equation ∇²h = rhs using Gauss–Seidel iteration. | |
| Array | unwrap_phase (const Array &alpha) |
| Unwraps a 2D phase array to correct discontinuities in phase data. | |
| Array | talus_jump_mask (const Array &z, float threshold, float sigma) |
| Array | basin_id (const Array &z, bool fast_approx=false, bool remove_lakes=true) |
| Label drainage basins using a priority-flood algorithm. | |
| Array | carve_riverbed (const Array &z, const Array &z_river, float talus_riverbank=0.01f, bool smooth_river_bottom=true, float merging_distance=8.f, std::uint32_t seed=0, float riverbank_noise_ratio=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Blends and carves smooth riverbanks around modified riverbed profiles. | |
| Array | d8_compute_ndip (const Array &d8) |
| Computes the number of drainage paths for each cell based on the D8 flow direction model. | |
| void | find_flow_apex (const Array &z, std::vector< int > &is, std::vector< int > &js) |
| Identifies flow apex (source) cells using D8 flow routing. | |
| void | find_flow_sinks (const Array &z, std::vector< int > &is, std::vector< int > &js) |
| Identifies the indices of flow sinks within the heightmap. | |
| std::vector< glm::ivec2 > | find_flow_sinks (const Array &z) |
| Find interior flow sinks in a height field. | |
| std::vector< glm::ivec2 > | find_flow_sinks_border (const Array &z) |
| Find flow sinks located on the domain border. | |
| Array | flooding_uniform_level (const Array &z, float zref) |
| Compute water depth for a uniform flooding level. | |
| Array | flooding_from_boundaries (const Array &z, float zref, bool from_east=true, bool from_west=true, bool from_north=true, bool from_south=true, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Compute flooding starting from the lowest boundary points. | |
| Array | flooding_from_point (const Array &z, int i, int j, float depth_min=std::numeric_limits< float >::max(), const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Flood terrain starting from a single seed point. | |
| Array | flooding_from_point (const Array &z, const std::vector< int > &i, const std::vector< int > &j, float depth_min=std::numeric_limits< float >::max(), const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Flood terrain starting from multiple seed points. | |
| Array | flooding_lake_system (const Array &z, float surface_threshold=0.f, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Estimate lake water depths on a terrain by filling depressions. | |
| Array | flow_accumulation_d8 (const Array &z) |
| Computes the flow accumulation for each cell using the D8 flow direction model. | |
| Array | flow_accumulation_stochastic (const Array &z, int n_samples=1<< 19, std::uint32_t seed=0, const Array *p_source=nullptr, const Array *p_decay=nullptr) |
| Computes flow accumulation using a stochastic (Monte-Carlo) transport estimator. | |
| Array | flow_accumulation_dinf (const Array &z, float talus_ref=0.1f, int iterations=0, const UvTile ®ion={}, ICommunicator &comm=SingleArrayComm::instance()) |
| Computes the flow accumulation for each cell using the Multiple Flow Direction (MFD) model. | |
| Array | flow_accumulation_dinf_perturbed (const Array &z, float talus_ref, int nsamples, glm::vec2 kw, std::uint32_t seed, float amp, const Array *p_perturb_scaling=nullptr, const UvRect &uv_rect=UvRect::unit(), int iterations=0, const UvTile ®ion={}, ICommunicator &comm=SingleArrayComm::instance()) |
| Computes averaged D-infinity flow accumulation with terrain perturbations. | |
| Array | flow_direction_d8 (const Array &z) |
| Computes the flow direction from each cell to its downslope neighbor using the D8 model. | |
| std::vector< Array > | flow_direction_dinf (const Array &z, float talus_ref) |
| Computes the flow direction and weights for each direction using the Multiple Flow Direction (MFD) model. | |
| std::vector< float > | flow_direction_dinf_flat (const Array &z, float talus_ref) |
| Array | flow_direction_dinf_angle (const Array &z, float talus_ref) |
| Computes the flow direction using the Multiple Flow Direction (MFD) model. | |
| Array | flow_fixing (const Array &z, float riverbed_talus=0.f, int iterations=5, int prefilter_ir=8, bool carve_riverbed=true, float merging_distance=8.f, const Array *p_noise_r=nullptr) |
| Array | flow_fixing_drainage_basin (const Array &z, bool fast_approx=false, float riverbed_talus=1e-4f, int iterations=3, bool carve_riverbed=false, float talus_riverbank=0.01f, float merging_distance=8.f, std::uint32_t seed=0, float noise_strength=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Fixes flow paths and unwanted upslopes using a cell-based drainage basin tree network and elevation updates. | |
| Array | flow_fixing_mst (const Array &z, float riverbed_talus=0.f, float elevation_ratio=0.95f, float distance_exponent=2.f, float upward_penalization=0.1f, float valley_affinity=0.5f, int prefilter_ir=8, float minimum_depth=1e-4f, bool carve_riverbed=true, float merging_distance=8.f, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP_UPPER, float radial_profile_parameter=2.f, const Array *p_noise_r=nullptr, bool use_midpoint=false, float offset_ratio=0.2f) |
| Resolves flow sinks and unwanted upslopes using Dijkstra pathfinding and a Minimum Spanning Tree (MST) over sinks and boundary outlets. | |
| std::vector< Path > | flow_fixing_mst_paths (const TerrainTriMesh &mesh, float riverbed_talus=0.f, float elevation_ratio=0.95f, float distance_exponent=2.f, float upward_penalization=0.1f, float minimum_depth=1e-4f) |
| Computes river flow paths resolving depressions via Minimum Spanning Tree (MST) on a triangular terrain mesh. | |
| std::vector< Path > | flow_fixing_mst_paths (const Array &z, size_t control_points_count=2048, std::uint32_t seed=0, float riverbed_talus=0.f, float elevation_ratio=0.95f, float distance_exponent=2.f, float upward_penalization=0.1f, float minimum_depth=1e-4f) |
| Computes river flow paths resolving depressions via Minimum Spanning Tree (MST) on a triangular mesh generated from a heightmap. | |
| Array | flow_fixing_mst_triangulated (const Array &z, size_t control_points_count=2048, std::uint32_t seed=0, float riverbed_talus=0.f, float elevation_ratio=0.95f, float distance_exponent=2.f, float upward_penalization=0.1f, float minimum_depth=1e-4f, float merging_distance=8.f, RadialProfile radial_profile=RadialProfile::RP_SMOOTHSTEP_UPPER, float radial_profile_parameter=2.f, const Array *p_noise_r=nullptr) |
| Resolves flow sinks on a heightmap by computing an MST on a triangular mesh and carving the resulting river paths with trenching. | |
| Path | flow_stream (const Array &z, const glm::ivec2 ij_start, const float elevation_ratio=0.5f, const float distance_exponent=2.f, const float upward_penalization=100.f, const std::vector< Path > &existing_streams={}, const int valley_radius=2, const float valley_factor=0.35f, const bool truncate_at_intersection=false) |
| Computes the optimal flow path from a starting point to the boundary of a given elevation array. | |
| Path | flow_stream (const TerrainTriMesh &mesh, size_t start_vertex_index, float elevation_ratio=0.5f, float distance_exponent=2.f, float upward_penalization=100.f, bool favor_domain_center=false, const std::vector< Path > &existing_streams={}, float valley_radius=0.02f, float valley_factor=0.35f, bool truncate_at_intersection=false) |
| Computes the optimal flow path from a starting vertex to the boundary of a terrain triangular mesh. | |
| Path | flow_stream (const TerrainTriMesh &mesh, glm::vec2 xy_start, float elevation_ratio=0.5f, float distance_exponent=2.f, float upward_penalization=100.f, bool favor_domain_center=false, const std::vector< Path > &existing_streams={}, float valley_radius=0.02f, float valley_factor=0.35f, bool truncate_at_intersection=false) |
| Computes the optimal flow path from starting 2D coordinates to the boundary of a terrain triangular mesh. | |
| Array | generate_riverbed (const Path &path, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), bool bezier_smoothing=false, float depth_start=0.01f, float depth_end=1.f, float slope_start=64.f, float slope_end=32.f, float shape_exponent_start=1.f, float shape_exponent_end=10.f, float k_smoothing=0.5f, int post_filter_ir=0, Array *p_noise_x=nullptr, Array *p_noise_y=nullptr, Array *p_noise_r=nullptr) |
| Generates a 2D array representing a riverbed based on a specified path. | |
| Graph | hydrology_paths_to_graph (const std::vector< Path > &paths, float snap_tolerance=1e-4f) |
| Convert a collection of hydrology flow paths into a connected Graph. | |
| Array | merge_water_depths (const Array &depth1, const Array &depth2, float k_smooth=0.f) |
| Merge two water depth fields. | |
| Array | snow_melting_map (const Array &z, float melt_start_elevation=0.f, float melt_end_elevation=0.5f, float elevation_strength=1.f, float elevation_exp=1.f, float sun_azimuth=0.f, float sun_zenith=60.f, float aspect_strength=0.f, float slope_exp=1.f, float slope_strength=0.f) |
| Generate a spatial snow melting map from terrain features. | |
| Array | water_depth_from_mask (const Array &z, const Array &mask, float mask_threshold=0.f, int iterations_max=10000, float tolerance=1e-2f) |
| Compute water depth over a masked terrain using harmonic interpolation. | |
| void | water_depth_dry_out (Array &water_depth, float dry_out_ratio=0.5f, const Array *p_mask=nullptr, float depth_max=std::numeric_limits< float >::max()) |
| Apply a drying factor to a water depth field. | |
| Array | water_depth_increase (const Array &water_depth, const Array &z, float additional_depth) |
| Simulates a local increase in water depth without global reflooding. | |
| Array | water_depth_increase_with_flooding (const Array &water_depth, const Array &z, float additional_depth) |
| Simulates a physical rise in water level with full domain flooding. | |
| Array | water_frontier_curvature (const Array &water_depth, int prefilter_ir, bool extend_values_from_interface=false) |
| Compute the curvature of the water interface from a signed distance field. | |
| Array | water_mask (const Array &water_depth) |
| Generates a binary mask representing water presence. | |
| Array | water_mask (const Array &water_depth, const Array &z, float additional_depth) |
| Computes a gradient-based water mask using an extended water depth model. | |
| bool | assert_almost_equal (const Array &a, const Array &b, float tolerance=1e-6f, const std::string &fname="", AssertResults *p_results=nullptr) |
| bool | is_subset (const Array &a, const Array &b) |
| void | print_array (const Array &arr, bool show_coords=false, int width=6, int precision=2) |
| void | dump_visual_check (const Array &array, const std::string &fname="check.png") |
| uint32_t | float_key (float f) |
| float | key_float (uint32_t k) |
| float | next_up (float f) |
| std::filesystem::path | add_filename_suffix (const std::filesystem::path &file_path, const std::string &suffix) |
| Adds a suffix to the filename of a given file path. | |
| std::filesystem::path | make_unique_temp_dir (const std::string &prefix) |
| Create a unique temporary directory. | |
| std::string | zfill (const std::string &str, int n_zero) |
| Pads the beginning of a string with zeros until it reaches a specified length. | |
| bool | validate_shape (glm::ivec2 shape, const std::source_location &loc=std::source_location::current()) |
| Validates that array dimensions are strictly positive. | |
| bool | validate_non_empty (const Array &array, const std::source_location &loc=std::source_location::current()) |
| Validates that an array is initialized, non-empty, and has a consistent buffer size. | |
| template<typename T> requires requires(const T &t) { { t.empty() } -> std::convertible_to<bool>; } | |
| bool | validate_non_empty (const T &container, std::string_view name="Container", const std::source_location &loc=std::source_location::current()) |
| Validates that a container or object with an empty() method is not empty. | |
| template<typename T> requires requires(const T &t) { { t.size() } -> std::convertible_to<size_t>; } | |
| bool | validate_min_size (const T &container, size_t min_size, std::string_view name="Container", const std::source_location &loc=std::source_location::current()) |
| Validates that a container has at least min_size elements. | |
| bool | validate_same_shape (const Array &a, const Array &b, const std::source_location &loc=std::source_location::current()) |
| Validates that two arrays have identical shapes and buffer sizes. | |
| bool | validate_same_shape (glm::ivec2 shape, const Array &b, const std::source_location &loc=std::source_location::current()) |
| Validates that an array has the expected 2D shape. | |
| bool | validate_non_empty (const Texture &tex, int min_channels=1, const std::source_location &loc=std::source_location::current()) |
| Validates that a Texture is initialized, non-empty, and has valid channel buffers. | |
| bool | validate_channels (const Texture &tex, int expected_channels, const std::source_location &loc=std::source_location::current()) |
| Validates exact channel count of a Texture. | |
| bool | validate_same_shape (const Texture &a, const Texture &b, const std::source_location &loc=std::source_location::current()) |
| Validates that two Textures have matching 2D shapes. | |
| bool | validate_same_shape (const Texture &tex, const Array &arr, const std::source_location &loc=std::source_location::current()) |
| Validates that a Texture and an Array have matching 2D shapes. | |
| bool | validate_slice (const Array &array, glm::ivec4 idx, const std::source_location &loc=std::source_location::current()) |
| Validates that a slice extent {i1, i2, j1, j2} is valid and within array boundaries. | |
| bool | validate_slice_for_array (const Array &dest, glm::ivec4 idx, const Array &src, const std::source_location &loc=std::source_location::current()) |
| Validates that a slice extent matches the dimensions of a source array. | |
| bool | validate_not_zero (float value, const std::source_location &loc=std::source_location::current()) |
| Validates that a divisor value is not zero. | |
| bool | validate_parameter_range (glm::vec2 range, float min_val, float max_val, std::string_view param_name="Range", const std::source_location &loc=std::source_location::current()) |
| Validates that a 2D range vector {low, high} lies within [min_val, max_val] with low <= high. | |
| bool | validate_finite (const Array &array, const std::source_location &loc=std::source_location::current()) |
| Validates that all elements of an array are finite (not NaN or Inf). | |
| bool | validate_cmap (int cmap, const std::source_location &loc=std::source_location::current()) |
| Validates that a colormap ID corresponds to a valid Cmap enum value. | |
| constexpr float | bilinear_interp (float f00, float f10, float f01, float f11, float u, float v) noexcept |
| Compute the bilinear interpolated value from four input values. | |
| void | bspline_weights (float t, float w[4]) noexcept |
| Compute uniform cubic B-spline weights for a fractional parameter in [0, 1). | |
| constexpr float | cubic_interpolate (const float p[4], float x) noexcept |
| Array | harmonic_interpolation (const Array &array, const Array &mask_fixed_values, int iterations_max=500, float tolerance=1e-5f, float omega=0.f, int sync_interval=0, const UvTile ®ion=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance()) |
| Perform harmonic interpolation on a 2D array using the Successive Over-Relaxation (SOR) method. | |
| Array | harmonic_interpolation (const Array &array, const Array &mask_fixed_values, const Array &dx, const Array &dy, int iterations_max=500, float tolerance=1e-5f, float omega=0.f, int sync_interval=0, const UvTile ®ion=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance()) |
| Perform harmonic interpolation on a 2D array with 2D variable diffusion coefficients (Dx, Dy) using the Successive Over-Relaxation (SOR) method. | |
| Array | interpolate2d (glm::ivec2 shape, const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &values, InterpolationMethod2D interpolation_method, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Generic 2D interpolation function. | |
| Array | interpolate2d_delaunay (glm::ivec2 shape, const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &values, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float fill_value=0.f) |
| 2D interpolation using the Delaunay triangulation method. | |
| Array | interpolate2d_delaunay_gradient (glm::ivec2 shape, const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &values, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float fill_value=0.f, float gradient_scaling=1.f) |
| 2D interpolation using a smoother version of the Delaunay triangulation method. | |
| Array | interpolate2d_gaussian (glm::ivec2 shape, const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &values, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float sigma=0.05f, float radius=0.f) |
| 2D interpolation using the Gaussian kernel method. | |
| Array | interpolate2d_idw (glm::ivec2 shape, const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &values, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float distance_exp=2.f, float radius=0.f) |
| 2D interpolation using the IDW method. | |
| Array | interpolate2d_nearest (glm::ivec2 shape, const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &values, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| 2D interpolation using the nearest neighbor method. | |
| Array | interpolate2d_nni (glm::ivec2 shape, const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &values, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| 2D interpolation using the Natural Neighbor Interpolation method. | |
| void | interpolate_array_bicubic (const Array &source, Array &target, bool endpoint=false, bool pixel_centered=true) |
| Resample an array to a target array using bicubic interpolation. | |
| void | interpolate_array_bicubic (const Array &source, Array &target, const UvRect &uv_rect_source, const UvRect &uv_rect_target, bool endpoint=false, bool pixel_centered=true) |
| Resample a source array into a target array using bicubic interpolation between two local axis-aligned bounding boxes. | |
| void | interpolate_array_bilinear (const Array &source, Array &target, bool endpoint=false, bool pixel_centered=true) |
| Resample an array to a target array using bilinear interpolation. | |
| void | interpolate_array_bilinear (const Array &source, Array &target, const UvRect &uv_rect_source, const UvRect &uv_rect_target, bool endpoint=false, bool pixel_centered=true) |
| Resample a source array into a target array using bilinear interpolation between two local axis-aligned bounding boxes. | |
| void | interpolate_array_nearest (const Array &source, Array &target, bool endpoint=false) |
| Resample an array to a target array using nearest-neighbor interpolation. | |
| void | interpolate_array_nearest (const Array &source, Array &target, const UvRect &uv_rect_source, const UvRect &uv_rect_target, bool endpoint=false) |
| Resample a source array into a target array using nearest-neighbor interpolation between two local axis-aligned bounding boxes. | |
| Array | resample_bicubic_warp (const Array &src, glm::ivec2 dst_shape, float warp=0.f, std::uint32_t seed=0) |
| Resample an array to a target shape using cubic B-spline interpolation with optional domain noise warping. | |
| void | flatten_terrain (Array &h_source1, const Array &h_source2, const CoordFrame &t_source1, const CoordFrame &t_source2, bool bilinear=true) |
| Blend a second terrain array in-place onto a base terrain array using their world-space coordinate frames. | |
| void | flatten_terrain (const std::vector< const Array * > &h_sources, Array &h_target, const std::vector< const CoordFrame * > &t_sources, const CoordFrame &t_target, bool bilinear=true) |
| Flatten multiple terrain arrays into a target array using their world-space coordinate frames. | |
| void | interpolate_terrain (const Array &h_source, Array &h_target, const CoordFrame &t_source, const CoordFrame &t_target, bool bilinear=true, float fill_value=0.f, Array *p_mask=nullptr) |
| Project and interpolate a source terrain array onto a target terrain array using their world-space coordinate frames. | |
| void | flatten_terrain (VirtualArray &h_source1, const VirtualArray &h_source2, const CoordFrame &t_source1, const CoordFrame &t_source2, const ComputeMode &cm, bool bilinear=true) |
| Blend a second terrain VirtualArray in-place onto a base terrain VirtualArray using their world-space coordinate frames. | |
| void | flatten_terrain (const std::vector< const VirtualArray * > &h_sources, VirtualArray &h_target, const std::vector< const CoordFrame * > &t_sources, const CoordFrame &t_target, const ComputeMode &cm, bool bilinear=true) |
| Flatten multiple terrain VirtualArrays into a target VirtualArray using their world-space coordinate frames. | |
| void | interpolate_terrain (const VirtualArray &h_source, VirtualArray &h_target, const CoordFrame &t_source, const CoordFrame &t_target, const ComputeMode &cm, bool bilinear=true, float fill_value=0.f, VirtualArray *p_mask=nullptr) |
| Project and interpolate a source terrain VirtualArray onto a target terrain VirtualArray using their world-space coordinate frames. | |
| Array | get_kernel (glm::ivec2 shape, KernelType kernel_type) |
| Generate a kernel of the specified type. | |
| Array | biweight (glm::ivec2 shape) |
| Generates a biweight kernel array. | |
| Array | blackman (glm::ivec2 shape) |
| Generates a Blackman window array with the specified shape. | |
| Array | cone (glm::ivec2 shape) |
| Generates a cone-shaped kernel array. | |
| Array | cone_talus (float height, float talus) |
| Generates a cone-shaped kernel with specified height and talus. | |
| Array | cone_smooth (glm::ivec2 shape) |
| Generates a cone-shaped kernel with a smooth landing. | |
| Array | cubic_pulse (glm::ivec2 shape) |
| Generates a cubic pulse kernel array. | |
| std::vector< float > | cubic_pulse_1d (int nk) |
| Generates a 1D cubic pulse kernel. | |
| Array | cubic_pulse_directional (glm::ivec2 shape, float angle, float aspect_ratio, float anisotropy) |
| Generates a "directional" cubic pulse kernel. | |
| Array | cubic_pulse_truncated (glm::ivec2 shape, float slant_ratio, float angle) |
| Generates a truncated cubic pulse kernel. | |
| Array | cupola (glm::ivec2 shape, float rc=0.5f) |
| Generate a 2D radial cupola kernel. | |
| Array | disk (glm::ivec2 shape) |
| Generates a disk-shaped kernel footprint. | |
| Array | disk_smooth (glm::ivec2 shape, float r_cutoff=0.9f) |
| Generates a smooth, disk-shaped kernel footprint with soft edges. | |
| Array | gabor (glm::ivec2 shape, float kw, float angle, bool quad_phase_shift=false) |
| Generates a Gabor kernel of the specified shape. | |
| Array | gabor_dune (glm::ivec2 shape, float kw, float angle, float xtop, float xbottom) |
| Generates a modified dune-like Gabor kernel. | |
| Array | hann (glm::ivec2 shape) |
| Generates a Hann window array with the specified shape. | |
| Array | lorentzian (glm::ivec2 shape, float footprint_threshold=0.1f) |
| Generate a Lorentzian kernel. | |
| Array | lorentzian_compact (glm::ivec2 shape) |
| Generate a modified Lorentzian kernel with compact support. | |
| Array | sinc_radial (glm::ivec2 shape, float kw) |
| Generates a radial sinc function array with the specified shape and wave number. | |
| Array | sinc_separable (glm::ivec2 shape, float kw) |
| Generates a separable sinc function array with the specified shape and wave number. | |
| Array | smooth_cosine (glm::ivec2 shape) |
| Generate a smooth cosine kernel. | |
| Array | square (glm::ivec2 shape) |
| Generate a square-shaped kernel. | |
| Array | tricube (glm::ivec2 shape) |
| Generate a tricube kernel. | |
| Array | path_length_to_outlet (const Array &z) |
| Computes the downstream path length to the domain outlet. | |
| Array | path_length_to_sink (const Array &z) |
| Computes the downstream path length to the nearest sink. | |
| Array | local_max (const Array &array, int ir) |
| Return the local maxima based on a maximum filter with a square kernel. | |
| Array | local_median_deviation (const Array &array, int ir) |
| Computes the local median deviation of a 2D array. | |
| Array | local_min (const Array &array, int ir) |
| Return the local minima based on a maximum filter with a square kernel. | |
| Array | local_mean (const Array &array, int ir) |
| Return the local mean based on a mean filter with a square kernel. | |
| Array | relative_elevation (const Array &array, int ir) |
| Calculates the relative elevation within a specified radius, helping to identify local highs and lows. | |
| Array | roughness (const Array &array, int ir) |
| Measures the local surface roughness within a given radius. | |
| Array | ruggedness (const Array &array, int ir) |
| Computes the ruggedness of each element in the input array. | |
| Array | rugosity (const Array &z, int ir, bool convex=true) |
| Estimates the rugosity of a surface by analyzing the skewness of the elevation data, which reflects surface roughness. | |
| Array | topographic_wetness_index (const Array &z, float talus_ref=0.f, float min_slope=1e-4f) |
| Computes the Topographic Wetness Index (TWI). | |
| Array | topographic_residual (const Array &z, int ir, bool normalize_output=false) |
| Computes the topographic residual (relief) relative to a smoothed surface. | |
| Array | valley_width (const Array &z, int ir=0, bool ridge_select=false) |
| Measures the valley width by calculating the distance from each point in a concave region to the frontier of that region. | |
| Array | abs (const Array &array) |
| Absolute value. | |
| Array | abs_smooth (const Array &array, float mu, const Array &vshift) |
| Smooth absolute value. | |
| Array | abs_smooth (const Array &array, float mu, float vshift) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array | abs_smooth (const Array &array, float mu) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array | almost_unit_identity (const Array &array) |
| Almost unit identity function. | |
| Array | almost_unit_identity_c2 (const Array &array) |
| Almost unit identity function (C2 variant). | |
| Array | atan (const Array &array) |
| Arctangent. | |
| Array | atan2 (const Array &y, const Array &array) |
| Element-wise arctangent with quadrant handling. | |
| Array | build_density_linear (const std::vector< const Array * > &layers, const std::vector< float > &weights={}) |
| Combine a list of layers in linear space. | |
| Array | build_density_log (const std::vector< const Array * > &layers, const std::vector< float > &weights={}, float eps=1e-6f) |
| Combine a list of layers in log space. | |
| Array | cos (const Array &array) |
| Cosine. | |
| Array | exp (const Array &array) |
| Exponential. | |
| Array | gaussian_decay (const Array &array, float sigma) |
| Gaussian decay. | |
| Array | hypot (const Array &array1, const Array &array2) |
| Hypotenuse. | |
| Array | is_equal (const Array &array, float value) |
| Binary mask of elements equal to a value. | |
| Array | is_non_zero (const Array &array) |
| Binary mask of non-zero elements. | |
| Array | is_zero (const Array &array) |
| Binary mask of zero elements. | |
| Array | lerp (const Array &array1, const Array &array2, const Array &t) |
| Linear interpolation. | |
| Array | lerp (const Array &array1, const Array &array2, float t) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array | log10 (const Array &array) |
| Base-10 logarithm. | |
| Array | log_safe (const Array &array, float eps=1e-6f) |
| Safe natural logarithm with lower clamp. | |
| Array | pow (const Array &array, float exp) |
| Power function. | |
| Array | r_min (const Array &array1, const Array &array2, float alpha=0.f) |
| Generalized Rvachev R-function for smooth minimum / intersection (exact zero-set). | |
| Array | r_max (const Array &array1, const Array &array2, float alpha=0.f) |
| Generalized Rvachev R-function for smooth maximum / union (exact zero-set). | |
| Array | sigmoid (const Array &array, float width=1.f, float vmin=0.f, float vmax=1.f, float x0=0.f) |
| Sigmoid function. | |
| Array | sin (const Array &array) |
| Sine. | |
| Array | smoothstep3 (const Array &array, float vmin=0.f, float vmax=1.f) |
| Cubic smoothstep. | |
| Array | smoothstep3_lower (const Array &array) |
| Cubic smoothstep (zero derivative at 0 only). | |
| Array | smoothstep3_upper (const Array &array) |
| Cubic smoothstep (zero derivative at 1 only). | |
| Array | smoothstep5 (const Array &array, float vmin=0.f, float vmax=1.f) |
| Quintic smoothstep. | |
| Array | smoothstep5 (const Array &array, const Array &vmin, const Array &vmax) |
| Array | smoothstep5_lower (const Array &array) |
| Quintic smoothstep (zero derivative at 0 only). | |
| Array | smoothstep5_upper (const Array &array) |
| Quintic smoothstep (zero derivative at 1 only). | |
| Array | smoothstep7 (const Array &array) |
| Seventh-order smoothstep. | |
| Array | sqrt (const Array &array) |
| Square root. | |
| Array | sqrt_safe (const Array &array) |
| Safe square root. | |
| Array | threshold (const Array &array, float x0, float x1) |
| Linear threshold. | |
| Array | threshold_smooth (const Array &array, float x0, float x1) |
| Smooth threshold. | |
| Array | convolve1d_i (const Array &array, const std::vector< float > &kernel) |
| Return the convolution product of the array with a 1D kernel along the 'i' direction. | |
| Array | convolve1d_j (const Array &array, const std::vector< float > &kernel) |
| Return the convolution product of the array with a 1D kernel along the 'j' direction. | |
| Array | convolve2d (const Array &array, const Array &kernel) |
| Return the convolution product of the array with a given 2D kernel. | |
| Array | convolve2d_truncated (const Array &array, const Array &kernel) |
| Return the convolution product of the array with a given 2D kernel, with a truncated output size. | |
| Array | convolve2d_svd (const Array &z, const Array &kernel, int rank=3) |
| Return the approximate convolution product of the array with a Singular Value Decomposition (SVD) of a kernel. | |
| Array | convolve2d_svd_rotated_kernel (const Array &z, const Array &kernel, int rank=3, int n_rotations=6, std::uint32_t seed=1) |
| Return the approximate convolution product of the array with a Singular Value Decomposition (SVD) of a kernel combined with kernel rotations. | |
| float | abs_smooth (float a, float mu) |
| Smooth absolute value. | |
| float | almost_unit_identity (float x) |
| Almost unit identity function. | |
| float | almost_unit_identity_c2 (float x) |
| Almost unit identity function (C2 variant). | |
| float | approx_hypot (float a, float b) |
| Approximate hypotenuse. | |
| float | approx_rsqrt (float a) |
| Fast inverse square root approximation. | |
| int | ceil_div (int a, int b) |
| Integer ceiling division. | |
| float | fast_exp (float x) |
| Fast exponential approximation. | |
| float | fast_log (float x) |
| Fast natural logarithm approximation. | |
| float | gain (float x, float factor) |
| Gain curve remapping in [0,1]. | |
| int | highest_power_of_2 (int n) |
| Highest power of 2 less than or equal to n. | |
| float | lerp (float a, float b, float t) |
| Linear interpolation. | |
| float | log_safe (float x, float eps=1e-6f) |
| Safe natural logarithm with lower clamp. | |
| float | power_curve (float x, float a, float b) |
| Smooth asymmetric bell-shaped curve on [0,1]. | |
| float | r_min (float f1, float f2, float alpha=0.f) |
| Generalized Rvachev R-function for smooth minimum / intersection (exact zero-set). | |
| float | r_max (float f1, float f2, float alpha=0.f) |
| Generalized Rvachev R-function for smooth maximum / union (exact zero-set). | |
| float | sigmoid (float x, float width=1.f, float vmin=0.f, float vmax=1.f, float x0=0.f) |
| Sigmoid function. | |
| float | smoothstep3 (float x) |
| Cubic smoothstep function. | |
| float | smoothstep3 (float x, float clamp_min, float clamp_max) |
| Cubic smoothstep function with clamping. | |
| float | smoothstep3_lower (float x) |
| Cubic smoothstep (zero derivative at 0 only). | |
| float | smoothstep3_upper (float x) |
| Cubic smoothstep (zero derivative at 1 only). | |
| float | smoothstep5 (float x) |
| Quintic smoothstep function. | |
| float | smoothstep5_lower (float x) |
| Quintic smoothstep (zero derivative at 0 only). | |
| float | smoothstep5_upper (float x) |
| Quintic smoothstep (zero derivative at 1 only). | |
| float | smoothstep7 (float x) |
| Seventh-order smoothstep function. | |
| float | threshold (float x, float x0, float x1) |
| Linear threshold. | |
| float | threshold_smooth (float x, float x0, float x1) |
| Smooth threshold using smoothstep. | |
| float | trapeze (float x, float x0, float x1, float width) |
| Computes a trapezoidal pulse function. | |
| float | trapeze_smooth (float x, float x0, float x1, float width) |
| Smooth trapezoidal pulse using cubic smoothstep interpolation. | |
| float | triangle (float x, float vmin, float vmax) |
| Triangle function between bounds. | |
| std::function< float(float, float)> | get_distance_function (DistanceFunction dist_fct, DistanceFunctionAxis dfa=DistanceFunctionAxis::DFA_XY) |
| Return the requested distance function. | |
| std::function< float(float)> | get_erosion_profile_function (const ErosionProfile &erosion_profile, float delta, float &profile_avg) |
| Generates a function representing an erosion profile based on the specified type and parameters. | |
| std::function< float(float)> | get_phasor_profile_function (PhasorProfile phasor_profile, float delta, float *p_profile_avg=nullptr) |
| Generates a function representing a phasor profile based on the specified type and parameters. | |
| std::function< float(float)> | get_radial_profile_function (RadialProfile radial_profile, float delta) |
| Returns a normalized radial profile function. | |
| Array | area_remove (const Array &array, float threshold_size, float background_value=0.f, float fill_value=0.f) |
| Remove connected components smaller than a given size threshold. | |
| Array | border (const Array &array, int ir) |
| Apply a border algorithm to the input array using a square structure. | |
| Array | closing (const Array &array, int ir) |
| Apply a closing algorithm to the input array using a square structure. | |
| Array | closing_by_reconstruction (const Array &array, int ir, float k_smooth_max=0.f) |
| Apply closing by reconstruction to the input array. | |
| Array | contour_smoothing (const Array &array, int ir, float transition_ratio=0.1f) |
| Smooth contour boundaries of segmented regions. | |
| Array | dilation (const Array &array, int ir) |
| Apply a dilation algorithm to the input array using a square structure. | |
| Array | dilation_expand_border_only (const Array &array, int ir) |
| Expand non-zero regions of an array by morphological dilation, while preserving the original non-zero values. | |
| Array | dilation_expand_min_value_border_only (const Array &array) |
| Array | distance_transform (const Array &array, bool return_squared_distance=false, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Return the Euclidean distance transform. | |
| Array | distance_transform_approx (const Array &array, bool return_squared_distance=false) |
| Calculates an approximate distance transform of the input array. | |
| Array | distance_transform_manhattan (const Array &array, bool return_squared_distance=false) |
| Calculates the Manhattan distance transform of an array. | |
| Array | distance_transform_with_closest (const Array &array, Mat< glm::ivec2 > &closest, bool return_squared_distance=false) |
| Return the Euclidean distance transform. | |
| Array | erosion (const Array &array, int ir) |
| Apply an erosion algorithm to the input array using a square structure. | |
| void | flood_fill (Array &array, int i, int j, float fill_value=1.f, float background_value=0.f) |
| Apply a flood fill algorithm to the input array. | |
| Array | morphological_black_hat (const Array &array, int ir) |
| Apply a morphological black hat algorithm to the input array using a square structure. | |
| Array | morphological_gradient (const Array &array, int ir) |
| Apply a morphological gradient algorithm to the input array using a square structure. | |
| Array | morphological_laplacian (const Array &array, int ir) |
| Apply a morphological Laplacian operator to the input array using a square structure. | |
| Array | morphological_top_hat (const Array &array, int ir) |
| Apply a morphological top hat algorithm to the input array using a square structure. | |
| Array | opening (const Array &array, int ir) |
| Apply an opening algorithm to the input array using a square structure. | |
| Array | opening_by_reconstruction (const Array &array, int ir, float k_smooth_min=0.f) |
| Apply opening by reconstruction to the input array. | |
| Array | reconstruction_by_dilation (const Array &marker, const Array &mask, int ir, float k_smooth_min=0.f) |
| Perform morphological reconstruction by dilation. | |
| Array | reconstruction_by_erosion (const Array &marker, const Array &mask, int ir, float k_smooth_max=0.f) |
| Perform morphological reconstruction by erosion. | |
| Array | relative_distance_from_skeleton (const Array &array, int ir_search, bool zero_at_borders=true, int ir_erosion=1) |
| Computes the relative distance of each non-zero cell in a binary array from the skeleton and border. | |
| Array | relative_distance_from_skeleton (const Array &array, const Array &skeleton, int ir_search, int ir_erosion=1) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array | skeleton (const Array &array, const Array &skeleton, bool zero_at_borders=true) |
| Computes a skeletonized version of an array. | |
| Array | remove_endpoints (const Array &array, int iterations=1, float background_value=0.f) |
| Removes endpoint-like pixels from a binary/weighted array. | |
| Array | signed_curvature_from_distance (const Array &array, int prefilter_ir=0) |
| Computes the signed curvature of the distance transform. | |
| Array | signed_distance_transform (const Array &array, int prefilter_ir=0) |
| Computes a signed distance transform using curvature sign. | |
| Array | skeleton (const Array &array, bool zero_at_borders=true) |
| Computes the skeleton of a binary image using the Zhang-Suen skeletonization algorithm. | |
| Array | morphological_operators (const Array &array, int ir, hmap::MorphologyOperation operation, MinMaxKernel kernel_type=MinMaxKernel::DISK) |
| Apply a morphological operation to the input array using a square kernel. | |
| bool | init_openmp (int num_threads=-1) |
| void | log_openmp_info () |
| void | add_kernel (Array &array, const Array &kernel, int i, int j) |
| Add a kernel to a specified position in an array. | |
| void | add_kernel_maximum_smooth (Array &array, const Array &kernel, float k_smooth, int i, int j) |
| Adds a smoothed maximum value from a kernel to a specified position in a 2D array. | |
| Array | compare (const Array &a, const Array &b, float slice_x_pos, float slice_y_pos) |
| Combines two arrays by selecting values from a or b based on a slice position. | |
| Array | hstack (const Array &array1, const Array &array2) |
| Horizontally stack two arrays side by side. | |
| Array | inpainting_diffusion (const Array &array, const Array &mask, int iterations) |
| Perform diffusion-based inpainting to fill a specified region of an array. | |
| std::vector< float > | linspace (float start, float stop, int num, bool endpoint=true) |
| Generate a vector of evenly spaced numbers over a specified interval. | |
| std::vector< float > | linspace_jitted (float start, float stop, int num, float ratio, int seed, bool endpoint=true) |
| Generate a vector of jittered (noised) numbers over a specified interval. | |
| std::vector< float > | logspace (float start, float stop, int num, bool endpoint=true) |
| Generates a logarithmically spaced vector. | |
| template<typename Fn> | |
| void | fill_array_using_xy_function (Array &array, const UvRect &uv_rect, const Array *p_ctrl_param, const Array *p_noise_x, const Array *p_noise_y, const Array *p_stretching, Fn &&fct_xy) |
| Fill an array using a scalar function based on (x, y) coordinates. | |
| template<typename Fn> | |
| void | fill_array_using_xy_function (Array &array, const UvRect &uv_rect, const Array *p_ctrl_param, const Array *p_noise_x, const Array *p_noise_y, const Array *p_stretching, Fn &&fct_xy, int subsampling) |
| Fill an array using a scalar function based on (x, y) coordinates with subsampling. | |
| void | find_vertical_cut_path (const Array &error, std::vector< int > &path_i) |
| Find the vertical cut path with the minimum cost using dynamic programming. | |
| Array | generate_mask (glm::ivec2 shape, std::vector< int > cut_path_i, int ir) |
| Generate a smooth mask based on a cut path. | |
| Array | get_random_patch (const Array &array, glm::ivec2 patch_shape, std::mt19937 &gen, bool patch_flip=false, bool patch_rotate=false, bool patch_transpose=false, std::vector< Array * > *p_secondary_arrays=nullptr, std::vector< Array > *p_secondary_patches=nullptr) |
| Extracts a random sub-array (patch) from the input array, with optional transformations. | |
| std::vector< float > | random_vector (float min, float max, int num, int seed) |
| Generate a vector filled with random values within a specified range. | |
| void | rescale_vector (std::vector< float > &vec, float vmin, float vmax) |
| Rescales the values of a vector to a specified range. | |
| std::vector< float > | rescaled_vector (const std::vector< float > &vec, float vmin, float vmax) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | swap (Array &a, Array &b) |
| Swaps the contents of two Array objects. | |
| Array | vstack (const Array &array1, const Array &array2) |
| Vertically stack two arrays. | |
| template<typename Fn> | |
| void | apply_with_mask (Array &array, const Array *p_mask, Fn &&fn) |
| Applies a transformation function with optional masked blending. | |
| template<typename Fn> | |
| Array | transform_with_mask (const Array &array, const Array *p_mask, Fn &&fn) |
| Applies a transformation function with optional masked blending. | |
| Array | dendry (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, Array &control_function, float eps=0.05, int resolution=1, float displacement=0.075, int primitives_resolution_steps=3, float slope_power=2.f, float noise_amplitude_proportion=0.01, bool add_control_function=true, float control_function_overlap=0.5f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), int subsampling=1) |
| Dendry is a locally computable procedural function that generates branching patterns at various scales (see [Gaillard2019]). | |
| Array | dendry (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, const std::function< float(float, float, float)> &noise_function, float noise_function_offset=0.f, float noise_function_scaling=1.f, float eps=0.05, int resolution=1, float displacement=0.075, int primitives_resolution_steps=3, float slope_power=2.f, float noise_amplitude_proportion=0.01, bool add_control_function=true, float control_function_overlap=0.5f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Array | diffusion_limited_aggregation (glm::ivec2 shape, float scale, std::uint32_t seed, float seeding_radius=0.4f, float seeding_outer_radius_ratio=0.2f, float slope=8.f, float noise_ratio=0.2f) |
| Generates a diffusion-limited aggregation (DLA) pattern. | |
| Array | diffusion_limited_aggregation_trimesh (glm::ivec2 shape, std::uint32_t seed, size_t control_points_count=5000, glm::vec2 seed_position={0.5f, 0.5f}, float ratio=0.98f, float stop_proba=1.f, float slope=16.f, InterpolationMethod2D interpolation_method=InterpolationMethod2D::ITP2D_DELAUNAY_GRADIENT, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | gabor_noise (glm::ivec2 shape, float kw, float angle, int width, float density, std::uint32_t seed) |
| Return a sparse Gabor noise. | |
| Array | noise (NoiseType noise_type, glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f) |
| Return an array filled with coherence noise. | |
| Array | noise_fbm (NoiseType noise_type, glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, 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 UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f, float stretch_decay=0.f) |
| Return an array filled with coherence fbm noise. | |
| Array | noise_iq (NoiseType noise_type, glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, float gradient_scale=0.05f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f, float stretch_decay=0.f) |
| Return an array filled with coherence fbm noise. | |
| Array | noise_jordan (NoiseType noise_type, glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, float warp0=0.4f, float damp0=1.f, float warp_scale=0.4f, float damp_scale=1.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f, float stretch_decay=0.f) |
| Return an array filled with coherence fbm noise. | |
| Array | noise_parberry (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, float mu=1.02f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f, float stretch_decay=0.f) |
| Return an array filled with coherent fbm Parberry variant of Perlin noise. | |
| Array | noise_pingpong (NoiseType noise_type, glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, 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 UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f, float stretch_decay=0.f) |
| Return an array filled with coherence fbm pingpong noise. | |
| Array | noise_ridged (NoiseType noise_type, glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, float k_smoothing=0.1f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f, float stretch_decay=0.f) |
| Return an array filled with coherence fbm ridged noise. | |
| Array | noise_slope (NoiseType noise_type, glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, float gradient_scale=0.5f, float slope_power=2.f, float octave_blend=0.5f, float bias_angle=0.f, float bias_strength=0.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f, float stretch_decay=0.f) |
| Return an array filled with slope-weighted coherence fbm noise. | |
| Array | noise_swiss (NoiseType noise_type, glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, float warp_scale=0.1f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), float angle=0.f, float stretch=1.f, float stretch_decay=0.f) |
| Return an array filled with coherence fbm swiss noise. | |
| Array | worley_double (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float ratio=0.5f, float k=0.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Return an array filled with the maximum of two Worley (cellular) noises. | |
| Array | get_primitive_base (const PrimitiveType &primitive_type, const glm::ivec2 &shape, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Generates a primitive shape as a 2D array. | |
| Array | band (glm::ivec2 shape, float angle, float length=0.5f, float width=0.1f, RadialProfile profile=RadialProfile::RP_SMOOTHSTEP, float profile_param=0.f, const Array *p_noise_r=nullptr, const Array *p_noise_offset=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Generate a bounded band (capsule) mask. | |
| Array | biquad_pulse (glm::ivec2 shape, float gain=1.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return a 'biquadratic pulse'. | |
| Array | biquad_pulse_x (glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit()) |
| Array | biquad_pulse_y (glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit()) |
| Array | bump (glm::ivec2 shape, float gain=1.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return a bump. | |
| Array | bump_lorentzian (glm::ivec2 shape, float shape_factor=0.5f, float radius=0.5f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Generates a 2D Lorentzian bump pattern. | |
| Array | checkerboard (glm::ivec2 shape, glm::vec2 kw, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Return a checkerboard heightmap. | |
| Array | cone (glm::ivec2 shape, float slope, float apex_elevation=1.f, bool smooth_profile=false, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Generates a synthetic conical mountain heightmap. | |
| Array | cone_complex (glm::ivec2 shape, float alpha, float radius=0.5f, bool smooth_profile=true, float valley_amp=0.2f, int valley_nb=5, float valley_decay_ratio=0.5f, float valley_angle0=15.f, const ErosionProfile &erosion_profile=ErosionProfile::EP_TRIANGLE_GRENIER, float erosion_delta=0.01f, float radial_waviness_amp=0.05f, float radial_waviness_kw=2.f, float bias_angle=30.f, float bias_amp=0.75f, float bias_exponent=1.f, glm::vec2 center={0.5f, 0.5f}, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Generates a complex conical heightfield with valleys, directional bias, and radial waviness. | |
| Array | cone_sigmoid (glm::ivec2 shape, float alpha, float radius=0.5f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Generates a smooth conical heightmap using a sigmoid-based profile. | |
| Array | constant (glm::ivec2 shape, float value=0.f) |
| Return a constant value array. | |
| Array | cubic_pulse (glm::ivec2 shape, const Array *p_noise_x, const Array *p_noise_y, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Generates a cubic pulse array. | |
| Array | disk (glm::ivec2 shape, float radius, float slope=1.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Generates a disk-shaped heightmap with optional modifications. | |
| Array | gaussian_pulse (glm::ivec2 shape, float sigma, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return a gaussian_decay pulse kernel. | |
| Array | multisteps (glm::ivec2 shape, float angle, float r=1.2f, int nsteps=8, float elevation_exponent=0.7f, float shape_gain=4.f, float scale=0.5f, float outer_slope=0.1f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const glm::vec2 ¢er={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit()) |
| Generate a multi-step height profile along a rotated axis. | |
| Array | paraboloid (glm::ivec2 shape, float angle, float a, float b, float v0=0.f, bool reverse_x=false, bool reverse_y=false, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return a paraboloid. | |
| Array | polar_shape (glm::ivec2 shape, float rmin=0.1f, float rmax=0.3f, float aspect_ratio=1.f, float smoothing_width=0.1f, bool square_base=false, float angle=15.f, float sector_angle=90.f, float vmin=0.5f, float kt_value=0.f, float kr_border=0.f, float kr_border_ratio=0.1f, const Array *p_noise_r=nullptr, const Array *p_noise_theta=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Generate a polar-based shape mask with optional angular and radial perturbations. | |
| Array | quad_surface (glm::ivec2 shape, float c00=0.f, float c10=0.f, float c01=0.f, float c11=0.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Generates a surface defined by the four corner values of the domain. | |
| Array | rectangle (glm::ivec2 shape, float rx, float ry, float angle, float slope=1.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Generates a rectangle-shaped heightmap with optional modifications. | |
| Array | slope (glm::ivec2 shape, float angle, float slope, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return an array corresponding to a slope with a given overall. | |
| Array | smooth_cosine (glm::ivec2 shape, const Array *p_noise_x, const Array *p_noise_y, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Generates a smooth cosine array. | |
| Array | step (glm::ivec2 shape, float angle, float slope, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return a step function (Heaviside with an optional talus slope at the transition). | |
| void | swirl (Array &dx, Array &dy, float amplitude=1.f, float exponent=1.f, const Array *p_noise=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Generate displacements dx and dy to apply a swirl effect to another primitve. | |
| Array | wave_dune (glm::ivec2 shape, float kw, float angle, float xtop, float xbottom, float phase_shift=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return a dune shape wave. | |
| Array | wave_sine (glm::ivec2 shape, float kw, float angle, float phase_shift=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return a sine wave. | |
| Array | wave_square (glm::ivec2 shape, float kw, float angle, float phase_shift=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return a square wave. | |
| Array | wave_triangular (glm::ivec2 shape, float kw, float angle, float slant_ratio, float phase_shift=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Return a triangular wave. | |
| 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}, const UvRect &uv_rect=UvRect::unit()) |
| Return a caldera-shaped heightmap. | |
| Array | caldera (glm::ivec2 shape, float radius, float sigma_inner, float sigma_outer, float z_bottom, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Array | circus (glm::ivec2 shape, float radius=0.4f, float angle=0.f, float exit_width=0.35f, float exit_depth=0.f, float center_depth=0.1f, float ridge_height=1.f, float ridge_width=0.15f, float outer_falloff=2.f, const Array *p_noise_r=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit(), Array *p_mask=nullptr) |
| Generate a procedural circus (glacial cirque / amphitheatre basin) heightmap. | |
| 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, const UvRect &uv_rect=UvRect::unit(), Array *p_crater_mask=nullptr, Array *p_inner_crater_mask=nullptr) |
| Generate a procedural impact crater heightmap. | |
| Array | crater_field (glm::ivec2 shape, const std::vector< glm::vec2 > ¢ers, const std::vector< float > &radii, float angle=30.f, float inner_depth=0.5f, float inner_exp=3.f, float lip_height=0.1f, float lip_extent=0.25f, float lip_exp=2.f, float asym_ratio=0.8f, float central_peak_height=0.05f, 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, const UvRect &uv_rect=UvRect::unit(), Array *p_crater_mask=nullptr, Array *p_inner_crater_mask=nullptr, bool scale_elevation_with_radius=true) |
| Generate a field of procedural impact craters from explicit centers and radii. | |
| Array | crater_field (glm::ivec2 shape, std::uint32_t seed, int n_craters, float r_min=0.02f, float r_max=0.2f, float angle=30.f, float inner_depth=0.5f, float inner_exp=3.f, float lip_height=0.1f, float lip_extent=0.25f, float lip_exp=2.f, float asym_ratio=0.8f, float central_peak_height=0.05f, 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, const UvRect &uv_rect=UvRect::unit(), Array *p_crater_mask=nullptr, Array *p_inner_crater_mask=nullptr, bool scale_elevation_with_radius=true) |
| Generate a field of randomly distributed procedural impact craters. | |
| 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 ¢er={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit()) |
| Generates a 2D island mask by perturbing a radial boundary with noise. | |
| 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, const UvRect &uv_rect=UvRect::unit()) |
| Generates a land mask of an island chain scattered along a path. | |
| 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}, const UvRect &uv_rect=UvRect::unit(), Array *p_rift_mask=nullptr, Array *p_bottom_mask=nullptr) |
| Generate a rift-shaped primitive. | |
| Array | valley_head (glm::ivec2 shape, float angle=0.f, float min_depth=0.f, float max_depth=0.2f, float min_width=0.02f, float max_width=0.15f, float depth_length=0.5f, float width_length=0.5f, float development_power=2.f, float profile_power=1.3f, const Array *p_noise_offset=nullptr, const Array *p_noise_r=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit(), Array *p_mask=nullptr) |
| Generate a procedural natural valley head / valley incision deformation heightmap. | |
| Array | white (glm::ivec2 shape, float a, float b, std::uint32_t seed) |
| Return an array filled with white noise. | |
| Array | white_density_map (const Array &density_map, std::uint32_t seed) |
| Return an array filled 1 with a probability based on a density map. | |
| Array | white_sparse (glm::ivec2 shape, float a, float b, float density, std::uint32_t seed) |
| Return an array sparsely filled with white noise. | |
| Array | white_sparse_binary (glm::ivec2 shape, float density, std::uint32_t seed) |
| Return an array sparsely filled with random 0 and 1. | |
| float | fast_hash32_to_unit_float (unsigned int seed, size_t k) |
| Generates a fast deterministic uniform float in [0,1) using a 32-bit hash. | |
| float | hash01 (uint32_t a, uint32_t b) |
| Computes a pseudo-random float in [0, 1) by hashing two 32-bit integers. | |
| uint32_t | hash32 (uint32_t x) |
| Integer hash function (Murmur3 / finalize style 32-bit mixer). | |
| uint64_t | splitmix64 (uint64_t x) |
| Computes a deterministic 64-bit hash using the SplitMix64 algorithm. | |
| float | splitmix64_to_unit_float (unsigned int seed, size_t k) |
| Generates a deterministic uniform float in [0,1) from a seed and sample index. | |
| float | uniform01 (uint64_t h) |
| Converts a 64-bit hash value into a deterministic uniform float in [0, 1). | |
| float | vnoise (float x, float y, uint32_t seed=0) |
| Computes 2D value noise in [-1, 1] using a hash-based lattice. | |
| void | chop (Array &array, float vmin) |
| Set to zero any value lower than vmin. | |
| void | chop_max_smooth (Array &array, float vmax) |
| Set to zero any value lower than vmax and apply a linear decrease slope between vmax / 2 and vmax. | |
| void | clamp (Array &array, float vmin=0.f, float vmax=1.f) |
| Clamp array elements to a target range. | |
| void | clamp (Array &array, float vmax, ClampMode mode) |
| Clamps the values of an array according to the specified mode. | |
| void | clamp_min (Array &array, float vmin) |
| Clamp array values lower than a given bound. | |
| void | clamp_min (Array &array, const Array &vmin) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | clamp_min_smooth (Array &array, float vmin, float k=0.2f) |
| Clamp array values lower than a given bound with a smooth transition. | |
| void | clamp_min_smooth (Array &array, const Array &vmin, float k=0.2f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| float | clamp_min_smooth (float x, float vmin, float k=0.2f) |
| Clamp a single value lower than a given bound with a smooth transition. | |
| void | clamp_max (Array &array, float vmax) |
| Clamp array values larger than a given bound. | |
| void | clamp_max (Array &array, const Array &vmax) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | clamp_max_smooth (Array &array, float vmax, float k=0.2f) |
| Clamp array values larger than a given bound with a smooth transition. | |
| void | clamp_max_smooth (Array &array, const Array &vmax, float k=0.2f) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | clamp_oblique_plane (Array &array, float vmax, float angle, float slope, bool use_max_operator=true, float k=0.f, glm::vec2 center={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit()) |
| Clamps an array against an oblique plane. | |
| void | clamp_smooth (Array &array, float vmin, float vmax, float k=0.2f) |
| Clamp array values within a given interval with a smooth transition. | |
| Array | maximum (const Array &array1, const Array &array2) |
| Return the element-wise maximum of two arrays. | |
| Array | maximum (const Array &array1, const float value) |
| Return the element-wise maximum of an array and a scalar value. | |
| Array | maximum_smooth (const Array &array1, const Array &array2, float k=0.2) |
| Return the polynomial cubic smooth element-wise maximum of two arrays. | |
| float | maximum_smooth (const float a, const float b, float k=0.2) |
| Return the polynomial cubic smooth maximum of two scalar values. | |
| Array | minimum (const Array &array1, const Array &array2) |
| Return the element-wise minimum of two arrays. | |
| Array | minimum (const Array &array1, const float value) |
| Return the element-wise minimum of an array and a scalar value. | |
| Array | minimum_smooth (const Array &array1, const Array &array2, float k=0.2) |
| Return the polynomial cubic smooth element-wise minimum of two arrays. | |
| float | minimum_smooth (const float a, const float b, float k) |
| Return the polynomial cubic smooth minimum of two scalar values. | |
| void | remap (Array &array, float vmin, float vmax, float from_min, float from_max) |
| Remap array elements from a starting range to a target range. | |
| void | remap (Array &array, float vmin=0, float vmax=1, ICommunicator &comm=SingleArrayComm::instance()) |
| Remap array elements from a starting range to a target range (default range). | |
| void | rescale (Array &array, float scaling, float vref=0.f) |
| Remap array elements from a starting range to a target range. | |
| void | normalize_and_clip (Array &array, float multiplier=2.5f, bool smooth_transition=true, bool range_01=false, ICommunicator &comm=SingleArrayComm::instance()) |
| Normalize an array around its mean and clip values. | |
| ScatterField | merge_scatter_fields (const std::vector< ScatterField > &fields, bool merge_by_class=true) |
| Merges multiple ScatterField instances into a single instance. | |
| ScatterField | merge_scatter_fields (const std::vector< ScatterField > &fields, const std::vector< BBox2D > &bboxs, bool merge_by_class=true) |
| Merges multiple ScatterField instances with associated bounding boxes into a single instance, resolving overlaps by keeping items from earlier fields in the input order. | |
| Array | scatter_field_to_heightmap (const ScatterField &field, glm::ivec2 shape, ScatterShape shape_type=SCATTER_SHAPE_DISK, float height_radius_ratio=1.0f, std::optional< uint32_t > class_id=std::nullopt, Array *p_rock_map=nullptr, uint32_t seed=0, const UvRect &uv_rect=UvRect::unit()) |
| Converts a ScatterField into a heightmap by representing each scattered object as a local elevation increase on GPU. | |
| ScatterField | seed_scatter_clusters (size_t class_count, size_t item_count, const Array &density, const Array &exclusion, float cluster_spread=0.05f, size_t points_per_cluster=8, const ScatterSeedingOptions &options={}) |
| Generates a clustered scatter distribution using inverse transform sampling for cluster centers and local cluster regions. | |
| ScatterField | seed_scatter_kmeans (size_t class_count, size_t item_count, const Array &density, const Array &exclusion, float cluster_randomness=0.0f, size_t k_neighbors=4, const ScatterSeedingOptions &options={}) |
| Generates a multi-class scatter distribution using 2D inverse transform sampling for positions and PointSampler k-means clustering to tag classes. | |
| Array | sdf_2d_polyline (const Path &path, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, bool use_bvh=true) |
| Computes the signed distance field (SDF) of a 2D polyline. | |
| Array | sdf_2d_polyline_brute_force (const Path &path, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | sdf_2d_polyline_bvh (const Path &path, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | sdf_2d_polyline_bezier (const Path &path, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, bool use_bvh=true) |
| See hmap::sdf_2d_polyline, with a Bezier approximation of the path. | |
| Array | sdf_2d_polyline_bezier_brute_force (const Path &path, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | sdf_2d_polyline_bezier_bvh (const Path &path, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | sdf_2d_graph (const Graph &graph, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, bool use_bvh=true) |
| Computes the 2D unsigned distance field to a graph network. | |
| Array | sdf_2d_graph_brute_force (const Graph &graph, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | sdf_2d_graph_bvh (const Graph &graph, glm::ivec2 shape, const UvRect &uv_rect=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr) |
| Array | perturb_mask_contour (const Array &mask, const Array &noise, float max_displacement, int ir=1) |
| Perturb the contour of a binary mask using a displacement field, while trying to preserve a single connected component without holes. | |
| Array | scan_mask (const Array &array, float contrast=0.5f, float brightness=0.5f) |
| Mask adjustement using a 'scanning' method. | |
| Array | select_angle (const Array &array, float angle, float sigma) |
| Return angle selection for a given angle and a tolerance half-width on this value. | |
| Array | select_blob_log (const Array &array, int ir, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance()) |
| Return blob detection using the Laplacian of Gaussian (LoG) approach. | |
| Array | select_cavities (const Array &array, int ir, bool concave=true, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance()) |
| Return holes or bumps detection based on the mean curvature of the heightmap. | |
| Array | select_eq (const Array &array, float value) |
| Return an array with elements equal to 1 where input elements are equal to value. | |
| Array | select_gradient_angle (const Array &array, float angle) |
| Return an array weighted by the gap between the gradient angle and a given angle. | |
| Array | select_gradient_binary (const Array &array, float talus_center) |
| Return an array filled with 1 where the gradient is larger than a given value and 0 elsewhere. | |
| Array | select_gradient_exp (const Array &array, float talus_center, float talus_sigma) |
| Return an array weighted (exponantial decay) by the gradient norm of the input array. | |
| Array | select_gradient_inv (const Array &array, float talus_center, float talus_sigma) |
| Return an array weighted (square inverse) by the gradient norm of the input array. | |
| Array | select_gt (const Array &array, float value) |
| Return an array with elements equal to 1 where input elements are larger than value. | |
| Array | select_interval (const Array &array, float value1, float value2) |
| Return an array with elements equal to 1 where input elements are within the bounds provided. | |
| Array | select_inward_outward_slope (const Array &array, glm::vec2 center={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit()) |
| Return an array with positive values if the slope is pointing to the center (slope is inward), and negative values otherwise (slope is outward). | |
| Array | select_lt (const Array &array, float value) |
| Return an array with elements equal to 1 where input elements are smaller than value. | |
| Array | select_midrange (const Array &array, float gain, float vmin, float vmax) |
| Selects the midrange values of the input array within a specified range. | |
| Array | select_midrange (const Array &array, float gain) |
| Selects and scales the midrange values of the input array. | |
| void | select_multiband3 (const Array &array, Array &band_low, Array &band_mid, Array &band_high, float ratio1, float ratio2, float overlap, float vmin, float vmax) |
| Splits the input array into three bands (low, mid, and high) based on given ratios and overlap. | |
| void | select_multiband3 (const Array &array, Array &band_low, Array &band_mid, Array &band_high, float ratio1, float ratio2, float overlap) |
| Splits the input array into three bands (low, mid, and high) based on given ratios and overlap. | |
| Array | select_pulse (const Array &array, float value, float sigma) |
| Return an array filled with non-zero values where the input is in the interval [value - sigma, value + sigma]. Output array values have a cubic pulse distribution within this interval. | |
| Array | select_range (const Array &array, float vmin, float vmax, float width) |
| Return a selection mask for a value range [vmin, vmax] with smooth transitions of specified width at both ends. | |
| Array | select_rivers (const Array &array, float talus_ref, float clipping_ratio) |
| Return an array filled with a criterion based on the occurence of a river bed. | |
| Array | select_transitions (const Array &array1, const Array &array2, const Array &array_blend) |
| Return an array filled with 1 at the blending transition between two arrays, and 0 elsewhere. | |
| Array | select_valley (const Array &z, int ir, bool ridge_select=false, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance()) |
| Array | smooth_mask_preserve_frontier (const Array &mask, float feather_width, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Smooths a binary mask with an inward falloff while preserving its 0-boundary. | |
| Array | hillshade (const Array &z, float azimuth, float zenith, float talus_ref=1.f) |
| Compute the shaded relief map (hillshading) from a heightmap. | |
| Array | shadow_grid (const Array &z, float shadow_talus) |
| Compute the shadow intensity using a grid-based technique. | |
| Array | shadow_heightmap (const Array &z, float azimuth=180.f, float zenith=45.f, float distance=0.2f) |
| Compute crude shadows from a heightmap. | |
| Array | topographic_shading (const Array &z, float azimuth, float zenith, float talus_ref=1.f) |
| Compute the topographic shadow intensity in the range [-1, 1]. | |
| Path | dijkstra (const Path &path, const Array &array, const UvRect &uv_rect, float elevation_ratio=0.f, float distance_exponent=0.5f, float upward_penalization=0.1f, Array *p_mask_nogo=nullptr) |
| Divide the path by adding points based on the lowest elevation difference between each pair of edge endpoints. | |
| Path | find_cut_path_dijkstra (const Array &z, DomainBoundary start, DomainBoundary end, float dijk_elevation_ratio=0.9f, float dijk_distance_exponent=2.f, float dijk_upward_penalization=100.f, std::uint32_t seed=0, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true, bool favor_domain_center=false) |
| Find a Dijkstra-based cut path between two domain boundaries. | |
| Path | find_cut_path_dijkstra (const Array &z, DomainBoundary start, DomainBoundary end, std::uint32_t seed, size_t control_points_count=2048, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true, bool favor_domain_center=false, const UvTile ®ion=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance()) |
| Generate a cut path across a heightmap using a random triangular mesh and Dijkstra shortest path search (tileable). | |
| Path | find_cut_path_midpoint (const Array &z, DomainBoundary start, DomainBoundary end, std::uint32_t seed, float offset_ratio=0.2f, int steps=16, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true, const UvTile ®ion=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance()) |
| Generate a stochastic cut path using midpoint displacement. | |
| Path | find_cut_path_multiscale (const Array &z, DomainBoundary start, DomainBoundary end, int n_levels=3, int corridor_radius=4, float corridor_decay=1.f, float dijk_elevation_ratio=0.9f, float dijk_distance_exponent=2.f, float dijk_upward_penalization=100.f, std::uint32_t seed=0, bool favor_boundary_center=true, bool favor_lower_elevation=true, bool favor_sinks=true, bool use_astar=false, bool smooth_path=false) |
| Find a fast coarse-to-fine multiscale cut path between two domain boundaries. | |
| void | find_path_dijkstra (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, std::vector< int > &i_path, std::vector< int > &j_path, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, const Array *p_node_weights=nullptr) |
| Finds the path with the lowest elevation and elevation difference between two points in a 2D array using Dijkstra's algorithm. | |
| void | find_path_dijkstra (const Array &z, glm::ivec2 ij_start, std::vector< glm::ivec2 > ij_end_list, std::vector< std::vector< int > > &i_path_list, std::vector< std::vector< int > > &j_path_list, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, const Array *p_node_weights=nullptr) |
| Path | find_path_dijkstra (const Array &z, glm::vec2 start, glm::vec2 end, std::uint32_t seed, size_t control_points_count=2048, bool favor_domain_center=false, const UvTile ®ion=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance()) |
| Generate a path between two points across a heightmap using a random triangular mesh and Dijkstra shortest path search (tileable). | |
| std::vector< glm::ivec2 > | find_path_dijkstra (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, const Array *p_node_weights=nullptr) |
| Overload of find_path_dijkstra returning a vector of grid indices. | |
| Path | find_path_dijkstra (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, const UvRect &uv_rect, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, const Array *p_node_weights=nullptr) |
| Overload of find_path_dijkstra returning a Path mapped to a bounding box with point values holding sampled terrain elevations. | |
| std::vector< glm::ivec2 > | find_path_midpoint (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, float offset_ratio=0.2f, int max_it=0, int steps=16) |
| Compute a path between two points using iterative midpoint refinement. | |
| void | find_path_midpoint (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, std::vector< int > &i_path, std::vector< int > &j_path, float offset_ratio=0.2f, int max_it=0, int steps=16) |
| Overload of find_path_midpoint returning path indices in i and j vectors. | |
| Path | find_path_midpoint (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, const UvRect &uv_rect, float offset_ratio=0.2f, int max_it=0, int steps=16) |
| Overload of find_path_midpoint returning a Path mapped to a bounding box with point values holding sampled terrain elevations. | |
| void | find_path_multiscale (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, std::vector< int > &i_path, std::vector< int > &j_path, int n_levels=3, int corridor_radius=4, float corridor_decay=1.f, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, bool use_astar=false, bool smooth_path=false) |
| Finds a shortest path on a 2D grid using a fast coarse-to-fine multiscale approach. | |
| std::vector< glm::ivec2 > | find_path_multiscale (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, int n_levels=3, int corridor_radius=4, float corridor_decay=1.f, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, bool use_astar=false, bool smooth_path=false) |
| Overload of find_path_multiscale returning a vector of grid indices. | |
| Path | find_path_multiscale (const Array &z, glm::ivec2 ij_start, glm::ivec2 ij_end, const UvRect &uv_rect, int n_levels=3, int corridor_radius=4, float corridor_decay=1.f, float elevation_ratio=0.1f, float distance_exponent=2.f, float upward_penalization=0.1f, const Array *p_mask_nogo=nullptr, bool use_astar=false, bool smooth_path=false) |
| Overload of find_path_multiscale returning a Path object mapped to a bounding box, with point values containing the elevation sampled from the heightmap. | |
| float | index_to_uv (int i, int n, GridRegistration reg=GridRegistration::CellCenter) |
| Maps a discrete index i in [0, n) to a UV coordinate in [0, 1]. | |
| float | uv_to_continuous_index (float u, int n, GridRegistration reg=GridRegistration::CellCenter) |
| Maps a UV coordinate in [0, 1] to a continuous index in [0, n - 1]. | |
| UvRect | tile_uv_rect (const glm::ivec2 &global_offset, const glm::ivec2 &tile_shape_with_halo, const glm::ivec2 &global_shape, const UvRect &domain_uv=UvRect::unit()) |
| Computes the exact UV rectangle of a tile (including halo) within a domain of global_shape. | |
| float | autocorr_length_scale (const Array &array, float max_lag_fraction=0.4f) |
| Estimate the isotropic dominant length scale of a 2D heightmap. | |
| glm::vec2 | autocorr_length_scale_axial (const Array &array, float max_lag_fraction=0.4f) |
| Estimate axis-aligned dominant length scales of a 2D heightmap. | |
| Array | detrend_reg (const Array &array) |
| Apply linear regression for detrending of a 2D array. | |
| void | normalize (Array &array, NormalizationMethod method) |
| In-place normalization of an array. | |
| Array | normalized (const Array &array, NormalizationMethod method) |
| Returns a normalized copy of an array. | |
| float | variance (const Array &array, float *p_mean=nullptr) |
| Compute the population variance of a 2D array. | |
| Array | loose_symmetry (const Array &array, SymmetryType symmetry_type=SymmetryType::SYMMETRY_LEFT_TO_RIGHT, float strength=1.f, int factor=4, int patch_size=16, int analysis_stride=2, int synthesis_stride=8, int sparsity=1, bool flatten_center=false, float flatten_radius=0.05f) |
| Synthesize a heightmap with natural, approximate symmetry using exemplar-based super-resolution. | |
| Array | non_parametric_sampling (const Array &array, glm::ivec2 patch_shape, std::uint32_t seed, float error_threshold=0.1f) |
| Synthesize a new heightmap based on an input array using a non-parametric sampling method. | |
| Array | quilting (const std::vector< const Array * > &p_arrays, glm::ivec2 patch_base_shape, glm::ivec2 tiling, float overlap, std::uint32_t seed, std::vector< Array * > secondary_arrays={}, bool patch_flip=true, bool patch_rotate=true, bool patch_transpose=true, float filter_width_ratio=0.25f) |
| Synthesize a new heightmap by stitching together small patches from input heightmaps. | |
| Array | quilting_blend (const std::vector< const Array * > &p_arrays, glm::ivec2 patch_base_shape, float overlap, std::uint32_t seed, bool patch_flip=true, bool patch_rotate=true, bool patch_transpose=true, float filter_width_ratio=0.25f) |
| Synthesize a new heightmap by stitching together small patches from a list of input heightmaps. | |
| Array | quilting_expand (const Array &array, float expansion_ratio, glm::ivec2 patch_base_shape, float overlap, std::uint32_t seed, std::vector< Array * > secondary_arrays={}, bool keep_input_shape=false, bool patch_flip=true, bool patch_rotate=true, bool patch_transpose=true, float filter_width_ratio=0.25f) |
| Synthesize a new heightmap by expanding the input heightmap and stitching patches. | |
| Array | quilting_shuffle (const Array &array, glm::ivec2 patch_base_shape, float overlap, std::uint32_t seed, std::vector< Array * > secondary_arrays={}, bool patch_flip=true, bool patch_rotate=true, bool patch_transpose=true, float filter_width_ratio=0.25f) |
| Synthesize a new heightmap by reshuffling patches of the input heightmap. | |
| Array | terrain_super_resolution (const Array &array, const Array &exemplar, int factor, int patch_size=16, int analysis_stride=8, int synthesis_stride=8, int sparsity=1) |
| Synthesize a high-resolution heightmap from a low-resolution input using an exemplar-based sparse patch representation (terrain amplification). | |
| std::vector< float > | cubic_pulse (const TerrainTriMesh &mesh) |
| Compute a cubic pulse value for each mesh vertex. | |
| TerrainTriMesh | generate_terrain_tri_mesh_from_heightmap (const Array &z, float max_error, int max_triangles=0, int max_points=0) |
| Generate a terrain mesh from a heightmap. | |
| TerrainTriMesh | generate_terrain_tri_mesh_from_heightmap_random (const Array &z, int control_points_count, std::uint32_t seed, const UvTile ®ion=UvTile::unit(), ICommunicator *p_comm=nullptr) |
| Generate a random terrain mesh from a heightmap tile. | |
| TerrainAlignment | compute_terrain_alignment (const Array &lower, const CoordFrame &frame_lower, const Array &upper, const CoordFrame &frame_upper, TerrainAlignMode mode, float huber_delta=0.1f, int max_iterations=10) |
Compute alignment parameters to fit upper to lower over their common valid area. | |
| TerrainAlignment | compute_terrain_alignment (const VirtualArray &lower, const CoordFrame &frame_lower, const VirtualArray &upper, const CoordFrame &frame_upper, TerrainAlignMode mode, float huber_delta=0.1f, int max_iterations=10, int coarse_size=128) |
| Compute alignment parameters for VirtualArray inputs using a coarse Array representation. | |
| void | apply_terrain_alignment (Array &upper, const TerrainAlignment &alignment) |
| Apply precomputed alignment parameters to an Array in-place. | |
| void | apply_terrain_alignment (VirtualArray &upper, const TerrainAlignment &alignment, const ComputeMode &cm=ComputeMode{}) |
| Apply precomputed alignment parameters to a VirtualArray in-place. | |
| void | align_terrains (const Array &lower, const CoordFrame &frame_lower, Array &upper, const CoordFrame &frame_upper, TerrainAlignMode mode, float huber_delta=0.1f, int max_iterations=10) |
Align upper to lower in-place over their common valid area. | |
| void | align_terrains (const VirtualArray &lower, const CoordFrame &frame_lower, VirtualArray &upper, const CoordFrame &frame_upper, TerrainAlignMode mode, float huber_delta=0.1f, int max_iterations=10, int coarse_size=128, const ComputeMode &cm=ComputeMode{}) |
Align upper VirtualArray to lower VirtualArray in-place. | |
| void | flip_lr (Texture &texture) |
| Flip the texture horizontally (left/right). | |
| void | flip_ud (Texture &texture) |
| Flip the texture vertically (up/down). | |
| void | rot180 (Texture &texture) |
| Rotate the texture by 180 degrees. | |
| void | rot270 (Texture &texture) |
| Rotate the texture by 270 degrees counterclockwise. | |
| void | rot90 (Texture &texture) |
| Rotate the texture by 90 degrees counterclockwise. | |
| void | scale_uv (Texture &texture, glm::vec2 uv_scale) |
| Scale the texture in UV space with wrapping boundary. | |
| Texture | transpose (const Texture &texture) |
| Return the transposed texture. | |
| void | flip_lr (Array &array) |
| Flip the array horizontally (left/right). | |
| void | flip_ud (Array &array) |
| Flip the array vertically (up/down). | |
| void | radial_displacement_to_xy (const Array &dr, Array &dx, Array &dy, float smoothing=1.f, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit()) |
| Interpret the input array dr as a radial displacement and convert it to a pair of displacements dx and dy in cartesian coordinates. | |
| void | rot180 (Array &array) |
| Rotate the array by 180 degrees. | |
| void | rot270 (Array &array) |
| Rotate the array by 270 degrees. | |
| void | rot90 (Array &array) |
| Rotate the array by 90 degrees. | |
| void | rotate (Array &array, float angle, bool zoom_in=true, bool zero_padding=false) |
| Rotate the array by a specified angle. | |
| void | rotate_displacement (const Array &delta, float angle, Array &dx, Array &dy) |
| Rotates a scalar displacement field into directional X and Y components. | |
| void | scale_uv (Array &array, glm::vec2 uv_scale) |
| Scale the array in UV space with wrapping boundary. | |
| Array | symmetrize (const Array &array, SymmetryType symmetry_type=SymmetryType::SYMMETRY_LEFT_TO_RIGHT, bool flatten_center=false, float flatten_radius=0.05f) |
| Enforces geometric symmetry on an array. | |
| Array | translate (const Array &array, float dx, float dy, bool periodic=false, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Translates a 2D array by a specified amount along the x and y axes. | |
| Array | transpose (const Array &array) |
| Return the transposed array. | |
| Array | zoom (const Array &array, float zoom_factor, bool periodic=false, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit()) |
| Applies a zoom effect to a 2D array with an adjustable center. | |
| void | warp (Array &array, const Array *p_dx, const Array *p_dy) |
| Apply a warping effect to the array. | |
| void | warp_directional (Array &array, float angle, float amount=0.02f, int ir=4, bool reverse=false) |
| Apply a warping effect following the downward local gradient direction (deflate/inflate effect). | |
| void | warp_directional (Array &array, float angle, const Array *p_mask, float amount=0.02f, int ir=4, bool reverse=false) |
| Apply a warping effect following the downward local gradient direction (deflate/inflate effect) with a mask. | |
| void | warp_downslope (Array &array, float amount=0.02f, int ir=4, bool reverse=false) |
| Apply a warping effect following the downward local gradient direction (deflate/inflate effect). | |
| void | warp_downslope (Array &array, const Array *p_mask, float amount=0.02f, int ir=4, bool reverse=false) |
| Apply a warping effect following the downward local gradient direction (deflate/inflate effect) with a mask. | |
| std::vector< size_t > | argsort (const std::vector< float > &v) |
| Returns the indices that would sort the vector. | |
| float | compute_median (std::vector< float > values) |
| Computes the median value of a set of floats. | |
| std::vector< size_t > | find_sign_changes (const std::vector< float > &data) |
| Returns indices where a sign change occurs in the input vector. | |
| std::vector< float > | generate_random_vector (size_t size, float min_value, float max_value, uint32_t seed) |
| Generate a vector of random floating-point values within a given range. | |
| std::vector< int > | generate_random_vector (size_t size, int min_value, int max_value, uint32_t seed) |
| Generate a vector of random integers within a given range. | |
| std::vector< int > | generate_unique_random_vector (size_t size, int min_value, int max_value, uint32_t seed) |
| Generate a vector of unique random integers within a given range. | |
| std::string | make_histogram (const std::vector< float > &values, int bin_count, int hist_height) |
| Generates an ASCII histogram representation of values. | |
| std::vector< float > | moving_average (const std::vector< float > &input, int radius) |
| Smooths a vector using a centered moving average. | |
| template<typename T> | |
| void | reindex_vector (std::vector< T > &v, std::vector< size_t > &idx) |
| Reorders a vector using a given index mapping. | |
| std::vector< float > | remap (const std::vector< float > &data, float new_min=0.f, float new_max=1.f) |
| Remaps values of a vector to a given range [new_min, new_max]. | |
| template<typename T> | |
| void | shuffle_vector (std::vector< T > &values, std::uint32_t seed) |
| Shuffles a vector in-place using a deterministic seed. | |
| template<typename T> | |
| std::vector< T > | shuffled_vector (const std::vector< T > &values, std::uint32_t seed) |
| Returns a shuffled copy of a vector. | |
| size_t | upperbound_right (const std::vector< float > &v, float value) |
| Returns the index of the first element greater than a given value. | |
| void | vector_unique_values (std::vector< float > &v) |
| Removes duplicate values from a vector. | |
| std::string | to_string (StorageMode m) |
| std::unique_ptr< TileStorage > | make_storage (glm::ivec2 shape, glm::ivec2 tile_shape, StorageMode storage_mode) |
| std::string | to_string (ForEachMode m) |
| void | copy_data (const VirtualArray &src, VirtualArray &dst, const ComputeMode &cm) |
| void | sum_per_tile (const VirtualArray &va, std::vector< float > &tile_sums, float *p_total_inner_sum=nullptr, const VirtualArray *p_exclusion_mask=nullptr, float exclusion_threshold=0.f, const ComputeMode &cm={}) |
| template<std::size_t N, typename T, std::size_t... Is> | |
| auto | unpack_impl (const std::vector< T * > &v, std::index_sequence< Is... >) |
| template<std::size_t N, typename T> | |
| auto | unpack (const std::vector< T * > &v) |
| VirtualTexture | convert_texture_channels (const VirtualTexture &src, int dst_channels, float fill_value, const ComputeMode &cm) |
| template<typename Func> | |
| void | for_each_tile (VirtualTexture &tex, Func &&func, const ComputeMode &cm) |
| template<typename Func> | |
| void | for_each_tile (const VirtualTexture &tex, Func &&func, const ComputeMode &cm) |
| template<typename Func> | |
| void | for_each_pixel (VirtualTexture &tex, Func &&func, const ComputeMode &cm) |
| Forest | grow_forest_competition_nn (const Forest &forest, const std::vector< Species > &species={}, const InteractionMatrix &competition_matrix={}, const Array &max_radius_scale={}, float max_radius_scale_strength=1.0f, bool prune_unviable=true, const BBox2D &bbox=BBox2D{}) |
| Adjusts tree radii based on nearest-neighbor distances and species competition constraints. | |
| Forest | grow_forest_competition_voronoi (const Forest &forest, const std::vector< Species > &species={}, const InteractionMatrix &competition_matrix={}, const Array &max_radius_scale={}, float max_radius_scale_strength=1.0f, bool prune_unviable=true, const BBox2D &bbox=BBox2D{}) |
| Adjusts tree radii based on Voronoi cell areas and species competition constraints. | |
| Forest | grow_forest_iterative (const Forest &forest, const std::vector< Species > &species={}, size_t iterations=10, float growth_rate=0.1f, const InteractionMatrix &competition_matrix={}, const Array &max_radius_scale={}, float max_radius_scale_strength=1.0f, bool prune_unviable=true, const BBox2D &bbox=BBox2D{}, const UvTile ®ion=UvTile::unit()) |
| Simulates iterative plant growth with neighborhood competition and mortality. | |
| Forest | grow_forest_soft_core (const Forest &forest, const std::vector< Species > &species={}, const InteractionMatrix &repulsion_distances={}, const InteractionMatrix &repulsion_strengths={}, size_t target_count=0, const Array &max_radius_scale={}, float max_radius_scale_strength=1.0f, uint32_t seed=0, const BBox2D &bbox=BBox2D{}) |
| Performs multi-species Strauss soft-core growth and thinning on an input forest. | |
| Array | build_tree_density (const Array &heightmap, float min_elev=0.0f, float max_elev=0.9f, float elev_transition_width=0.1f, float min_talus=0.003f, float max_talus=0.005f, float angle=30.0f, float angle_width=90.0f, float weight_elev=1.0f, float weight_talus=1.0f, float weight_angle=0.8f, float weight_twi=0.5f, const Array &secondary_density={}, float weight_secondary=1.0f, const Array &exclusion_mask={}, float exclusion_threshold=0.f) |
| Computes an environmental suitability criteria map in [0, 1] representing tree probability density based on elevation, slope talus, aspect angle, topographic wetness index (TWI), an optional secondary density map, and an optional exclusion mask. | |
| Forest | seed_forest_clusters (size_t species_count, size_t tree_count, const Array &density, const Array &exclusion, float cluster_spread=0.05f, size_t points_per_cluster=8, const ForestSeedingOptions &options={}, const UvTile ®ion=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance()) |
| Generates a clustered forest distribution using inverse transform sampling for cluster centers and local cluster regions. | |
| Forest | seed_forest_kmeans (size_t species_count, size_t tree_count, const Array &density, const Array &exclusion, float cluster_randomness=0.0f, size_t k_neighbors=4, const ForestSeedingOptions &options={}, const UvTile ®ion=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance()) |
| Generates a multi-species forest distribution using 2D inverse transform sampling for positions and PointSampler k-means clustering to tag species. | |
| Graph | generate_network_alpha_model (const std::vector< float > &xc, const std::vector< float > &yc, const std::vector< float > &size, const BBox2D &bbox, const Array &z, std::uint32_t seed, float alpha=0.7f, int n_dummy_nodes=2500, float dz_weight=1.f, const Array *p_weight=nullptr) |
| Generate a large scale road network between "nodes" (or cities) using the alpha model. | |
| Array | build_rock_density (const Array &heightmap, float max_slope=0.05f, float bulkify_amp=0.01f, float weight_elev=1.0f, float weight_slope=1.0f, float weight_rivers=1.0f, float river_talus_ref=0.1f, float river_clipping_ratio=1000.0f, const Array &secondary_density={}, float weight_secondary=1.0f, const Array &exclusion_mask={}, float exclusion_threshold=0.f, const BBox2D &bbox=BBox2D{}) |
| Computes a probability density map in [0, 1] for rock placement based on elevation, talus/slope, river drainage paths, an optional secondary density map, and an optional exclusion mask. | |
| RockField | place_rocks_procedural (size_t rock_count, const Array &elevation, float min_elev=0.f, float max_elev=0.9f, float max_slope=1.f, const Array &density={}, const Array &exclusion={}, float size_slope_weight=0.f, float size_elevation_gain=1.f, float size_elevation_exponent=1.f, const RockSeedingOptions &options={}, const UvTile ®ion=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance()) |
| Places rocks procedurally on a terrain, without physical simulation. | |
| RockField | seed_rock_field (size_t rock_count, const Array &density, const Array &exclusion={}, const RockSeedingOptions &options={}, const UvTile ®ion=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance()) |
| Seeds a general rock/boulder field using inverse density transform sampling and applies power-law radius distribution and collision resolution. | |
| RockField | simulate_rock_emission (size_t rock_count, const Array &emission_density, const Array &elevation, const Array *p_friction_map=nullptr, const RockDistribution &dist={}, const RockSimulationOptions &options={}) |
| Emits rocks from a spatial emission density map and simulates their trajectories downhill across terrain on GPU. | |
| RockField | simulate_rock_trajectories (const RockField &rocks, const Array &elevation, const Array *p_friction_map=nullptr, const RockSimulationOptions &options={}) |
| Simulates physical movement (sliding, rolling, bouncing, and inter-rock collision avoidance) for an existing RockField across terrain on GPU. | |
| Array | operator* (const float value, const Array &array) |
| Array | operator/ (const float value, const Array &array) |
| Array | operator+ (const float value, const Array &array) |
| const Array | operator- (const float value, const Array &array) |
| template<typename T> | |
| void | convert_mat_to_array (const cv::Mat &mat, Array &array, bool flip_j) |
| void | square_fill_md (Array &array, Mat< int > &is_done, int i1, int i2, int j1, int j2, float noise_scale, std::mt19937 gen, std::uniform_real_distribution< float > dis) |
| void | square_md (Array &array, Mat< int > &is_done, int step, float noise_scale, std::mt19937 gen, std::uniform_real_distribution< float > dis) |
| Array | flatbed_carve (glm::ivec2 shape, const Path &path, float bottom_extent, float vmin, float depth, float falloff_distance, float outer_slope, bool preserve_bedshape, RadialProfile radial_profile, float radial_profile_parameter, Array *p_falloff_mask, const Array *p_noise_r, const UvRect &uv_rect) |
| uint32_t | helper_hash_u32 (uint32_t x) |
| float | helper_hash_01 (uint32_t x) |
| std::vector< glm::vec3 > | helper_tov3 (const std::vector< std::vector< float > > &colors) |
| void | thermal_schott (Array &z, const Array &talus, int iterations, float intensity) |
| void | thermal_schott (Array &z, const Array &talus, Array *p_mask, int iterations, float intensity) |
| void | thermal_schott (Array &z, const float talus, int iterations, float intensity) |
| void | thermal_schott (Array &z, const float talus, Array *p_mask, int iterations, float intensity) |
| void | helper_build_mesh_masked (aiMesh *p_mesh, const Array &array, const Array &mask, float elevation_scaling, bool fit_boundaries) |
| void | helper_build_mesh (aiMesh *p_mesh, const Array &array, MeshType mesh_type, float elevation_scaling, float max_error, bool fit_boundaries) |
| Texture | compute_splatmap (const Array *p_r, const Array *p_g, const Array *p_b, const Array *p_a) |
| glm::ivec4 | helper_compute_tile_bounds (int tile_x, int tile_y, const glm::ivec2 &tile_count, const glm::ivec2 &array_shape, bool overlapping_edges, bool reverse_tile_y_indexing) |
| void | recurve_bexp (Array &array, float tau, const Array *p_mask) |
| void | recurve_exp (Array &array, float tau, const Array *p_mask) |
| Path | helper_build_path (const std::vector< Point > &points, InterpolationMethodCurve method, Path::EdgeDivisionMode edm, int edge_divisions, int point_count) |
| size_t | helper_estimate_count (const BBox2D &bbox, float distance) |
| void | compute_gradient (const Array &array, Array &dx, Array &dy, float x_coeff[3], float y_coeff[3], float normalize_factor) |
| Array | compute_gradient_norm (const Array &array, float x_coeff[3], float y_coeff[3], float normalize_factor, Array *p_dx=nullptr, Array *p_dy=nullptr) |
| bool | is_monotonic (const std::vector< float > &data) |
| int | find_last_index_smaller_than (const std::vector< float > &vec, float threshold) |
| float | helper_wrap_phi (float phi) |
| template<typename F> | |
| auto | helper_make_wrapped (F f) |
| Array | helper_reconstruction_impl (const Array &marker, const Array &mask, int ir, float k_smooth, std::function< Array(const Array &, int)> morph_op, std::function< Array(const Array &, const Array &, float)> clamp_op) |
| void | helper_thinning (Array &in, int iter) |
| void | helper_flip_rot_transpose (Array &array, bool do_flip, int rot_steps, bool do_transpose) |
| float | helper_crater_radial_function (float r, float inner_depth, float inner_exp, float lip_height, float lip_extent, float lip_exp, int n_terraces, float terrace_extent, float terrace_exp, float terrace_persistence) |
| float | helper_crater_profile (float r, float dx, float dy, float alpha, float ap, float am, float inner_depth, float inner_exp, float lip_height, float lip_extent, float lip_exp, float central_peak_height, float central_peak_extent, int n_terraces, float terrace_extent, float terrace_exp, float terrace_persistence) |
| Point | helper_pick_lowest (const Point &pa, const Point &pb, const Array &z, float max_offset, int steps) |
| int | count_neighbors_to_fill (int i, int j, Mat< int > &is_cell_done) |
| bool | cmp_queue (std::pair< int, std::pair< int, int > > &a, std::pair< int, std::pair< int, int > > &b) |
| void | reindex_vector (std::vector< int > &v, std::vector< size_t > &idx) |
| void | reindex_vector (std::vector< float > &v, std::vector< size_t > &idx) |
| TEST (NoiseStretch, CpuIsotropicPreserved) | |
| TEST (NoiseStretch, CpuDirectionalMatchesAxisScaling) | |
| TEST (NoiseStretch, CpuOctaveDecay) | |
| TEST (NoiseStretch, GpuIsotropicAndDirectional) | |
| TEST (NoiseStretch, AllNoiseTypesCpuAndGpu) | |
| using hmap::UvTile = UvTile |
| using hmap::Tree = ScatterItem |
Represents a single tree instance.
| using hmap::Rock = ScatterItem |
Represents a single rock or boulder instance.
| enum hmap::StampingBlendMethod : int |
| enum hmap::DeformationConstraintType : int |
Penalty type of a deformation constraint (see DeformationConstraint).
|
strong |
Blending modes for combining terrains with CoordFrame transforms.
| Enumerator | |
|---|---|
| TBM_ADD | |
| TBM_AVERAGE | |
| TBM_DISTANCE | |
| TBM_HEIGHT | |
| TBM_MAX | |
| TBM_MAX_SMOOTH | |
| TBM_MIN | |
| TBM_MIN_SMOOTH | |
| TBM_MULTISCALE | |
| TBM_POISSON | |
| TBM_SEAMLESS | |
| TBM_SLOPE | |
| TBM_SUBTRACT | |
| enum hmap::PeriodicityType : int |
| enum hmap::DomainBoundary : int |
| enum hmap::ElevationLongitudinalProfile : int |
| enum hmap::MixMethod : int |
| enum hmap::NormalMapBlendingMethod : int |
| enum hmap::Cmap : int |
Enumeration for different colormap types.
Enumeration of colormap types for image processing.
This enumeration is defined in the highmap/colormap.hpp file and is used for selecting the colormap to be applied during colorization.
This enumeration defines various colormap options that can be used for visualizing data in image processing. Each colormap provides a different color mapping scheme, which can be applied to grayscale images or data to enhance visual interpretation.
| Enumerator | |
|---|---|
| BONE | |
| GRAY | |
| HOT | |
| INFERNO | |
| JET | |
| MAGMA | |
| NIPY_SPECTRAL | |
| RAINBOW_DEM | |
| SEISMIC | |
| TERRAIN | |
| TURBO | |
| VIRIDIS | |
| WHITE_UNIFORM | |
|
strong |
|
strong |
| enum hmap::CurvatureType : int |
Types of curvature measures.
Defines the different curvature descriptors that can be computed on a scalar field (e.g. heightmap). They include classical differential curvatures as well as terrain-analysis specific measures.
| enum hmap::MeshType : int |
| enum hmap::AssetExportFormat : int |
Enumeration for asset export formats supported by Assimp.
This enum lists the various file formats supported for asset export, as recognized by the Assimp library. Each format is associated with a specific file extension and usage.
|
strong |
|
strong |
Classification types for terrain-aware points of interest.
|
strong |
|
strong |
| enum hmap::NoiseType : int |
Enumeration of various noise types used for procedural generation.
This enumeration defines different types of noise algorithms that can be used for procedural generation tasks such as terrain generation, texture synthesis, and other applications where pseudo-random patterns are required.
|
strong |
Strategy used to extract a point value from an array.
| Enumerator | |
|---|---|
| AS_POINT | Array value at the point (interpolated). |
| AS_MIN | Minimum of the array values within a radius. |
| AS_MAX | Maximum of the array values within a radius. |
| AS_MEAN | Average of the array values within a radius. |
| enum hmap::PointSamplingMethod : int |
| enum hmap::FlowGraphFlag : uint8_t |
| enum hmap::InterpolationMethod1D : int |
Enumeration of the available 1D interpolation methods.
This enumeration defines the different types of interpolation methods that can be used with the Interpolator1D class.
| enum hmap::InterpolationMethod2D : int |
Enumeration of 2D interpolation methods.
This enum defines the available methods for 2D interpolation, such as Delaunay triangulation and nearest point interpolation.
| Enumerator | |
|---|---|
| ITP2D_DELAUNAY | Delaunay triangulation method for 2D interpolation. |
| ITP2D_NEAREST | Nearest point method for 2D interpolation. |
| ITP2D_IDW | Inverse Distance Weighting. |
| ITP2D_GAUSSIAN | Gaussian Distance Weighting. |
| ITP2D_NNI | Natural Neighbor Interpolation. |
| ITP2D_DELAUNAY_GRADIENT | Delaunay triangulation + linear gradient. |
| enum hmap::InterpolationMethodCurve : int |
Enumeration for specifying the interpolation method for curves.
Defines the available methods for curve interpolation:
| enum hmap::KernelType : int |
Enumeration for different kernel functions used in various algorithms.
This enumeration defines the types of kernel functions that can be used for smoothing, interpolation, and other operations requiring a kernel. Each kernel type represents a specific mathematical function used to weight data points based on their distance from a central point.
These kernels are used in algorithms that require weighting functions, such as kernel density estimation, interpolation, and data smoothing.
|
strong |
| enum hmap::DistanceFunction : int |
| enum hmap::DistanceFunctionAxis : int |
| enum hmap::ErosionProfile : int |
| enum hmap::PhasorProfile : int |
| enum hmap::RadialProfile : int |
| enum hmap::DistanceTransformType : int |
| enum hmap::MorphologyOperation : int |
Types of base morphology operators.
| enum hmap::VoronoiReturnType : int |
Selects the value returned by the Voronoi evaluation.
F1 is the distance to the nearest site, F2 to the second nearest.
| enum hmap::PrimitiveType : int |
| enum hmap::ClampMode : int |
| enum hmap::ScatterShape : int |
Defines the geometric shape used when converting a ScatterField to a heightmap.
|
strong |
| enum hmap::NormalizationMethod : int |
|
strong |
| enum hmap::SymmetryType : int |
Describes the symmetry operation to apply to an array.
| enum hmap::StorageMode : int |
| enum hmap::ForEachMode : int |
| Array hmap::cv_mat_to_array | ( | const cv::Mat & | mat, |
| bool | remap_values = true, | ||
| bool | flip_j = false ) |
Converts an OpenCV cv::Mat to a 2D Array with optional value scaling to [0, 1].
| std::string hmap::get_opencv_build_information | ( | ) |
Returns OpenCV build information string.
| cv::Mat hmap::to_cv_mat | ( | Array & | array | ) |
Converts a 2D Array to a non-owning OpenCV cv::Mat (CV_32FC1).
| void hmap::to_csv | ( | const std::vector< glm::vec3 > & | xyz, |
| const std::string & | fname ) |
|
inline |
|
inline |
| size_t hmap::count_non_zero | ( | const Array & | array | ) |
Count the number of non-zero elements in the array.
| array | Input array. |
| size_t hmap::count_zero | ( | const Array & | array | ) |
Count the number of zero elements in the array.
| array | Input array. |
|
inline |
Apply a function to every cell (mutable).
|
inline |
Apply a function to every cell (read-only).
| void hmap::alter_elevation | ( | Array & | array, |
| const Cloud & | cloud, | ||
| int | ir, | ||
| float | footprint_ratio = 1.f, | ||
| glm::vec2 | shift = {0.f, 0.f}, | ||
| glm::vec2 | scale = {1.f, 1.f} ) |
Point-wise alteration: locally enforce a new elevation value while maintaining the 'shape' of the heightmap.
This function modifies the elevation values in the input array based on a cloud of points that specify the coordinates and variations for the alterations. The function ensures that the shape of the heightmap is preserved while applying these local changes.
The alteration is performed using a kernel with a minimal radius (ir) and the intensity of the alterations is scaled based on the footprint_ratio. The shift parameter allows for introducing noise or offset in the alteration process, and the scale parameter is used to adjust the domain of the alteration.
| array | Input array representing the heightmap to be altered. The elevation values in this array will be adjusted according to the cloud data. |
| cloud | Cloud object that defines the coordinates and elevation variations for the alterations. This object provides the necessary data for applying the local changes. |
| ir | Alteration kernel minimal radius. This parameter defines the minimum size of the kernel used for local alterations. |
| footprint_ratio | Defines how the radius of the alteration scales with the variation intensity. A higher ratio results in a larger footprint of the alterations. |
| shift | Noise shift specified as a vector {xs, ys} for each direction, relative to a unit domain. This allows for adding random offsets to the alteration process. |
| scale | Domain scaling in the range [0, 1]. This parameter adjusts the domain size over which the alteration is applied. |
Example
Result
| void hmap::apply_gaussian_pushes | ( | Array & | array, |
| const std::vector< GaussianPush > & | pushes ) |
Apply a sequence of truncated-Gaussian pushes to a heightmap.
Replays, in order, the deformations recorded by sls_deformation. Since the deformed terrain is fully described by the original terrain and the push sequence, this also provides a compact storage of the deformation.
| array | Heightmap to deform (modified in place). |
| pushes | Push operations to apply, in order. |
| Array hmap::base_elevation | ( | glm::ivec2 | shape, |
| const std::vector< std::vector< float > > & | values, | ||
| float | width_factor = 1.f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const Array * | p_stretching = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generate a heightmap from a coarse grid of control points with defined elevation values.
This function creates a heightmap by interpolating elevation values provided at specific control points on a coarse grid. The result is a finer resolution heightmap where the elevation values are smoothly distributed over the entire grid.
The interpolation is performed using a Gaussian function, with the width_factor parameter controlling the half-width of the base Gaussian function used for smoothing. Optionally, noise can be added using the provided p_noise_x and p_noise_y arrays, and the heightmap can be adjusted by a local wavenumber multiplier specified by p_stretching. The bbox parameter defines the domain bounding box for the heightmap.
| shape | Dimensions of the output array (heightmap). |
| values | Elevation values at the control points specified on a coarse grid. This 2D vector holds the elevation data at each control point. |
| width_factor | Factor applied to the half-width of the Gaussian function used for smoothing the elevations. A value of 1.0 represents the default smoothing width. |
| p_noise_x | Optional pointer to an input noise array affecting the x-direction. If provided, it is used to add noise to the elevation values. |
| p_noise_y | Optional pointer to an input noise array affecting the y-direction. If provided, it is used to add noise to the elevation values. |
| p_stretching | Optional pointer to an input array that acts as a local wavenumber multiplier. If provided, it adjusts the elevation values according to the local wavenumber. |
| bbox | Domain bounding box specified as a vector {xmin, xmax, ymin, ymax}. This defines the extent of the heightmap in the coordinate space. |
Example
Result
| Array hmap::elevation_from_contours | ( | glm::ivec2 | shape, |
| const std::vector< Path > & | contours, | ||
| const std::vector< float > & | elevations, | ||
| const Array * | p_probability = nullptr, | ||
| float | randomness = 1.f, | ||
| std::uint32_t | seed = 0, | ||
| float | peak_ratio = 0.5f, | ||
| float | outside_ratio = 1.f, | ||
| bool | smoothstep = false, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Synthesize a heightmap from sparse closed iso-contours with known elevations using stochastic front propagation (proof of concept).
Experimental raster adaptation of the contour-based terrain synthesis of Huftier et al. [Huftier2026]. Each input path is treated as a closed polygon at a constant elevation. Contour pixels are fixed to their elevation (Dirichlet constraints) and the innermost enclosing contour defines the "zone" of every other pixel. Within a zone, two fronts are propagated from the fixed pixels with an Eden growth process implemented as first-passage percolation (Dijkstra with random passage times): one front from the zone's own contour, one from its child contours. The time needed to enter a pixel is ((1 - randomness) + randomness * E) / rate with E an exponential random variable and rate given by the probability map for the rising front and by its complement for the descending front. The arrival times t_near and t_far define a progress t_near / (t_near + t_far) that is mapped linearly between the two contour elevations after spurious pits are removed by a priority flood.
With randomness = 0 the passage times equal their expectation and the method reduces to a deterministic, probability-weighted geodesic front propagation. With a uniform probability map the result is then close to an inverse-distance interpolation between consecutive contours.
Leaf contours (contours without children) rise to elevation + peak_ratio * spacing at their farthest interior point, or sink by the same amount when the contour is lower than its parent (basins). Outside all contours the terrain falls off to elevation - outside_ratio * spacing. spacing is the mean elevation gap between nested contours (falls back to the elevation range, then to 1).
Limitations of this proof of concept: contours must not cross each other; children of a contour with different elevations produce a discontinuity along the seam between their regions; pit removal is only applied to zones whose child contours are all higher than the enclosing contour.
| shape | Output array shape. |
| contours | Closed contour polygons (at least 3 points each), in bbox coordinates. The closed flag of the paths is ignored, every path is closed. |
| elevations | Elevation of each contour (same size as contours). |
| p_probability | Optional probability map in [0, 1] with shape shape. Where it is high the rising front advances fast and the terrain stays low longer (gentle slopes); where it is low the terrain rises quickly (steep slopes). If null, a uniform map (0.5) is used. |
| randomness | Amount of randomness in the front propagation in [0, 1]: 0 is deterministic, 1 is the Eden growth model. |
| seed | Random seed. |
| peak_ratio | Elevation gain of leaf contour interiors, relative to the mean elevation gap between nested contours. |
| outside_ratio | Elevation drop outside all contours, relative to the mean elevation gap between nested contours. |
| smoothstep | If true, applies smoothstep (S-curve) interpolation between contours, yielding softer transitions near contour boundaries. If false (default), uses linear interpolation. |
| bbox | Domain bounding box {xmin, xmax, ymin, ymax}. |
Example
Result
| Array hmap::elevation_from_contours | ( | const Array & | contours, |
| const Array * | p_probability = nullptr, | ||
| float | randomness = 1.f, | ||
| std::uint32_t | seed = 0, | ||
| float | peak_ratio = 0.5f, | ||
| float | outside_ratio = 1.f, | ||
| bool | smoothstep = false ) |
Synthesize a heightmap from a raster of sparse iso-contours with known elevations using stochastic front propagation.
Overload of elevation_from_contours where contour elevations are provided directly on a raster grid (contours). Pixels with non-zero values (or distinct non-background elevation values) serve as the Dirichlet constraints.
| contours | Raster array containing contour elevations at contour pixels and zero elsewhere. |
| p_probability | Optional probability map in [0, 1] with the same shape as contours. |
| randomness | Amount of randomness in the front propagation in [0, 1]: 0 is deterministic, 1 is the Eden growth model. |
| seed | Random seed. |
| peak_ratio | Elevation gain of leaf contour interiors, relative to the mean elevation gap between nested contours. |
| outside_ratio | Elevation drop outside all contours, relative to the mean elevation gap between nested contours. |
| smoothstep | If true, applies smoothstep (S-curve) interpolation between contours. |
| Array hmap::elevation_from_sparse_constraints | ( | const Array & | mountains, |
| const Array * | p_coastline = nullptr, | ||
| const Array * | p_boundary = nullptr, | ||
| float | mountain_elevation = 1.0f, | ||
| float | coastline_elevation = 0.0f, | ||
| float | boundary_elevation = -1.0f, | ||
| int | iterations_max = 500, | ||
| float | tolerance = 1e-5f, | ||
| const Array * | p_noise = nullptr, | ||
| float | noise_amplitude = 0.0f ) |
Synthesize a smooth heightmap from sparse elevation constraints using GPU harmonic interpolation (Laplacian PDE).
This function allows generating a continuous terrain elevation model from sparse sketch data by treating the provided constraints as Dirichlet boundary conditions and solving the discrete Laplace equation ($\Delta z = 0$) using GPU-accelerated Red-Black SOR.
| mountains | Array specifying mountain peak/ridge elevations (> 0). |
| p_coastline | Optional pointer to coastline mask (fixed to coastline_elevation). |
| p_boundary | Optional pointer to outer boundary/ocean mask (fixed to boundary_elevation). If null, a 1-pixel boundary border around the domain perimeter is used. |
| mountain_elevation | Target elevation scaling for mountains (default: 1.0). |
| coastline_elevation | Elevation at coastline (default: 0.0). |
| boundary_elevation | Elevation at boundary/ocean (default: -1.0). |
| iterations_max | Max iterations for GPU solver (default: 500). |
| tolerance | Convergence tolerance for early exit (default: 1e-5). |
| p_noise | Optional noise array to modulate the free terrain regions. |
| noise_amplitude | Amplitude of optional noise detail (default: 0.0). |
Example
| Array hmap::reverse_midpoint | ( | const Array & | array, |
| std::uint32_t | seed, | ||
| float | noise_scale = 1.f, | ||
| float | threshold = 0.f ) |
Apply the reverse midpoint displacement algorithm to the input array.
This function implements the reverse midpoint displacement algorithm as described in Belhadj et al. (2005). The algorithm generates a terrain-like structure by applying displacement to the values in the input array based on random noise. The function can be tuned using the seed parameter for random number generation, noise_scale for controlling the amplitude of the noise, and threshold for setting a background value.
| array | Input array to which the reverse midpoint displacement algorithm will be applied. The array's values are modified to produce the output terrain. |
| seed | Random seed number used to initialize the random number generator for reproducibility. |
| noise_scale | Amplitude of the noise applied during the displacement process. A higher value results in more pronounced terrain features. |
| threshold | Threshold 'background' value used to influence the displacement algorithm. Values below this threshold may be treated differently depending on the algorithm's design. |
Example
Result
| Array hmap::ridgelines | ( | glm::ivec2 | shape, |
| const std::vector< float > & | xr, | ||
| const std::vector< float > & | yr, | ||
| const std::vector< float > & | zr, | ||
| float | slope, | ||
| float | k_smoothing = 1.f, | ||
| float | width = 0.1f, | ||
| float | vmin = 0.f, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const Array * | p_stretching = nullptr, | ||
| const UvRect & | uv_rect_array = UvRect::unit() ) |
Generate a heightmap based on a set of ridgelines and a specified slope.
This function creates a heightmap using a set of ridgelines defined by their x, y, and z coordinates, and applies a specified slope to the ridgelines. The function can optionally apply smoothing, adjust the ridge edge width, and clamp values below a minimum threshold. Additional noise and stretching parameters can be applied to modify the resulting heightmap.
| shape | The dimensions of the output array (heightmap). |
| xr | A vector of x-coordinates defining ridge segments. |
| yr | A vector of y-coordinates defining ridge segments. |
| zr | A vector of z-coordinates defining ridge segments. |
| slope | The slope applied to the ridgelines. Can be negative to invert the slope. |
| k_smoothing | Smoothing parameter to control the smoothness of the ridgelines. |
| width | Width of the ridge edges. Determines how broad the ridges appear. |
| vmin | Minimum value for the heightmap. Values below this threshold will be clamped to vmin. |
| bbox | Bounding box for the entire domain, defining the area covered by the heightmap. |
| p_noise_x | Pointer to an optional array for x-direction noise to apply to the heightmap. |
| p_noise_y | Pointer to an optional array for y-direction noise to apply to the heightmap. |
| p_stretching | Pointer to an optional array for local wavenumber multipliers to stretch the ridges. |
| bbox_array | Bounding box for the array domain, defining the spatial extent of the heightmap. |
Example
Result
| Array hmap::ridgelines_bezier | ( | glm::ivec2 | shape, |
| const std::vector< float > & | xr, | ||
| const std::vector< float > & | yr, | ||
| const std::vector< float > & | zr, | ||
| float | slope, | ||
| float | k_smoothing = 1.f, | ||
| float | width = 0.1f, | ||
| float | vmin = 0.f, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const Array * | p_stretching = nullptr, | ||
| const UvRect & | uv_rect_array = UvRect::unit() ) |
Generate a heightmap based on a set of ridgelines with quadratic Bezier interpolation.
This function creates a heightmap using ridgelines defined by their x, y, and z coordinates. The ridgelines are interpolated using quadratic Bezier curves to smooth the transitions. The function applies a specified slope to the ridgelines and can optionally apply smoothing, adjust ridge edge width, and clamp values below a minimum threshold. Additional noise and stretching parameters can be used to modify the resulting heightmap.
| shape | The dimensions of the output array (heightmap). |
| xr | A vector of x-coordinates defining ridge segments, organized in groups of three (control points of the Bezier curves). |
| yr | A vector of y-coordinates defining ridge segments, organized in groups of three (control points of the Bezier curves). |
| zr | A vector of z-coordinates defining ridge segments, organized in groups of three (control points of the Bezier curves). |
| slope | The slope applied to the ridgelines. Can be negative to invert the slope. |
| k_smoothing | Smoothing parameter to control the smoothness of the ridgelines. |
| width | Width of the ridge edges. Determines how broad the ridges appear. |
| vmin | Minimum value for the heightmap. Values below this threshold will be clamped to vmin. |
| bbox | Bounding box for the entire domain, defining the area covered by the heightmap. |
| p_noise_x | Pointer to an optional array for x-direction noise to apply to the heightmap. |
| p_noise_y | Pointer to an optional array for y-direction noise to apply to the heightmap. |
| p_stretching | Pointer to an optional array for local wavenumber multipliers to stretch the ridges. |
| bbox_array | Bounding box for the array domain, defining the spatial extent of the heightmap. |
Example
Result
| Array hmap::sls_deformation | ( | const Array & | z, |
| const std::vector< DeformationConstraint > & | constraints, | ||
| std::uint32_t | seed, | ||
| int | iterations = 200, | ||
| int | ir_min = 4, | ||
| int | ir_max = 64, | ||
| int | n_radii = 7, | ||
| float | talus_max = 0.f, | ||
| int | n_candidates = 512, | ||
| float | p_best = 0.65f, | ||
| float | top_fraction = 0.1f, | ||
| float | tolerance = 1e-3f, | ||
| std::vector< GaussianPush > * | p_pushes = nullptr ) |
Deform a heightmap to satisfy a set of constraints using stochastic local search over truncated-Gaussian push operations.
Implements the constraint-based terrain deformation of S. Stachniak and W. Stuerzlinger, "An Algorithm for Automated Fractal Terrain Deformation", WSCG
At every iteration, a set of candidate vertices is drawn: half on a jittered uniform grid, half sampled proportionally to the current penalty map so that the search concentrates where constraints are violated. For each candidate and each radius, the push amplitude is the least-squares optimum of the (locally quadratic) penalty over the kernel footprint, clamped by the slope limit talus_max * radius which suppresses high-frequency spikes (frequency limitation of the paper). The best deformation is applied with probability p_best, otherwise one of the top_fraction best deformations is applied (the stochastic noise of the search, which prevents stalling in local minima). The search stops when the fitness drops below tolerance times its initial value, when no improving deformation can be found for a number of consecutive iterations, or after iterations pushes.
| z | Input heightmap. |
| constraints | Constraint terms defining the fitness function. Every target and weight array must have the shape of z. |
| seed | Random seed number. |
| iterations | Maximum number of iterations (one push per iteration). |
| ir_min | Smallest push radius, in pixels. |
| ir_max | Largest push radius, in pixels. |
| n_radii | Number of radii, geometrically spaced in [ir_min, ir_max]. |
| talus_max | Maximum push amplitude per pixel of radius (slope limit). If zero or negative, defaults to the elevation range of the inputs divided by ir_max. |
| n_candidates | Number of candidate vertices evaluated per iteration. |
| p_best | Probability of applying the best deformation found (0.65 in the original paper). |
| top_fraction | Fraction of the best deformations a sub-optimal choice is drawn from. |
| tolerance | Relative fitness tolerance for early termination. |
| p_pushes | Optional pointer to a vector receiving the applied pushes, in order (see apply_gaussian_pushes). |
Example
Result
| Array hmap::stamping | ( | glm::ivec2 | shape, |
| const std::vector< float > & | xr, | ||
| const std::vector< float > & | yr, | ||
| const std::vector< float > & | zr, | ||
| Array | kernel, | ||
| int | kernel_ir, | ||
| bool | kernel_scale_radius, | ||
| bool | kernel_scale_amplitude, | ||
| StampingBlendMethod | blend_method, | ||
| std::uint32_t | seed, | ||
| float | k_smoothing = 0.1f, | ||
| bool | kernel_flip = true, | ||
| bool | kernel_rotate = false, | ||
| const UvRect & | uv_rect_array = UvRect::unit() ) |
Generate a heightmap by stamping a kernel at predefined locations.
This function creates a heightmap by stamping a specified kernel at given x, y, and z coordinates. The kernel can be scaled and manipulated based on the z-coordinates of the stamping points, and can be optionally flipped or rotated. The heightmap is generated by blending the results using the specified blending method. Randomization options are available for kernel manipulation.
| shape | The dimensions of the output array (heightmap). |
| xr | A vector of x-coordinates where the kernel is stamped. |
| yr | A vector of y-coordinates where the kernel is stamped. |
| zr | A vector of z-coordinates where the kernel is stamped. This affects the kernel radius and amplitude scaling. |
| kernel | The kernel to be stamped onto the heightmap. |
| kernel_ir | The radius of the kernel in pixels. |
| kernel_scale_radius | Boolean flag to scale the kernel radius based on the z-coordinates. |
| kernel_scale_amplitude | Boolean flag to scale the kernel amplitude based on the z-coordinates. |
| blend_method | The method used for blending multiple kernel stamps. Options may include additive, maximum, minimum, etc. |
| seed | Random seed number for kernel randomization. |
| k_smoothing | Smoothing parameter for the heightmap (e.g., for smooth minimum or maximum blending). |
| kernel_flip | Boolean flag to randomly flip the kernel before stamping. Flipping includes transposing. |
| kernel_rotate | Boolean flag to randomly rotate the kernel before stamping. Rotation can be resource-intensive. |
| bbox_array | Bounding box for the array domain, defining the spatial extent of the heightmap. |
Example
Result
other_related_functions Return the 'exclusion' blending of two arrays.
The exclusion blend mode creates a blend that is similar to the difference blend mode but with lower contrast. It produces an effect that is often used in image editing for special effects. For more details, see https://en.wikipedia.org/wiki/Blend_modes.
| array1 | First input array. |
| array2 | Second input array. |
Example
Result
blend_exclusion, blend_negate, blend_overlay, blend_soft Return the blending of two arrays based on their gradients.
This function blends two arrays by considering their gradients, which can be useful for producing smooth transitions between the arrays based on their directional changes.
| array1 | First input array. |
| array2 | Second input array. |
| ir | Filtering radius in pixels. |
Return the 'negate' blending of two arrays.
The negate blend mode inverts the colors of one of the arrays relative to the other. It creates a high-contrast effect that can be useful for emphasizing differences between two arrays.
| array1 | First input array. |
| array2 | Second input array. |
blend_exclusion, blend_negate, blend_overlay, blend_soft Return the 'overlay' blending of two arrays.
The overlay blend mode combines the colors of two arrays in a way that enhances contrast and emphasizes details.
| array1 | First input array. |
| array2 | Second input array. |
blend_exclusion, blend_negate, blend_overlay, blend_soft Return the 'soft' blending of two arrays.
The soft blend mode applies a soft light effect to the blending of two arrays, based on the soft light mode described in Pegtop soft light mode. It creates a subtle blend with reduced contrast.
| array1 | First input array. |
| array2 | Second input array. |
blend_exclusion, blend_negate, blend_overlay, blend_soft Return the power law blending of a set of arrays.
Blends two (or more) arrays using power law averaging:
\[f_\text{blend} = \frac{\sum_i f_i^{\alpha+1}}{\sum_i f_i^\alpha} \]
The behavior varies with the bias \(\alpha\) from a simple average of the heights at each node when \(\alpha=0\), approaching \(\max(f_i)\) as \(\alpha \to \infty\).
| arrays | Array references to blend. |
| alpha | Power law exponent (default: 0.0). |
Example
Result
Return the power law blending of two arrays.
| array1 | First input array. |
| array2 | Second input array. |
| alpha | Power law exponent (default: 0.0). |
| Array hmap::mixer | ( | const Array & | t, |
| const std::vector< const Array * > & | arrays, | ||
| float | gain_factor = 1.f ) |
Return the mixing of a set of arrays based on a parameter t.
This function mixes a set of arrays based on a mixing coefficient t that determines the contribution of each array. The parameter t should be in the range [0, 1], where t represents the blending ratio.
| t | Mixing coefficient, in the range [0, 1]. |
| arrays | References to the input arrays to be mixed. |
Example
Result
| Array hmap::transfer | ( | const Array & | source, |
| const Array & | target, | ||
| int | ir, | ||
| float | amplitude, | ||
| bool | target_prefiltering = false ) |
Transfers spatial details from a source array onto a target array.
This function applies a high-pass spatial filter to the source array (using a smoothing pulse of radius ir) to extract its high-frequency content. That content is then scaled by amplitude and blended with the target array. Optionally, the target can be prefiltered before blending.
The result is a new array that combines the base structure of target with the high-frequency details from source.
| source | The input array providing high-frequency details. |
| target | The input array providing the base structure. |
| ir | Radius (in pixels or samples) for the smoothing filter used to separate low/high frequencies. |
| amplitude | Scaling factor applied to the high-frequency content extracted from source. |
| target_prefiltering | If true, target is smoothed before blending to better integrate with the transferred details. |
Example
Result
| void hmap::blend_terrains | ( | Array & | lower, |
| const CoordFrame & | frame_lower, | ||
| const Array & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| TerrainBlendMode | mode, | ||
| float | param = 0.2f ) |
Blend an upper terrain onto a lower terrain in-place, taking their CoordFrame transforms into account.
| lower | Lower (base) terrain array, modified in-place. |
| frame_lower | Coordinate frame of the lower terrain. |
| upper | Upper (overlay) terrain array. |
| frame_upper | Coordinate frame of the upper terrain. |
| mode | Blending mode. |
| param | Mode-specific parameter (smoothness k for MIN_SMOOTH / MAX_SMOOTH, normalized feathering width in (0, 0.5] for DISTANCE). |
| void hmap::blend_terrains | ( | VirtualArray & | lower, |
| const CoordFrame & | frame_lower, | ||
| const VirtualArray & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| TerrainBlendMode | mode, | ||
| float | param = 0.2f, | ||
| const ComputeMode & | cm = ComputeMode{} ) |
Blend an upper VirtualArray terrain onto a lower VirtualArray terrain in-place, taking their CoordFrame transforms into account.
| lower | Lower (base) VirtualArray, modified in-place. |
| frame_lower | Coordinate frame of the lower terrain. |
| upper | Upper (overlay) VirtualArray. |
| frame_upper | Coordinate frame of the upper terrain. |
| mode | Blending mode. |
| param | Mode-specific parameter (smoothness k for MIN_SMOOTH / MAX_SMOOTH, normalized feathering width in (0, 0.5] for DISTANCE). |
| cm | Compute mode for tile execution. |
| void hmap::blend_terrains_height | ( | Array & | lower, |
| const CoordFrame & | frame_lower, | ||
| const Array & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| float | feather_width = 0.2f, | ||
| float | height_offset = 0.f, | ||
| float | height_range = 0.2f ) |
Height-aware terrain blending for Array inputs.
| void hmap::blend_terrains_height | ( | VirtualArray & | lower, |
| const CoordFrame & | frame_lower, | ||
| const VirtualArray & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| float | feather_width = 0.2f, | ||
| float | height_offset = 0.f, | ||
| float | height_range = 0.2f, | ||
| const ComputeMode & | cm = ComputeMode{} ) |
Height-aware terrain blending for VirtualArray inputs.
| void hmap::blend_terrains_multiscale | ( | Array & | lower, |
| const CoordFrame & | frame_lower, | ||
| const Array & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| float | feather_width = 0.25f, | ||
| int | n_levels = 3, | ||
| int | base_radius = 16, | ||
| float | detail_gain = 1.f ) |
Multiscale (frequency-band) terrain blending for Array inputs.
| void hmap::blend_terrains_multiscale | ( | VirtualArray & | lower, |
| const CoordFrame & | frame_lower, | ||
| const VirtualArray & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| float | feather_width = 0.25f, | ||
| int | n_levels = 3, | ||
| int | base_radius = 16, | ||
| float | detail_gain = 1.f, | ||
| int | coarse_size = 128, | ||
| const ComputeMode & | cm = ComputeMode{} ) |
Multiscale (frequency-band) terrain blending for VirtualArray inputs using a coarse global proxy for low-frequency bands and tile-local detail blending with halo synchronization.
| void hmap::blend_terrains_poisson | ( | Array & | lower, |
| const CoordFrame & | frame_lower, | ||
| const Array & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| int | iterations = 400, | ||
| float | feather_width = 0.15f, | ||
| bool | mixed_gradients = true ) |
Poisson / gradient-domain terrain blending for Array inputs.
| void hmap::blend_terrains_poisson | ( | VirtualArray & | lower, |
| const CoordFrame & | frame_lower, | ||
| const VirtualArray & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| int | iterations = 400, | ||
| float | feather_width = 0.15f, | ||
| bool | mixed_gradients = true, | ||
| int | coarse_size = 128, | ||
| int | sync_interval = 25, | ||
| const ComputeMode & | cm = ComputeMode{} ) |
Poisson / gradient-domain terrain blending for VirtualArray inputs using a two-level coarse-proxy + tile-local Red-Black SOR solver with halo synchronization.
| void hmap::blend_terrains_seamless | ( | Array & | lower, |
| const CoordFrame & | frame_lower, | ||
| const Array & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| float | feather_width = 0.2f, | ||
| int | boundary_samples = 64 ) |
Seamless boundary blending (harmonic MVC membrane) for Array inputs.
| void hmap::blend_terrains_seamless | ( | VirtualArray & | lower, |
| const CoordFrame & | frame_lower, | ||
| const VirtualArray & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| float | feather_width = 0.2f, | ||
| int | boundary_samples = 64, | ||
| const ComputeMode & | cm = ComputeMode{} ) |
Seamless boundary blending (harmonic MVC membrane) for VirtualArray inputs.
| void hmap::blend_terrains_slope | ( | Array & | lower, |
| const CoordFrame & | frame_lower, | ||
| const Array & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| float | feather_width = 0.2f, | ||
| float | slope_scale = 0.1f, | ||
| int | ir_slope = 2 ) |
Slope-aware terrain blending for Array inputs.
| void hmap::blend_terrains_slope | ( | VirtualArray & | lower, |
| const CoordFrame & | frame_lower, | ||
| const VirtualArray & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| float | feather_width = 0.2f, | ||
| float | slope_scale = 0.1f, | ||
| int | ir_slope = 2, | ||
| const ComputeMode & | cm = ComputeMode{} ) |
Slope-aware terrain blending for VirtualArray inputs.
| void hmap::extrapolate_borders | ( | Array & | array, |
| int | nbuffer = 1, | ||
| float | sigma = 0.f, | ||
| float | vmin = -FLT_MAX ) |
Performs linear extrapolation of values at the borders of an array (e.g., i = 0, j = 0, etc.) based on the inner values of the array.
This function modifies the borders of the input array by applying a linear extrapolation method, which uses the values inside the array to estimate and fill in the border values. The extrapolation is influenced by a relaxation coefficient (sigma) and a buffer depth (nbuffer), which determines how many layers of the border are extrapolated.
| array | Reference to the input array whose borders need extrapolation. |
| nbuffer | Optional parameter specifying the buffer depth, i.e., the number of layers at the border to extrapolate. Default is 1. |
| sigma | Optional relaxation coefficient that adjusts the influence of inner values on the extrapolated border values. Default is 0.0. |
| void hmap::falloff | ( | Array & | array, |
| float | strength = 1.f, | ||
| DistanceFunction | dist_fct = DistanceFunction::EUCLIDIAN, | ||
| const Array * | p_noise = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Applies a falloff effect to the input array based on distance.
This function modifies the elements of the input array by applying a falloff effect, which decreases the values based on their distance from a central point or area. The strength of the falloff, the type of distance function used, and optional noise can be specified.
| array | Reference to the array that will be modified by the falloff effect. |
| strength | The strength of the falloff effect. A higher value results in a stronger falloff. Default is 1.0f. |
| dist_fct | The distance function to be used for calculating the falloff. Options include Euclidian and others, with DistanceFunction::EUCLIDIAN as the default. |
| p_noise | Optional pointer to an array that provides noise to be added to the falloff effect. If nullptr (default), no noise is added. |
| bbox | A 4D vector representing the bounding box within which the falloff effect is applied. The default is {0.f, 1.f, 0.f, 1.f}. |
Example
Result
| void hmap::fill_borders | ( | Array & | array | ) |
Fills the border values of an array (e.g., i = 0, j = 0, etc.) based on the values of the first neighboring cells.
This function modifies the border values of the input array by copying values from their immediate neighbors. The operation ensures that border values are consistent with their adjacent cells, typically used to prepare the array for further processing.
| array | Reference to the input array whose borders need to be filled. |
| void hmap::fill_borders | ( | Array & | array, |
| int | nbuffer ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| Array hmap::generate_buffered_array | ( | const Array & | array, |
| glm::ivec4 | buffers, | ||
| bool | zero_padding = false ) |
Creates and returns a new array with additional buffer zones at the boundaries, where the buffer values are filled either by symmetry or by zero-padding.
This function takes an input array and generates a new array with extra layers (buffers) added to its boundaries. The size of these buffer zones is specified by the buffers parameter, and the values within these buffers can be filled either by reflecting the values at the boundaries (symmetry) or by padding with zeros.
| array | Reference to the input array. |
| buffers | A vector specifying the buffer sizes for the east, west, south, and north boundaries. |
| zero_padding | Optional boolean flag to use zero-padding instead of symmetry for filling the buffer values. Default is false. |
| void hmap::make_periodic | ( | Array & | array, |
| int | nbuffer, | ||
| const PeriodicityType & | periodicity_type = PeriodicityType::PERIODICITY_XY ) |
Adjusts the input array to be periodic in both directions by transitioning smoothly at the boundaries.
This function modifies the input array so that the values at the boundaries transition smoothly, making the array periodic in both the horizontal and vertical directions. The width of the transition zone at the boundaries is controlled by the nbuffer parameter.
| array | Reference to the input array to be made periodic. |
| nbuffer | The width of the transition zone at the boundaries. |
Example
Result
Creates a periodic array in both directions using a stitching operation that minimizes errors at the boundaries.
This function generates a new array that is periodic in both directions by applying a stitching operation at the boundaries. The stitching process aims to minimize discrepancies, creating a seamless transition between the edges of the array. The overlap parameter determines the extent of the overlap during the stitching, based on the half-size of the domain. If overlap is set to 1, the transition spans the entire domain.
| array | Reference to the input array to be made periodic. |
| overlap | A float value representing the overlap based on the domain's half-size. An overlap of 1 means the transition spans the whole domain. |
Example
Result
Creates a tiled, periodic array by applying a transition with overlap in both directions.
This function generates a new array that is periodic and tiled according to the specified tiling dimensions. The periodicity is achieved by applying a transition at the boundaries, where the extent of overlap is determined by the overlap parameter. The tiling parameter specifies the number of tiles in the horizontal and vertical directions.
| array | Reference to the input array to be tiled and made periodic. |
| overlap | A float value representing the overlap based on the domain's half-size. If overlap is 1, the transition spans the entire domain on both sides. |
| tiling | A 2D vector specifying the number of tiles in the horizontal and vertical directions. |
Example
Result
| glm::ivec2 hmap::pick_boundary_cell | ( | const Array & | z, |
| DomainBoundary | boundary, | ||
| std::uint32_t | seed, | ||
| bool | favor_boundary_center = true, | ||
| bool | favor_lower_elevation = true, | ||
| bool | favor_sinks = true ) |
Picks a boundary cell using weighted random selection.
Selects a cell on the specified boundary, where each candidate is assigned a weight. Higher weights increase the probability of selection.
Optional weighting factors:
z (normalized).Weights are combined multiplicatively. Selection is deterministic given seed.
| z | Input 2D scalar field. |
| boundary | Boundary to sample from. |
| seed | Random seed. |
| favor_boundary_center | Enable center bias. |
| favor_lower_elevation | Enable low-value bias. |
| favor_sinks | Enable sink bias. |
Example
Result
| void hmap::set_borders | ( | Array & | array, |
| glm::vec4 | border_values, | ||
| glm::ivec4 | buffer_sizes ) |
Enforces specific values at the boundaries of the array.
This function sets the values at the borders of the input array to specified values for each side (east, west, south, and north). The size of the buffer zone at each border can also be defined, allowing precise control over how much of the boundary is modified.
| array | Reference to the input array whose borders are to be modified. |
| border_values | A vector specifying the values to set at the east, west, south, and north borders. |
| buffer_sizes | A vector specifying the size of the buffer zones at the east, west, south, and north borders. |
Example
Result
| void hmap::set_borders | ( | Array & | array, |
| glm::vec4 | border_values, | ||
| glm::vec4 | buffer_sizes, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Enforces specific values at the domain boundaries based on distance.
This overloaded function sets values near the boundaries of the unit square domain [0, 1] x [0, 1] based on continuous distances. The array corresponds to the specified bounding box bbox.
| array | Reference to the input array whose borders are to be modified. |
| border_values | A vector specifying the values to set at the west, east, south, and north borders. |
| buffer_sizes | A vector specifying the buffer distance at the west, east, south, and north borders. |
| bbox | Domain bounding box {xmin, xmax, ymin, ymax}. Default is {0.f, 1.f, 0.f, 1.f}. |
| void hmap::set_borders | ( | Array & | array, |
| float | border_values, | ||
| int | buffer_sizes ) |
Enforces a uniform value at all boundaries of the array.
This overloaded function sets the same value at all borders of the input array. The size of the buffer zone at each border can be defined with a single value that applies uniformly to all sides.
| array | Reference to the input array whose borders are to be modified. |
| border_values | The value to set at all borders. |
| buffer_sizes | The size of the buffer zone to apply uniformly at all borders. |
| void hmap::set_borders | ( | Array & | array, |
| float | border_values, | ||
| float | buffer_sizes, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Enforces a uniform value at all domain boundaries based on distance.
This overloaded function sets the same value at all borders of the unit square domain [0, 1] x [0, 1] based on a continuous buffer distance. The array corresponds to the specified bounding box bbox.
| array | Reference to the input array whose borders are to be modified. |
| border_values | The value to set at all borders. |
| buffer_sizes | The buffer distance to apply uniformly at all borders. |
| bbox | Domain bounding box {xmin, xmax, ymin, ymax}. Default is {0.f, 1.f, 0.f, 1.f}. |
| void hmap::sym_borders | ( | Array & | array, |
| glm::ivec4 | buffer_sizes ) |
Fills the values at the domain borders using symmetry over a specified buffer depth.
This function fills the borders of the input array by reflecting the values inside the array symmetrically. The depth of the buffer at each border (east, west, south, north) is specified by the buffer_sizes parameter.
| array | Reference to the input array whose borders are to be filled using symmetry. |
| buffer_sizes | A vector specifying the buffer sizes at the east, west, south, and north borders. |
| void hmap::zeroed_borders | ( | Array & | array | ) |
Fills the border values (e.g., i = 0, j = 0, etc.) of the array with zeros.
This function sets all the values at the borders of the input array to zero. It can be used to zero out boundary values, preparing the array for specific computations.
| array | Reference to the input array whose borders are to be zeroed. |
| void hmap::zeroed_edges | ( | Array & | array, |
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP, | ||
| float | profile_param = 0.f, | ||
| float | amount = 1.f, | ||
| DistanceFunction | distance = DistanceFunction::EUCLIDIAN, | ||
| DistanceFunctionAxis | dfa = DistanceFunctionAxis::DFA_XY, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| float | radius = 0.5f, | ||
| const Array * | p_noise_r = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Smoothly attenuates array values toward zero near the domain boundaries.
Applies a radial profile centered at center with the specified radius. The effect can be shaped using radial_profile, profile_param, and an optional noise modulation array.
| array | Input/output array. |
| radial_profile | Radial attenuation profile. |
| profile_param | Profile-specific parameter. |
| amount | Effect strength in [0, 1]. |
| distance | Distance function. |
| dfa | Distance axes used for distance evaluation. |
| center | Profile center in normalized coordinates. |
| radius | Profile radius. |
| p_noise_r | Optional modulation array. |
| bbox | Domain bounding box. |
| void hmap::carve_river | ( | Array & | z, |
| const Graph & | graph, | ||
| float | talus, | ||
| float | outlet_width, | ||
| float | headwater_width = 0.f, | ||
| float | width_exponent = 0.5f, | ||
| float | depth = 0.05f, | ||
| float | depth_exponent = 0.3f, | ||
| std::uint32_t | seed = 0, | ||
| float | talus_noise_ratio = 0.f, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP_UPPER, | ||
| float | radial_profile_parameter = 2.f, | ||
| Array * | p_river_mask = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Carves a continuous river network into a heightmap along a directed flow Graph.
A triangular riverbed with a given slope (talus) is generated from the channel bottom using expand_talus, and merged with the original heightmap using the network signed distance field (SDF), scaling channel width and depth with flow accumulation.
| [in,out] | z | Target heightmap to carve in-place. |
| [in] | graph | Input flow network Graph. |
| [in] | talus | Slope of the triangular riverbed valley walls. |
| [in] | outlet_width | Maximum channel influence width at downstream outlet(s). |
| [in] | headwater_width | Minimum channel influence width at headwaters (default: 0). |
| [in] | width_exponent | Scaling exponent for channel width with flow accumulation (default: 0.5). |
| [in] | depth | Incision depth below graph elevation for river bottom (default: 0.05). |
| [in] | depth_exponent | Scaling exponent for depth scaling with flow accumulation (default: 0.3). |
| [in] | seed | Random seed for expand_talus (default: 0). |
| [in] | talus_noise_ratio | Roughness / perturbation ratio for valley expansion (default: 0). |
| [in] | radial_profile | Blending profile for SDF transition (default: RP_SMOOTHSTEP_UPPER). |
| [in] | radial_profile_parameter | Shaping parameter for the radial profile (default: 2.0). |
| [out] | p_river_mask | Optional output mask in [0, 1] of carved river channel. |
| [in] | bbox | Domain bounding box. |
| void hmap::dig_path | ( | Array & | z, |
| Path & | path, | ||
| int | width = 1, | ||
| int | decay = 2, | ||
| int | flattening_radius = 16, | ||
| bool | force_downhill = false, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | depth = 0.f ) |
Dig a path on a heightmap.
This function modifies a heightmap array by "digging" a path into it based on the provided path. The path is represented by a Path object, and the function adjusts the height values in the z array to create the appearance of a dug path. The width, border decay, and flattening radius parameters control the characteristics of the dig. Optionally, the path can be forced to have a monotonically decreasing elevation.
Example
Result
| z | Input array representing the heightmap to be modified. |
| path | The path to be dug into the heightmap, with coordinates with respect to a unit-square. The path will be processed to create the dig effect. |
| width | Radius of the path width in pixels. This determines how wide the dug path will be. |
| decay | Radius of the path border decay in pixels. This controls how quickly the effect of the path fades out towards the edges. |
| flattening_radius | Radius used to flatten the elevation of the path, creating a smooth transition. This is measured in pixels. |
| force_downhill | If true, the path's elevation will be forced to decrease monotonically, creating a downhill effect. |
| bbox | Bounding box specifying the region of the heightmap to consider for the digging operation. It defines the area where the path is applied. |
| depth | Optional depth parameter to specify the maximum depth of the dig. If not provided, the default depth of 0.f is used. |
| void hmap::flatten_around_points | ( | Array & | z, |
| const std::vector< float > & | xp, | ||
| const std::vector< float > & | yp, | ||
| const std::vector< float > & | zp, | ||
| const std::vector< float > & | radius, | ||
| float | strength = 1.0f, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP, | ||
| float | profile_param = 1.0f, | ||
| Array * | p_mask = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Flattens a heightmap locally around a set of reference points.
Each point has its own influence radius. For a given cell, only the points whose radius covers the cell are kept, and the target elevation is the average of their elevations weighted by falloff * radius (larger radius, larger influence). The cell is blended toward this target using the sum of the falloffs (clamped to 1), which keeps the transition smooth.
| [in,out] | z | Heightmap array to modify in place. |
| [in] | xp | Point x coordinates (in the bounding box). |
| [in] | yp | Point y coordinates (in the bounding box). |
| [in] | zp | Reference elevations of the points. |
| [in] | radius | Influence radius of each point. |
| [in] | strength | Flattening strength in [0, 1]. |
| [in] | radial_profile | Radial profile type used for distance falloff. |
| [in] | profile_param | Shape parameter for the radial profile. |
| [out] | p_mask | Optional output blending weights. |
| [in] | bbox | Bounding box of the heightmap. |
| void hmap::flatten_around_points | ( | Array & | z, |
| const std::vector< float > & | xp, | ||
| const std::vector< float > & | yp, | ||
| const std::vector< float > & | zp, | ||
| float | radius = 0.2f, | ||
| float | strength = 1.0f, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP, | ||
| float | profile_param = 1.0f, | ||
| Array * | p_mask = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Overload of flatten_around_points with a single radius shared by all points.
| void hmap::flatten_around_points_terrain_aware | ( | Array & | z, |
| const std::vector< float > & | xp, | ||
| const std::vector< float > & | yp, | ||
| const std::vector< float > & | zp, | ||
| const std::vector< float > & | radius, | ||
| float | slope_weight = 1.f, | ||
| float | uphill_weight = 2.f, | ||
| float | max_height_above = -1.f, | ||
| float | terrain_follow = 0.5f, | ||
| float | strength = 1.f, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP, | ||
| float | profile_param = 1.f, | ||
| Array * | p_mask = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Terrain-aware flattening around a set of seed points.
From each seed, a Dijkstra propagation computes an accumulated cost distance over the heightmap. The step cost is the step length multiplied by 1 + slope_weight * slope + uphill_weight * climb / radius, so the flattened region follows valleys and spreads easily over flat areas but is reduced on steep or higher terrain. Cells are reached only while the cost is below the radius and the Euclidean distance is below the radius (the radius is thus a maximum geometric extent) and the elevation is not above the height limit.
The cost distance replaces the Euclidean distance in the radial profile. The target surface is the seed elevation plus a fraction (terrain_follow) of the smoothed terrain relief relative to the seed, so it is not an exact plateau. Contributions of several seeds are combined as in flatten_around_points.
| [in,out] | z | Heightmap array to modify in place. |
| [in] | xp | Seed x coordinates (in the bounding box). |
| [in] | yp | Seed y coordinates. |
| [in] | zp | Seed reference elevations. |
| [in] | radius | Maximum geometric extent of each seed (bbox units). |
| [in] | slope_weight | Penalty on the local slope (0: ignored). |
| [in] | uphill_weight | Penalty on climbing above the seed elevation (0: ignored). |
| [in] | max_height_above | Cells higher than seed elevation + max_height_above are never reached (negative: no limit). |
| [in] | terrain_follow | Amount of smoothed relief kept in the target surface: 0 gives an exact plateau, 1 keeps the whole relief. |
| [in] | strength | Flattening strength in [0, 1]. |
| [in] | radial_profile | Radial profile used for the falloff. |
| [in] | profile_param | Shape parameter of the radial profile. |
| [out] | p_mask | Optional output blending weights. |
| [in] | bbox | Bounding box of the heightmap. |
| void hmap::flatten_around_points_terrain_aware | ( | Array & | z, |
| const std::vector< float > & | xp, | ||
| const std::vector< float > & | yp, | ||
| const std::vector< float > & | zp, | ||
| float | radius, | ||
| float | slope_weight = 1.f, | ||
| float | uphill_weight = 2.f, | ||
| float | max_height_above = -1.f, | ||
| float | terrain_follow = 0.5f, | ||
| float | strength = 1.f, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP, | ||
| float | profile_param = 1.f, | ||
| Array * | p_mask = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Overload with a single radius shared by all seeds.
| void hmap::flatbed_carve | ( | Array & | z, |
| const Path & | path, | ||
| float | bottom_extent = 32.f, | ||
| float | vmin = 0.1f, | ||
| float | depth = 0.05f, | ||
| float | falloff_distance = 128.f, | ||
| float | outer_slope = 0.1f, | ||
| bool | preserve_bedshape = true, | ||
| RadialProfile | radial_profile = RadialProfile::RP_GAIN, | ||
| float | radial_profile_parameter = 2.f, | ||
| Array * | p_falloff_mask = nullptr, | ||
| const Array * | p_noise_r = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Blends a flatbed carve into an existing heightmap.
Carves and blends a flatbed shape along a path into the provided array, using a smooth falloff mask.
| z | Heightmap to modify in place. |
| path | Path defining the bed centerline. |
| bottom_extent | Radius of the flatbed region. |
| vmin | Base height value. |
| depth | Bed depth. |
| falloff_distance | Falloff width outside the bed. |
| outer_slope | Linear slope beyond the bed. |
| preserve_bedshape | Preserve relative bed shape under radial noise. |
| radial_profile | Radial profile type. |
| radial_profile_parameter | Shape parameter for the profile. |
| p_falloff_mask | Optional output falloff mask. |
| p_noise_r | Optional radial noise. |
| bbox | World-space bounding box. |
Example
Result
| void hmap::trench | ( | Array & | z, |
| const Path & | path, | ||
| float | width, | ||
| bool | enable_width_depth_scaling = true, | ||
| bool | enable_width_distance_scaling = true, | ||
| bool | enable_width_curvature_scaling = false, | ||
| float | curvature_radius_min = 1.f, | ||
| float | curv_width_ratio_min = 0.5f, | ||
| float | curv_width_ratio_max = 2.f, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP_UPPER, | ||
| float | radial_profile_parameter = 2.f, | ||
| ElevationLongitudinalProfile | longitudinal_profile = ElevationLongitudinalProfile::ELP_DECREASING, | ||
| float | elevation_shift = -0.05f, | ||
| float | shift_ramp_start_ratio = 0.f, | ||
| float | shift_ramp_end_ratio = 0.f, | ||
| float | min_slope = 0.001f, | ||
| size_t | k_neighbors = 8, | ||
| const Array * | p_noise_r = nullptr, | ||
| Array * | p_bending_mask = nullptr, | ||
| int | tile_size = 32, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Carves a trench along a given path into a heightmap.
This function modifies the input heightmap by carving a trench defined by a polyline path. The trench shape is controlled both longitudinally (along the path) and radially (across the path). Optional noise and scaling can be applied to introduce variations in width and depth.
| [in,out] | z | Heightmap to modify (2D array of elevations). |
| [in] | path | Polyline defining the trench centerline. |
| [in] | width | Base width of the trench. |
| [in] | enable_width_depth_scaling | If true, modulates trench width based on local elevation difference. |
| [in] | radial_profile | Type of radial profile used to shape the trench cross-section. |
| [in] | radial_profile_parameter | Parameter controlling the radial profile shape. |
| [in] | longitudinal_profile | Controls how elevation evolves along the path (e.g., flat, increasing, decreasing). |
| [in] | elevation_shift | Global elevation offset applied along the path. |
| [in] | shift_ramp_start_ratio | Ratio of the path length used to smoothly ramp the elevation shift at the beginning. |
| [in] | shift_ramp_end_ratio | Ratio of the path length used to smoothly ramp the elevation shift at the end. |
| [in] | min_slope | Minimum slope enforced between consecutive path points when monotonicity is required. |
| [in] | k_neighbors | Number of nearest neighbors used for interpolation. |
| [in] | p_noise_r | Optional pointer to a noise array used to locally perturb trench width (can be nullptr). |
| [out] | p_bending_mask | Optional output mask representing blending weights (can be nullptr). |
| [in] | tile_size | Tile size in pixels for spatial BVH partitioning (default: 32). A recommended rule of thumb is to choose tile_size on the order of the trench width in pixels: tile_size ~ clamp(width / dx, 16, 128). |
| [in] | bbox | Bounding box of the domain as (xmin, xmax, ymin, ymax). |
elevation_shift is non-zero when width-depth scaling is enabled, to avoid division by zero.Example
Result
| void hmap::trench | ( | Array & | z, |
| const std::vector< Path > & | paths, | ||
| float | width, | ||
| bool | enable_width_depth_scaling = true, | ||
| bool | enable_width_distance_scaling = true, | ||
| bool | enable_width_curvature_scaling = false, | ||
| float | curvature_radius_min = 1.f, | ||
| float | curv_width_ratio_min = 0.5f, | ||
| float | curv_width_ratio_max = 2.f, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP_UPPER, | ||
| float | radial_profile_parameter = 2.f, | ||
| ElevationLongitudinalProfile | longitudinal_profile = ElevationLongitudinalProfile::ELP_DECREASING, | ||
| float | elevation_shift = -0.05f, | ||
| float | shift_ramp_start_ratio = 0.f, | ||
| float | shift_ramp_end_ratio = 0.f, | ||
| float | min_slope = 0.001f, | ||
| size_t | k_neighbors = 8, | ||
| const Array * | p_noise_r = nullptr, | ||
| Array * | p_bending_mask = nullptr, | ||
| int | tile_size = 32, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
| void hmap::trench | ( | Array & | z, |
| const Graph & | graph, | ||
| const std::vector< float > & | relative_widths, | ||
| float | width, | ||
| bool | enable_width_depth_scaling = true, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP_UPPER, | ||
| float | radial_profile_parameter = 2.f, | ||
| ElevationLongitudinalProfile | longitudinal_profile = ElevationLongitudinalProfile::ELP_DECREASING, | ||
| float | elevation_shift = -0.05f, | ||
| float | min_slope = 0.001f, | ||
| const Array * | p_noise_r = nullptr, | ||
| Array * | p_bending_mask = nullptr, | ||
| int | tile_size = 32, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Carves river channels for an entire flow network represented by a Graph with per-node relative widths.
Each node in the graph provides a relative width ratio in [0, 1] (scaled by width to obtain the node's channel width). Along each edge between node u and node v, width is linearly interpolated as a function of the projection parameter t:
w(t) = width * ((1 - t) * r_u + t * r_v)
| [in,out] | z | Target heightmap to carve in-place. |
| [in] | graph | Input flow network Graph. |
| [in] | relative_widths | Relative width ratio in [0, 1] per graph node. |
| [in] | width | Maximum base width. |
| [in] | enable_width_depth_scaling | Modulate width according to depth. |
| [in] | radial_profile | Transverse cross-section profile. |
| [in] | radial_profile_parameter | Shaping parameter for radial profile. |
| [in] | longitudinal_profile | Downhill elevation monotonicity mode. |
| [in] | elevation_shift | Depth of trench incision. |
| [in] | min_slope | Minimum downstream slope. |
| [in] | p_noise_r | Optional noise array for radial perturbation. |
| [out] | p_bending_mask | Optional blending mask. |
| [in] | tile_size | Spatial tile partition size. |
| [in] | bbox | Domain bounding box. |
| void hmap::trench | ( | Array & | z, |
| const Graph & | graph, | ||
| float | width, | ||
| float | width_exponent = 1.0f, | ||
| bool | enable_width_depth_scaling = true, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP_UPPER, | ||
| float | radial_profile_parameter = 2.f, | ||
| ElevationLongitudinalProfile | longitudinal_profile = ElevationLongitudinalProfile::ELP_DECREASING, | ||
| float | elevation_shift = -0.05f, | ||
| float | min_slope = 0.001f, | ||
| const Array * | p_noise_r = nullptr, | ||
| Array * | p_bending_mask = nullptr, | ||
| int | tile_size = 32, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Carves river channels for an entire flow network represented by a Graph, computing relative widths from distance to outlet.
| [in,out] | z | Target heightmap to carve in-place. |
| [in] | graph | Input flow network Graph. |
| [in] | width | Target river width at the outlet(s). |
| [in] | width_exponent | Scaling exponent for width with distance to outlet (default: 1.0). |
| [in] | enable_width_depth_scaling | Modulate width according to depth. |
| [in] | radial_profile | Transverse cross-section profile. |
| [in] | radial_profile_parameter | Shaping parameter for radial profile. |
| [in] | longitudinal_profile | Downhill elevation monotonicity mode. |
| [in] | elevation_shift | Depth of trench incision. |
| [in] | min_slope | Minimum downstream slope. |
| [in] | p_noise_r | Optional noise array for radial perturbation. |
| [out] | p_bending_mask | Optional blending mask. |
| [in] | tile_size | Spatial tile partition size. |
| [in] | bbox | Domain bounding box. |
| void hmap::apply_hillshade | ( | Texture & | img, |
| const Array & | array, | ||
| float | vmin = 0.f, | ||
| float | vmax = 1.f, | ||
| float | exponent = 1.f ) |
Apply hillshading to a Tensor image.
This function applies a hillshading effect to the provided tensor image using the elevation data in the input array. The effect is controlled by the power exponent and can be scaled by specifying the minimum and maximum values.
| img | Input image represented as a Tensor. |
| array | Elevation data used to generate the hillshading effect. |
| vmin | Minimum value for scaling the hillshading effect (default is 0.f). |
| vmax | Maximum value for scaling the hillshading effect (default is 1.f). |
| exponent | Power exponent applied to the hillshade values (default is 1.f). |
| void hmap::apply_hillshade | ( | std::vector< uint8_t > & | img, |
| const Array & | array, | ||
| float | vmin = 0.f, | ||
| float | vmax = 1.f, | ||
| float | exponent = 1.f, | ||
| bool | is_img_rgba = false ) |
Apply hillshading to an 8-bit image.
This function applies a hillshading effect to a vector of 8-bit image data. The effect is computed based on the elevation data in the input array. The image can be either RGB or RGBA format depending on the is_img_rgba flag.
| img | Input image represented as a vector of 8-bit data. |
| array | Elevation data used to generate the hillshading effect. |
| vmin | Minimum value for scaling the hillshading effect (default is 0.f). |
| vmax | Maximum value for scaling the hillshading effect (default is 1.f). |
| exponent | Power exponent applied to the hillshade values (default is 1.f). |
| is_img_rgba | Boolean flag indicating if the input image has an alpha channel (default is false). |
| void hmap::color_adjust | ( | Array & | r, |
| Array & | g, | ||
| Array & | b, | ||
| ColorAdjust | param, | ||
| glm::ivec2 | dither_seed ) |
Apply color correction and tonemapping to RGB arrays.
Performs per-pixel adjustments including levels, exposure, tonemapping (Reinhard, ACES, or AGX), contrast, saturation, temperature, gamma, and optional dithering.
| r | Red channel array (modified in place). |
| g | Green channel array (modified in place). |
| b | Blue channel array (modified in place). |
| param | Color adjustment parameters. |
| dither_seed | Seed used for dithering noise. |
Example
Result
| Array hmap::color_match_mask | ( | const Array & | r, |
| const Array & | g, | ||
| const Array & | b, | ||
| const glm::vec3 & | color, | ||
| float | tolerance = 0.f ) |
Create a mask of pixels matching a target color within a tolerance.
| r | Red channel array. |
| g | Green channel array. |
| b | Blue channel array. |
| color | Target RGB color. |
| tolerance | Allowed color difference (0 = exact match). |
Example
Result
See unit tests: test_color_match_mask.cpp
| Texture hmap::colorize | ( | const Array & | array, |
| float | vmin, | ||
| float | vmax, | ||
| int | cmap, | ||
| bool | hillshading, | ||
| bool | reverse = false, | ||
| const Array * | p_noise = nullptr ) |
Apply colorization to an array.
This function applies a colormap to the input array and optionally applies hillshading and noise. The colorization can be reversed, and the function returns a Tensor representing the colorized image.
| array | Input array to be colorized. |
| vmin | Minimum value for scaling the colormap. |
| vmax | Maximum value for scaling the colormap. |
| cmap | Colormap to be applied (using the Cmap enum). |
| hillshading | Boolean flag to apply hillshading. |
| reverse | Boolean flag to reverse the colormap (default is false). |
| p_noise | Optional pointer to a noise array (default is nullptr). |
| Texture hmap::colorize | ( | const Array & | array, |
| float | vmin, | ||
| float | vmax, | ||
| const std::vector< float > & | positions, | ||
| const std::vector< glm::vec3 > & | colormap_colors, | ||
| bool | reverse = false, | ||
| const Array * | p_noise = nullptr ) |
Colorize a scalar field into a Texture using a custom colormap.
| array | Input scalar values. |
| vmin | Lower bound for normalization. |
| vmax | Upper bound for normalization. |
| positions | Normalized color positions. |
| colormap_colors | RGB(A) colors per position. |
| reverse | Reverse colormap mapping. |
| p_noise | Optional noise for dithering. |
Example
| Texture hmap::colorize_bivariate | ( | const Array & | a1, |
| const Array & | a2, | ||
| const glm::vec2 | range1, | ||
| const glm::vec2 | range2, | ||
| const std::vector< float > & | positions1, | ||
| const std::vector< float > & | positions2, | ||
| const std::vector< glm::vec3 > & | colormap_colors1, | ||
| const std::vector< glm::vec3 > & | colormap_colors2, | ||
| MixMethod | method = MM_SQRT_AVG, | ||
| bool | reverse1 = false, | ||
| bool | reverse2 = false, | ||
| const Array * | p_noise1 = nullptr, | ||
| const Array * | p_noise2 = nullptr ) |
Colorize two scalar fields into a Texture using two custom colormaps and a color mixing method.
Each scalar field is independently normalized using its corresponding range and mapped to a color using its custom colormap. The two resulting colors are then combined according to the specified mixing method.
| a1 | First input scalar field. |
| a2 | Second input scalar field. |
| range1 | Lower and upper bounds for normalization of the first field. |
| range2 | Lower and upper bounds for normalization of the second field. |
| positions1 | Normalized color positions for the first colormap. |
| positions2 | Normalized color positions for the second colormap. |
| colormap_colors1 | RGB colors for the first colormap. |
| colormap_colors2 | RGB colors for the second colormap. |
| method | Method used to mix the two resulting colors. |
| reverse1 | Reverse the first colormap mapping. |
| reverse2 | Reverse the second colormap mapping. |
| p_noise1 | Optional noise added to the first scalar field before normalization. |
| p_noise2 | Optional noise added to the second scalar field before normalization. |
Example
Result
Colorizes a slope height heatmap based on the gradient norms of a given array.
This function computes a colorized heatmap using a two-dimensional histogram that considers the gradient norm of the input array. It normalizes both the input array values and their corresponding gradient norms, calculates a 2D histogram, and then applies a colormap to visualize the heatmap.
| array | The input array for which the slope height heatmap is computed. This should be a 2D array representing height values. |
| cmap | An integer representing the colormap to be used for colorization. Colormap options depend on the colorization function used internally. |
Example
Result
Combine two arrays into a colored image.
This function takes two input arrays and combines them into a single 8-bit colored Texture image. The resulting image uses the data from both arrays to create a composite color representation.
| array1 | First input array. |
| array2 | Second input array. |
Example
Result
Compute luminance from a Texture.
Computes a grayscale luminance array from the RGB channels of a texture.
| tex | Input texture (expects at least 3 channels). |
Example
Result
| Texture hmap::mix | ( | const Texture & | tex1, |
| const Texture & | tex2, | ||
| MixMethod | method = MM_SQRT_AVG ) |
Mix two textures into an output texture.
| tex1 | First input texture. |
| tex2 | Second input texture. |
| method | Mixing method to use. |
Example
Result
| Texture hmap::mix | ( | const Texture & | tex1, |
| const Texture & | tex2, | ||
| const Array & | mask, | ||
| MixMethod | method = MM_SQRT_AVG, | ||
| float | gain = 1.f ) |
Mix two textures based on a transparency mask.
Blends tex1 and tex2 according to the values in mask. When mask is 0, tex1 is selected; when mask is 1, tex2 is selected. If gain is different from 1.0, a gain curve is applied to the mask beforehand.
| tex1 | First input texture (background). |
| tex2 | Second input texture (foreground). |
| mask | Transparency mask array with values in [0, 1]. |
| method | Mixing method to use (default: MM_SQRT_AVG). |
| gain | Gain factor applied to the mask when != 1.0 (default: 1.0). |
| Texture hmap::mix | ( | const std::vector< const Texture * > & | texs, |
| MixMethod | method = MM_SQRT_AVG ) |
Mix a list of textures sequentially.
| texs | Input list of textures. |
| method | Mixing method to use. |
| Texture hmap::mix_normal_map | ( | const Texture & | nmap_base, |
| const Texture & | nmap_detail, | ||
| float | detail_scaling, | ||
| NormalMapBlendingMethod | blending_method ) |
Blend two normal maps into a single output normal map.
Combines a base normal map with a detail normal map using the specified blending method and scaling factor.
| nmap_base | Base normal map texture. |
| nmap_detail | Detail normal map texture. |
| detail_scaling | Strength of the detail normal map. |
| blending_method | Normal map blending method. |
| glm::vec3 hmap::shade_color | ( | const glm::vec3 & | color, |
| float | t ) |
Adjust color by shading parameter t clamped to [0, 1].
Darker and richer for t approaching 0, lighter and duller for t approaching 1.
| color | Input RGB color. |
| t | Shading parameter (clamped to [0, 1]). |
| void hmap::shade_topographic_residual | ( | Texture & | tex, |
| const Array & | z, | ||
| int | ir, | ||
| float | strength = 1.0f ) |
Apply shade_color to a Texture based on topographic residuals of an elevation array.
Computes normalized topographic residual on the input elevation array z with smoothing radius ir, scales the normalized residual [-1, 1] by strength into shading factors in [0, 1], and applies shade_color to tex.
| tex | Texture to be shaded in-place (must have at least 3 channels). |
| z | Elevation array with same 2D shape as tex. |
| ir | Radius for topographic residual smoothing filter. |
| strength | Strength of residual shading (default is 1.f). |
| Texture hmap::terrain_texture | ( | const Array & | z, |
| const Array * | p_deposition = nullptr, | ||
| const Array * | p_snow_depth = nullptr, | ||
| const TerrainTextureParams & | params = TerrainTextureParams(), | ||
| const BBox2D & | bbox = BBox2D::unit(), | ||
| const Array * | p_noise = nullptr, | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Generate a procedural terrain texture from elevation and surface analysis.
Combines slopes, ridges, flow accumulation, deposition, and noise octaves into an RGBA color Texture.
| z | Elevation input array. |
| p_deposition | Optional deposition array (may be nullptr). |
| p_snow_depth | Optional snow depth array (may be nullptr). |
| params | Terrain texturing parameters. |
| bbox | Bounding box for coherent noise coordinates. |
| p_noise | Optional custom noise array (bypasses procedural noise if provided). |
| comm | Communicator for collective normalization across tiles. |
| std::vector< glm::vec3 > hmap::get_colormap_data | ( | int | cmap | ) |
| std::string hmap::to_string | ( | ReduceOp | op | ) |
Computes a signed level-set curvature.
| array | Input array. |
| prefilter_ir | Optional smoothing radius for curvature evaluation. |
See unit tests: test_level_set_curvature.cpp
| Array hmap::curvature_quadric | ( | const Array & | z, |
| int | ir, | ||
| CurvatureType | curvature_type ) |
Compute curvature measures on a scalar field.
Computes various curvature descriptors from the input array z. If ir == 0, local derivatives (3×3 stencil) are used. Otherwise, a quadric surface is fitted over a (2·ir+1) window.
| z | Input scalar field (e.g. heightmap) |
| ir | Neighborhood radius (0 for local, >0 for quadric fit) |
| curvature_type | Type of curvature to compute. |
Example
Result
| void hmap::aeolian_erosion | ( | Array & | z, |
| int | steps = 300, | ||
| std::uint32_t | seed = 1337u, | ||
| glm::vec2 | wind = {3.f, 0.f}, | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_vegetation = nullptr, | ||
| const Array * | p_abrasion_mask = nullptr, | ||
| Array * | p_sediment_map = nullptr, | ||
| Array * | p_bedrock_map = nullptr, | ||
| float | cell_size = -1.f, | ||
| float | matter_to_move = 0.001f, | ||
| int | samples_per_step = 0, | ||
| float | sand_repose_angle = 33.f, | ||
| float | shadow_angle_min = 5.f, | ||
| float | shadow_angle_max = 15.f, | ||
| float | max_shadow_dist = 12.f, | ||
| float | abrasion_rate = 0.f, | ||
| float | repose_rate = 0.35f, | ||
| int | sync_interval = 0, | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance(), | ||
| int | shadow_map_interval = 1, | ||
| int | repose_interval = 2 ) |
Simulates wind-driven aeolian terrain erosion, sand transport, and dune dynamics on GPU.
This algorithm is adapted from the research by Axel Paris, Adrien Peytavie, Eric Guérin, Oscar Argudo, and Eric Galin (Pacific Graphics 2019 / Computer Graphics Forum), "Desertscapes Simulation".
It simulates:
| z | Input/output total elevation heightmap (modified in-place). On output, z equals bedrock + sediment. |
| steps | Number of simulation iterations. |
| seed | Random seed for stochastic sampling. |
| wind | Base wind direction vector (in grid units). |
| p_bedrock | Optional input bedrock elevation array. If null, bedrock is initialized to zero. |
| p_vegetation | Optional vegetation density mask in [0, 1]. |
| p_abrasion_mask | Optional rock erodibility/susceptibility mask in [0, 1]. |
| p_sediment_map | Optional output array receiving final sand thickness. |
| p_bedrock_map | Optional output array receiving final bedrock elevation. |
| cell_size | Horizontal grid spacing in world units. If <= 0, defaults to 1.f / z.shape.x. |
| matter_to_move | Volume/height of sand grain packet displaced per hop. |
| samples_per_step | Number of stochastic saltation samples evaluated per step. If <= 0, defaults to total cell count (nx * ny). |
| sand_repose_angle | Angle of repose for loose sediment (in degrees, typically ~33°). |
| shadow_angle_min | Minimum wind shadow angle threshold (in degrees, typically ~5°). |
| shadow_angle_max | Maximum wind shadow angle threshold (in degrees, typically ~15°). |
| max_shadow_dist | Maximum raymarch distance for wind shadow detection (in grid cells). |
| abrasion_rate | Abrasion wear rate on exposed bedrock (0 to disable). |
| repose_rate | Rate of sediment redistribution during repose stabilization. |
| sync_interval | Number of simulation steps between communicator tile syncs. |
| region | Tile region geometry metadata. |
| comm | Tiled communicator instance. |
| shadow_map_interval | If > 0, wind shadows are precomputed on a grid every shadow_map_interval steps and looked up by the walkers, instead of ray-marching per walker hop. Much faster, at the cost of a slightly approximate (stale and interpolated) shadow. 0 keeps the exact per-walker ray-marching. |
| repose_interval | Number of simulation steps between angle-of-repose stabilization passes. |
Example
Result
| void hmap::aeolian_erosion_multiscale | ( | Array & | z, |
| int | steps = 300, | ||
| std::uint32_t | seed = 1337u, | ||
| glm::vec2 | wind = {3.f, 0.f}, | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_vegetation = nullptr, | ||
| const Array * | p_abrasion_mask = nullptr, | ||
| Array * | p_sediment_map = nullptr, | ||
| Array * | p_bedrock_map = nullptr, | ||
| float | cell_size = -1.f, | ||
| float | matter_to_move = 0.001f, | ||
| float | sand_repose_angle = 33.f, | ||
| float | shadow_angle_min = 5.f, | ||
| float | shadow_angle_max = 15.f, | ||
| float | max_shadow_dist = 12.f, | ||
| float | abrasion_rate = 0.f, | ||
| float | repose_rate = 0.35f, | ||
| int | levels = 3, | ||
| float | coarse_fraction = 0.7f, | ||
| int | min_level_size = 64, | ||
| int | shadow_map_interval = 1, | ||
| int | repose_interval = 2 ) |
Multiscale (coarse-to-fine) variant of hmap::aeolian_erosion.
The simulation is first run on downsampled copies of the terrain, where each step is much cheaper (fewer cells and shorter shadow rays in cells), to develop the large-scale dune pattern. At each level, only the change in sediment (and bedrock) is upsampled and added to the full-resolution layers so that fine details of the input are preserved. The last steps are run at full resolution to restore small-scale features.
| z | Input/output total elevation (bedrock + sediment). |
| steps | Total number of steps at full resolution (steps are distributed across the levels). |
| seed | Random seed. |
| wind | Base wind vector (reference grid of 256). |
| p_bedrock | Optional bedrock elevation. |
| p_vegetation | Optional vegetation density in [0, 1]. |
| p_abrasion_mask | Optional abrasion susceptibility in [0, 1]. |
| p_sediment_map | Optional output sediment thickness. |
| p_bedrock_map | Optional output bedrock elevation. |
| cell_size | Full-resolution cell size (<= 0 for 1 / z.shape.x). |
| matter_to_move | Sand packet displaced per hop. |
| sand_repose_angle | Angle of repose (degrees). |
| shadow_angle_min | Minimum wind shadow angle (degrees). |
| shadow_angle_max | Maximum wind shadow angle (degrees). |
| max_shadow_dist | Maximum shadow raymarch distance (reference grid). |
| abrasion_rate | Bedrock abrasion rate (0 to disable). |
| repose_rate | Repose stabilization rate. |
| levels | Number of resolution levels (1 = single-scale). Each level halves the resolution. |
| coarse_fraction | Fraction in [0, 1) of the steps spent on coarse levels (shared equally); the remainder is run at full resolution. |
| min_level_size | Smallest allowed size of a coarse level (levels that would be smaller are dropped). |
| shadow_map_interval | See hmap::aeolian_erosion (0 = exact shadows). |
| repose_interval | See hmap::aeolian_erosion. |
| void hmap::coastal_erosion_diffusion | ( | Array & | z, |
| Array & | water_depth, | ||
| float | additional_depth, | ||
| int | iterations = 10, | ||
| const Array * | p_mask = nullptr, | ||
| Array * | p_water_mask = nullptr ) |
Simulates terrain diffusion due to coastal erosion.
This function applies an iterative coastal erosion diffusion process on a terrain elevation array (z), taking into account the presence and depth of water. The erosion model smooths the terrain near shorelines while maintaining constant water-surface height.
At each iteration:
This results in a realistic simulation of coastal erosion processes where the terrain near the waterline is progressively smoothed and redistributed.
| z | Reference to the terrain elevation array (modified in place). |
| water_depth | Reference to the array representing water depth values (modified to preserve water surface level). |
| additional_depth | Additional virtual water depth used to estimate the influence region of the shoreline during mask computation. |
| iterations | Number of erosion–diffusion iterations to apply. |
| p_mask | Optional intensity mask in [0, 1]. |
| p_water_mask | Optional output pointer. If non-null, it receives the last computed water mask used during the final iteration. |
Example
Result
| void hmap::coastal_erosion_profile | ( | Array & | z, |
| Array & | water_depth, | ||
| float | shore_ground_extent, | ||
| float | shore_water_extent, | ||
| float | slope_shore = 0.5f, | ||
| float | slope_shore_water = 0.5f, | ||
| float | scarp_extent_ratio = 0.5f, | ||
| bool | apply_post_filter = true, | ||
| int | post_filter_iterations = 3, | ||
| bool | solid_shore_mask = true, | ||
| float | scarp_mask_transition_ratio = 0.2f, | ||
| const Array * | p_noise = nullptr, | ||
| Array * | p_shore_mask = nullptr, | ||
| Array * | p_scarp_mask = nullptr ) |
Applies a coastal erosion profile to a terrain elevation field.
This function modifies the elevation array z by carving a coastal profile at the interface between ground and water. It uses distance transforms both from ground regions and from water regions to determine how far each point is from the shoreline. According to this distance, the function applies:
Water depth is adjusted after filtering to preserve the original water surface height.
Optionally, a shoreline mask can be returned describing the region influenced by the coastal transformation.
| z | Array of terrain elevations. Modified in-place. |
| water_depth | Array of water depths. Modified to preserve water surface height after terrain changes. |
| shore_ground_extent | Horizontal extent (in grid units) over which the ground-side shore profile is applied. |
| shore_water_extent | Horizontal extent (in grid units) over which the underwater profile is applied. |
| slope_shore | Ground-side slope magnitude of the coastal profile. Expressed in elevation units per domain width. |
| slope_shore_water | Water-side slope magnitude of the underwater profile. Expressed similarly to slope_shore. |
| scarp_extent_ratio | Ratio defining the relative extent of the scarp region. A value in [0,1]:
|
| apply_post_filter | If true, applies Laplacian smoothing to z restricted to shoreline areas. |
| post_filter_iterations | Iterations for post-smoothing filter. |
| solid_shore_mask | Whether shore mask is solid. |
| scarp_mask_transition_ratio | Smooth transition ratio for scarp mask. |
| p_noise | Optional noise array. |
| p_shore_mask | Optional output pointer. If non-null, receives the shoreline mask (values in [0,1]) indicating where the coastal transformation was applied. |
| p_scarp_mask | Optional output pointer for scarp mask. |
Example
Result
| void hmap::coastal_erosion_profile | ( | Array & | z, |
| const Array * | p_mask, | ||
| Array & | water_depth, | ||
| float | shore_ground_extent, | ||
| float | shore_water_extent, | ||
| float | slope_shore = 0.5f, | ||
| float | slope_shore_water = 0.5f, | ||
| float | scarp_extent_ratio = 0.5f, | ||
| bool | apply_post_filter = true, | ||
| int | post_filter_iterations = 3, | ||
| bool | solid_shore_mask = true, | ||
| float | scarp_mask_transition_ratio = 0.2f, | ||
| const Array * | p_noise = nullptr, | ||
| Array * | p_shore_mask = nullptr, | ||
| Array * | p_scarp_mask = nullptr ) |
| void hmap::hydraulic_algebric | ( | Array & | z, |
| Array * | p_mask, | ||
| float | talus_ref, | ||
| int | ir, | ||
| Array * | p_bedrock = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr, | ||
| float | c_erosion = 0.05f, | ||
| float | c_deposition = 0.05f, | ||
| int | iterations = 1 ) |
Apply an algerbic formula based on the local gradient to perform erosion/deposition.
| z | Input array. |
| p_mask | Intensity mask, expected in [0, 1] (applied as a post-processing). |
| talus_ref | Reference talus. |
| ir | Smoothing prefilter radius. |
| p_bedrock | Reference to the bedrock heightmap. |
| p_erosion_map[out] | Reference to the erosion map, provided as an output field. |
| p_deposition_map | [out] Reference to the deposition map, provided as an output field. |
| c_erosion | Erosion coefficient. |
| c_deposition | Deposition coefficient. |
| iterations | Number of iterations. |
Example
Result
| void hmap::hydraulic_algebric | ( | Array & | z, |
| float | talus_ref, | ||
| int | ir, | ||
| Array * | p_bedrock = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr, | ||
| float | c_erosion = 0.05f, | ||
| float | c_deposition = 0.05f, | ||
| int | iterations = 1 ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::hydraulic_benes | ( | Array & | z, |
| Array * | p_mask, | ||
| int | iterations = 50, | ||
| Array * | p_bedrock = nullptr, | ||
| Array * | p_moisture_map = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr, | ||
| float | c_capacity = 40.f, | ||
| float | c_erosion = 0.2f, | ||
| float | c_deposition = 0.8f, | ||
| float | water_level = 0.005f, | ||
| float | evap_rate = 0.01f, | ||
| float | rain_rate = 0.5f ) |
Apply cell-based hydraulic erosion/deposition based on Benes et al. procedure.
See [Benes2002] and [Olsen2004].
| z | Input array. |
| p_mask | Intensity mask, expected in [0, 1] (applied as a post-processing). |
| iterations | Number of iterations. |
| p_bedrock | Reference to the bedrock heightmap. |
| p_moisture_map | Reference to the moisture map (quantity of rain), expected to be in [0, 1]. |
| p_erosion_map[out] | Reference to the erosion map, provided as an output field. |
| p_deposition_map | [out] Reference to the deposition map, provided as an output field. |
| c_capacity | Sediment capacity. |
| c_erosion | Erosion coefficient. |
| c_deposition | Deposition coefficient. |
| water_level | Water level. |
| evap_rate | Water evaporation rate. |
| rain_rate | Rain relaxation rate. |
Example
Result
| void hmap::hydraulic_benes | ( | Array & | z, |
| int | iterations = 50, | ||
| Array * | p_bedrock = nullptr, | ||
| Array * | p_moisture_map = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr, | ||
| float | c_capacity = 40.f, | ||
| float | c_erosion = 0.2f, | ||
| float | c_deposition = 0.8f, | ||
| float | water_level = 0.005f, | ||
| float | evap_rate = 0.01f, | ||
| float | rain_rate = 0.5f ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply cell-based hydraulic erosion using a nonlinear diffusion model.
| z | Input array. |
| radius | Gaussian filter radius (with respect to a unit domain). |
| vmax | Maximum elevation for the details. |
| k_smoothing | Smoothing factor, if any. |
Example
Result
| void hmap::hydraulic_diffusion | ( | Array & | z, |
| float | c_diffusion, | ||
| float | talus, | ||
| int | iterations ) |
Apply cell-based hydraulic erosion using a nonlinear diffusion model.
See [Roering2001].
| z | Input array. |
| c_diffusion | Diffusion coefficient. |
| talus | Reference talus (must be higher than the maximum talus of the map). |
| iterations | Number of iterations. |
Example
Result
| void hmap::hydraulic_musgrave | ( | Array & | z, |
| Array & | moisture_map, | ||
| int | iterations = 100, | ||
| float | c_capacity = 1.f, | ||
| float | c_erosion = 0.1f, | ||
| float | c_deposition = 0.1f, | ||
| float | water_level = 0.01f, | ||
| float | evap_rate = 0.01f ) |
Apply cell-based hydraulic erosion/deposition of Musgrave et al. (1989).
A simple grid-based erosion technique was published by Musgrave, Kolb, and Mace in 1989 [Musgrave1989].
| z | Input array. |
| moisture_map | Moisture map (quantity of rain), expected to be in [0, 1]. |
| iterations | Number of iterations. |
| c_capacity | Sediment capacity. |
| c_deposition | Deposition coefficient. |
| c_erosion | Erosion coefficient. |
| water_level | Water level. |
| evap_rate | Water evaporation rate. |
Example
Result
| void hmap::hydraulic_musgrave | ( | Array & | z, |
| int | iterations = 100, | ||
| float | c_capacity = 1.f, | ||
| float | c_erosion = 0.1f, | ||
| float | c_deposition = 0.1f, | ||
| float | water_level = 0.01f, | ||
| float | evap_rate = 0.01f ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::hydraulic_stream | ( | Array & | z, |
| float | c_erosion, | ||
| float | talus_ref, | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_moisture_map = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| int | ir = 1, | ||
| float | clipping_ratio = 10.f ) |
Apply hydraulic erosion based on a flow accumulation map.
| z | Input array. |
| c_erosion | Erosion coefficient. |
| talus_ref | Reference talus used to localy define the flow-partition exponent (small values of talus_ref will lead to thinner flow streams, see flow_accumulation_dinf). |
| p_bedrock | Lower elevation limit. |
| p_moisture_map | Reference to the moisture map (quantity of rain), expected to be in [0, 1]. |
| p_erosion_map[out] | Reference to the erosion map, provided as an output field. |
| ir | Kernel radius. If ir > 1, a cone kernel is used to carv channel flow erosion. |
| clipping_ratio | Flow accumulation clipping ratio. |
Example
Result
| void hmap::hydraulic_stream | ( | Array & | z, |
| const Array * | p_mask, | ||
| float | c_erosion, | ||
| float | talus_ref, | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_moisture_map = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| int | ir = 1, | ||
| float | clipping_ratio = 10.f ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::hydraulic_stream_log | ( | Array & | z, |
| float | c_erosion, | ||
| float | talus_ref, | ||
| int | deposition_ir = 32, | ||
| float | deposition_scale_ratio = 1.f, | ||
| float | gradient_power = 0.8f, | ||
| float | gradient_scaling_ratio = 1.f, | ||
| int | gradient_prefilter_ir = 16, | ||
| float | saturation_ratio = 1.f, | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_erodibility = nullptr, | ||
| const Array * | p_moisture_map = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr, | ||
| Array * | p_flow_map = nullptr ) |
Apply hydraulic erosion based on a flow accumulation map, alternative formulation.
| z | Input array representing the terrain elevation. |
| c_erosion | Erosion coefficient controlling the intensity of erosion. |
| talus_ref | Reference talus used to locally define the flow-partition exponent. Small values lead to thinner flow streams (see flow_accumulation_dinf). |
| deposition_ir | Kernel radius for sediment deposition. If greater than 1, a smoothing effect is applied. |
| deposition_scale_ratio | Scaling factor for sediment deposition. |
| gradient_power | Exponent applied to the terrain gradient to control erosion intensity. |
| gradient_scaling_ratio | Scaling factor for gradient-based erosion. |
| gradient_prefilter_ir | Kernel radius for pre-filtering the terrain gradient. |
| saturation_ratio | Ratio controlling the water saturation threshold for erosion processes. |
| p_bedrock | Pointer to an optional lower elevation limit. |
| p_moisture_map | Pointer to the moisture map (rainfall quantity), expected to be in [0, 1]. |
| p_erosion_map[out] | Pointer to the erosion map, provided as an output field. |
| p_flow_map[out] | Pointer to the flow accumulation map, provided as an output field. |
| ir | Kernel radius. If ir > 1, a cone kernel is used to carve channel flow erosion. |
Example
Result
| void hmap::hydraulic_stream_log | ( | Array & | z, |
| float | c_erosion, | ||
| float | talus_ref, | ||
| const Array * | p_mask, | ||
| int | deposition_ir = 32, | ||
| float | deposition_scale_ratio = 1.f, | ||
| float | gradient_power = 0.8f, | ||
| float | gradient_scaling_ratio = 1.f, | ||
| int | gradient_prefilter_ir = 16, | ||
| float | saturation_ratio = 1.f, | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_erodibility = nullptr, | ||
| const Array * | p_moisture_map = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr, | ||
| Array * | p_flow_map = nullptr ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::hydraulic_stream_log_multiscale | ( | Array & | z, |
| float | c_erosion, | ||
| float | talus_ref, | ||
| int | levels = 3, | ||
| int | deposition_ir = 32, | ||
| float | deposition_scale_ratio = 1.f, | ||
| float | gradient_power = 0.8f, | ||
| float | gradient_scaling_ratio = 1.f, | ||
| int | gradient_prefilter_ir = 16, | ||
| float | saturation_ratio = 1.f, | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_erodibility = nullptr, | ||
| const Array * | p_moisture_map = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr, | ||
| Array * | p_flow_map = nullptr, | ||
| float | mix = 1.f, | ||
| float | warp = 0.35f, | ||
| std::uint32_t | seed = 1 ) |
Multiscale stream-power hydraulic erosion cascade.
Runs stream-power erosion over a geometric resolution ladder (coarsest first, up to z.shape). Coarse levels carve broad valleys and major drainage networks, while fine levels carve detailed tributaries.
| z | Heightmap array to modify. |
| c_erosion | Erosion coefficient. |
| talus_ref | Reference talus. |
| levels | Number of resolution levels. |
| deposition_ir | Deposition smoothing radius at full resolution. |
| deposition_scale_ratio | Deposition blend factor (applied at last scale). |
| gradient_power | Power applied to normalized gradient. |
| gradient_scaling_ratio | Gradient scaling weight. |
| gradient_prefilter_ir | Gradient prefilter smoothing radius at full resolution. |
| saturation_ratio | Flow saturation ratio. |
| p_bedrock | Optional bedrock array bounding maximum erosion depth. |
| p_erodibility | Optional spatial erodibility multiplier array. |
| p_moisture_map | Optional moisture map. |
| p_erosion_map | Optional output erosion map. |
| p_deposition_map | Optional output deposition map. |
| p_flow_map | Optional output flow accumulation map. |
| mix | Interpolation blend factor between levels. |
| warp | Domain warp amplitude during upsampling. |
| seed | Random seed for domain warping noise. |
| void hmap::hydraulic_stream_log_multiscale | ( | Array & | z, |
| float | c_erosion, | ||
| float | talus_ref, | ||
| const Array * | p_mask, | ||
| int | levels = 3, | ||
| int | deposition_ir = 32, | ||
| float | deposition_scale_ratio = 1.f, | ||
| float | gradient_power = 0.8f, | ||
| float | gradient_scaling_ratio = 1.f, | ||
| int | gradient_prefilter_ir = 16, | ||
| float | saturation_ratio = 1.f, | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_erodibility = nullptr, | ||
| const Array * | p_moisture_map = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr, | ||
| Array * | p_flow_map = nullptr, | ||
| float | mix = 1.f, | ||
| float | warp = 0.35f, | ||
| std::uint32_t | seed = 1 ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::hydraulic_saleve | ( | TerrainTriMesh & | mesh, |
| const std::vector< float > & | erodibility, | ||
| const std::vector< float > & | max_slope, | ||
| float | m_exp = 0.8f, | ||
| float | uplift_rate = 1.f, | ||
| float | tolerance = 1e-3f, | ||
| int | max_iterations = 200, | ||
| float | noise_strength = 0.f, | ||
| std::uint32_t | seed = 0, | ||
| bool | enable_post_slope_limiter = false, | ||
| float | post_slope_limit = 0.f, | ||
| bool | enable_post_smoothing = false ) |
Perform hydraulic erosion on a triangulated terrain mesh.
Iteratively updates elevations using a drainage model with uplift, slope constraints, and spatially varying erodibility.
| mesh | Input/output terrain mesh. |
| erodibility | Per-vertex erodibility coefficients. |
| max_slope | Per-vertex maximum slope constraint. |
| m_exp | Exponent controlling flow response. |
| uplift_rate | Constant uplift applied each iteration. |
| tolerance | Convergence threshold on elevation updates. |
| max_iterations | Maximum number of erosion iterations. |
Example
Result
| Array hmap::hydraulic_saleve | ( | const Array & | z, |
| std::uint32_t | seed, | ||
| size_t | control_points_count = 10000, | ||
| float | m_exp = 0.8f, | ||
| float | uplift_rate = 1.f, | ||
| float | tolerance = 1e-3f, | ||
| int | max_iterations = 200, | ||
| float | smin = 0.f, | ||
| float | smax = 6.f, | ||
| float | strength = 0.5f, | ||
| bool | scale_erodibility_with_z = true, | ||
| float | erodibility_distrib_exp = 1.f, | ||
| float | noise_strength = 0.f, | ||
| bool | enable_post_slope_limiter = false, | ||
| float | post_slope_limit = 0.f, | ||
| bool | enable_post_smoothing = false, | ||
| InterpolationMethod2D | interpolation_method = InterpolationMethod2D::ITP2D_DELAUNAY_GRADIENT, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
Apply hydraulic erosion to a heightmap using an adaptive mesh.
Converts the input heightmap to a triangulated mesh, performs erosion, and interpolates the result back to a grid.
| z | Input heightmap. |
| seed | Random seed for point sampling. |
| control_points_count | Number of mesh control points. |
| m_exp | Flow response exponent. |
| uplift_rate | Constant uplift per iteration. |
| tolerance | Convergence threshold. |
| max_iterations | Maximum number of iterations. |
| smin | Minimum slope constraint. |
| smax | Maximum slope constraint. |
| strength | Blending factor between original and eroded terrain. |
| scale_erodibility_with_z | Modulate erodibility with elevation. |
| erodibility_distrib_exp | Exponent for erodibility distribution. |
| p_noise_x | Optional X displacement field. |
| p_noise_y | Optional Y displacement field. |
Example
Result
| Array hmap::hydraulic_saleve | ( | const Array & | z, |
| const Array * | p_mask, | ||
| std::uint32_t | seed, | ||
| size_t | control_points_count = 10000, | ||
| float | m_exp = 0.8f, | ||
| float | uplift_rate = 1.f, | ||
| float | tolerance = 1e-3f, | ||
| int | max_iterations = 200, | ||
| float | smin = 0.f, | ||
| float | smax = 6.f, | ||
| float | strength = 0.5f, | ||
| bool | scale_erodibility_with_z = true, | ||
| float | erodibility_distrib_exp = 1.f, | ||
| float | noise_strength = 0.f, | ||
| bool | enable_post_slope_limiter = false, | ||
| float | post_slope_limit = 0.f, | ||
| bool | enable_post_smoothing = false, | ||
| InterpolationMethod2D | interpolation_method = InterpolationMethod2D::ITP2D_DELAUNAY_GRADIENT, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::depression_filling | ( | Array & | z, |
| int | iterations = 1000, | ||
| float | epsilon = 1e-4f, | ||
| bool | outflow_left = true, | ||
| bool | outflow_right = true, | ||
| bool | outflow_bottom = true, | ||
| bool | outflow_top = true, | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Fill the depressions of the heightmap using the Planchon-Darboux algorithm.
Fill heightmap depressions to ensure that every cell can be connected to the boundaries following a downward slope [Planchon2002].
| z | Input array. |
| iterations | Number of iterations. |
| epsilon | Epsilon slope parameter. |
| outflow_left | Allow outflow on left boundary (i = 0). |
| outflow_right | Allow outflow on right boundary (i = nx - 1). |
| outflow_bottom | Allow outflow on bottom boundary (j = 0). |
| outflow_top | Allow outflow on top boundary (j = ny - 1). |
| region | Tile region metadata (for tiled execution). |
| comm | Communicator for multi-tile synchronization. |
Example
Result
| void hmap::depression_filling_priority_flood | ( | Array & | z, |
| bool | apply_post_filter = false, | ||
| bool | outflow_left = true, | ||
| bool | outflow_right = true, | ||
| bool | outflow_bottom = true, | ||
| bool | outflow_top = true, | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Fill depressions in a heightmap using the Priority-Flood algorithm.
| z | Input heightmap array. |
| apply_post_filter | Apply Laplacian smoothing to deposition. |
| outflow_left | Allow outflow on left boundary (i = 0). |
| outflow_right | Allow outflow on right boundary (i = nx - 1). |
| outflow_bottom | Allow outflow on bottom boundary (j = 0). |
| outflow_top | Allow outflow on top boundary (j = ny - 1). |
| region | Tile region metadata (for tiled execution). |
| comm | Communicator for multi-tile synchronization. |
| void hmap::erosion_maps | ( | Array & | z_before, |
| Array & | z_after, | ||
| Array & | erosion_map, | ||
| Array & | deposition_map, | ||
| float | tolerance = 0.f ) |
Computes erosion and deposition delta maps from terrain states before and after erosion.
| z_before | Input array (before erosion). |
| z_after | Input array (after erosion). |
| erosion_map | Erosion map. |
| deposition_map | Deposition map. |
| tolerance | Tolerance for erosion / deposition definition. |
Example
Result
| Array hmap::generate_bedrock | ( | const Array & | z, |
| float | elevation_strength, | ||
| float | slope_strength, | ||
| float | slope_limit, | ||
| float | zmin = 0.f, | ||
| float | zmax = -1.f ) |
Generates a modified bedrock heightmap from an input elevation array.
This function adjusts elevations based on overall height and local slope:
| z | Input elevation array. |
| elevation_strength | Strength of elevation-based adjustment. |
| slope_strength | Strength of slope-based adjustment. |
| slope_limit | Slope threshold for slope-based adjustment. |
| zmin | Minimum elevation to consider (computed from z if zmin > zmax). |
| zmax | Maximum elevation to consider (computed from z if zmin > zmax). |
Example
Result
| void hmap::hydraulic_mise | ( | Array & | z, |
| const MiseParams & | params = MiseParams(), | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_erodibility = nullptr, | ||
| const Array * | p_moisture_map = nullptr, | ||
| const Array * | p_outlet = nullptr, | ||
| Array * | p_sediment = nullptr, | ||
| Array * | p_flow = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr ) |
Simulates multiscale implicit stream-power hydraulic erosion (MISE).
Adapted from MISE by Leonhard (https://github.com/Leonhardmaster2).
| z | Heightmap array to be eroded in-place. |
| params | Solver parameters. |
| p_bedrock | Optional bedrock array bounding maximum erosion depth. |
| p_erodibility | Optional spatial erodibility multiplier array. |
| p_moisture_map | Optional precipitation / moisture weight map. |
| p_outlet | Optional outlet mask (>0 flags fixed base-level cells). |
| p_sediment | Optional output array receiving loose sediment thickness. |
| p_flow | Optional output array receiving normalized drainage flow area. |
| p_erosion_map | Optional output array receiving erosion delta (z_before - z, >= 0). |
| p_deposition_map | Optional output array receiving deposition delta (z - z_before, >= 0). |
Example
Result
| void hmap::hydraulic_mise | ( | Array & | z, |
| const Array * | p_mask, | ||
| const MiseParams & | params = MiseParams(), | ||
| const Array * | p_bedrock = nullptr, | ||
| const Array * | p_erodibility = nullptr, | ||
| const Array * | p_moisture_map = nullptr, | ||
| const Array * | p_outlet = nullptr, | ||
| Array * | p_sediment = nullptr, | ||
| Array * | p_flow = nullptr, | ||
| Array * | p_erosion_map = nullptr, | ||
| Array * | p_deposition_map = nullptr ) |
Simulates multiscale implicit stream-power hydraulic erosion (MISE) with an intensity mask.
| z | Heightmap array to be eroded in-place. |
| p_mask | Intensity mask in [0, 1] used for blending post-erosion. |
| params | Solver parameters. |
| p_bedrock | Optional bedrock array bounding maximum erosion depth. |
| p_erodibility | Optional spatial erodibility multiplier array. |
| p_moisture_map | Optional precipitation / moisture weight map. |
| p_outlet | Optional outlet mask (>0 flags fixed base-level cells). |
| p_sediment | Optional output array receiving loose sediment thickness. |
| p_flow | Optional output array receiving normalized drainage flow area. |
| p_erosion_map | Optional output array receiving erosion delta (z_before - z, >= 0). |
| p_deposition_map | Optional output array receiving deposition delta (z - z_before, >= 0). |
| bool hmap::export_asset | ( | const std::string & | fname, |
| const Array & | array, | ||
| MeshType | mesh_type = MeshType::TRI, | ||
| AssetExportFormat | export_format = AssetExportFormat::GLB2, | ||
| float | elevation_scaling = 0.2f, | ||
| const std::string & | texture_fname = "", | ||
| const std::string & | normal_map_fname = "", | ||
| float | max_error = 5e-4f, | ||
| bool | fit_boundaries = false ) |
Exports a heightmap to various 3D file formats.
This function exports the input heightmap array as a 3D asset in the specified format. The export can include different mesh types, elevation scaling, and optional texture and normal maps. The function supports optimized Delaunay triangulation for mesh generation, with a configurable maximum error.
| fname | The name of the file to which the 3D asset will be exported. |
| array | The input heightmap array to be converted into a 3D asset. |
| mesh_type | The type of mesh to generate (see MeshType). |
| export_format | The format in which to export the asset (see AssetExportFormat). |
| elevation_scaling | A scaling factor applied to the elevation values of the heightmap. Default is 0.2f. |
| texture_fname | The name of the texture file to be applied to the asset (optional). |
| normal_map_fname | The name of the normal map file to be applied to the asset (optional). |
| max_error | The maximum allowable error for optimized Delaunay triangulation. Default is 5e-4f. |
| fit_boundaries | If true, domain coordinates are scaled to [0, 1] x [0, 1]. Default is false (domain scaled to [0, 1 - 1/shape.x] x [0, 1 - 1/shape.y]). |
| bool hmap::export_asset | ( | const std::string & | fname, |
| const Array & | array, | ||
| const Array & | mask, | ||
| AssetExportFormat | export_format = AssetExportFormat::GLB2, | ||
| float | elevation_scaling = 0.2f, | ||
| const std::string & | texture_fname = "", | ||
| const std::string & | normal_map_fname = "", | ||
| bool | fit_boundaries = false ) |
| void hmap::export_points_to_ply | ( | const std::string & | fname, |
| const std::vector< float > & | x, | ||
| const std::vector< float > & | y, | ||
| const std::vector< float > & | z, | ||
| const std::map< std::string, std::vector< float > > & | custom_fields = {} ) |
Exports 3D points with optional custom fields to an ASCII PLY file.
This function writes vertex data (x, y, z) and optional additional per-point attributes to a PLY file in ASCII format. Each key in custom_fields defines a new property in the PLY header, and its associated vector provides per-point values for that property.
| fname | The output file name. |
| x | Vector of x coordinates. |
| y | Vector of y coordinates. |
| z | Vector of z coordinates. |
| custom_fields | A map of custom field names to their per-point float values. |
Example
| void hmap::write_raw_16bit | ( | const std::string & | fname, |
| const Array & | array ) |
Exports an array to a 16-bit 'raw' file format, commonly used for Unity terrain imports.
This function saves the input array to a file in a 16-bit 'raw' format, which is suitable for importing heightmaps into Unity or other applications that support this format. The array values are converted and written to the file specified by fname.
| fname | The name of the file to which the array will be exported. |
| array | The input array containing the data to be exported. |
| std::string hmap::export_as_ascii | ( | const Array & | array, |
| const glm::ivec2 & | export_shape = {64, 64}, | ||
| const std::string | chars_map = " .:-=+*#%@" ) |
Export a 2D array as an ASCII-art string representation.
This function rescales the input array to a given export resolution, remaps its values to the [0,1] range, and then converts each value to a character from a user-provided character map. The characters are arranged row by row to form a textual representation of the array, similar to rendering a heightmap in ASCII.
| array | The input 2D array to be exported. |
| export_shape | The desired shape (width, height) of the ASCII output. |
| chars_map | A string containing characters ordered from "low" to "high" intensity. For example: " .:-=+*#%@" |
| void hmap::export_as_cubemap | ( | const std::string & | fname, |
| const Array & | z, | ||
| int | cubemap_resolution = 128, | ||
| float | overlap = 0.25f, | ||
| int | ir = 16, | ||
| Cmap | cmap = static_cast<Cmap>(0), | ||
| bool | splitted = false, | ||
| Array * | p_cubemap = nullptr ) |
Exports a 2D array as a cubemap texture with continuity enforcement and overlapping regions.
This function generates a cubemap texture from the input array z, resamples the data to fit the cubemap resolution with optional overlapping regions, and ensures seamless transitions between the six faces of the cubemap. The cubemap can either be saved as a single texture or split into individual face textures.
| fname | Output file name or base name for the cubemap files. |
| z | Input 2D array representing the data to be converted into a cubemap. |
| cubemap_resolution | Resolution (width and height) of each individual face of the cubemap. |
| overlap | Fraction (0 to 1) of overlap between adjacent faces to ensure smooth transitions. |
| ir | Radius parameter for smoothing at triple corners. |
| cmap | Colormap to be applied when exporting the textures. |
| splitted | If true, exports each face of the cubemap as a separate image; otherwise, exports the entire cubemap as a single texture. |
| p_cubemap | Pointer to an optional output array where the final cubemap data will be stored. |
The generated cubemap maintains continuity between faces, adjusting values at overlapping regions and corners using smooth transitions. If the splitted flag is set, six individual PNG images are generated for the cubemap faces with appropriate suffixes appended to the base name. Otherwise, the entire cubemap is exported as a single texture file.
Example
Result
| void hmap::export_banner_png | ( | const std::string & | fname, |
| const std::vector< Array > & | arrays, | ||
| int | cmap, | ||
| bool | hillshading = false, | ||
| bool | normalize_arrays = false ) |
Exports a set of arrays as a banner PNG image file.
This function takes a vector of arrays and exports them as a single banner PNG image. The arrays are displayed side by side in the image, using the specified colormap cmap. Optionally, hillshading can be applied to enhance the visual representation of the data.
| fname | The name of the file to which the banner image will be exported. |
| arrays | A vector of arrays to be included in the banner image. |
| cmap | An integer representing the colormap to be applied to the arrays. |
| hillshading | A boolean flag to activate hillshading for enhanced visual depth. Default is false. |
| bool hmap::export_image | ( | const Array & | array, |
| const std::string & | fname, | ||
| const ImageWriterConfig & | config = {} ) |
Exports an array using the generic ImageWriter pipeline.
| array | Input 2D array. |
| fname | Output file or directory path. |
| config | Optional writer configuration. |
| bool hmap::export_image | ( | const VirtualArray & | va, |
| const std::string & | fname, | ||
| const ImageWriterConfig & | config = {} ) |
Exports a VirtualArray incrementally using the generic ImageWriter pipeline.
| va | Input VirtualArray. |
| fname | Output file or directory path. |
| config | Optional writer configuration. |
| bool hmap::export_image | ( | const VirtualArray & | va, |
| const std::string & | fname, | ||
| const ImageWriterConfig & | config, | ||
| const ComputeMode & | cm ) |
Exports a VirtualArray incrementally with custom compute mode.
| va | Input VirtualArray. |
| fname | Output file or directory path. |
| config | Writer configuration. |
| cm | Compute mode for tile processing. |
| bool hmap::export_image | ( | const VirtualTexture & | vt, |
| const std::string & | fname, | ||
| const ImageWriterConfig & | config = {} ) |
Exports a VirtualTexture incrementally using the generic ImageWriter pipeline.
| vt | Input VirtualTexture. |
| fname | Output file or directory path. |
| config | Optional writer configuration. |
| bool hmap::export_image | ( | const VirtualTexture & | vt, |
| const std::string & | fname, | ||
| const ImageWriterConfig & | config, | ||
| const ComputeMode & | cm ) |
Exports a VirtualTexture incrementally with custom compute mode.
| vt | Input VirtualTexture. |
| fname | Output file or directory path. |
| config | Writer configuration. |
| cm | Compute mode for tile processing. |
| bool hmap::export_virtual_array | ( | const VirtualArray & | va, |
| ImageWriter & | writer ) |
Streams a VirtualArray tile-by-tile into an already opened ImageWriter.
| va | Input VirtualArray. |
| writer | Reference to target ImageWriter. |
| bool hmap::export_virtual_array | ( | const VirtualArray & | va, |
| ImageWriter & | writer, | ||
| const ComputeMode & | cm ) |
Streams a VirtualArray tile-by-tile into an already opened ImageWriter with custom compute mode.
| va | Input VirtualArray. |
| writer | Reference to target ImageWriter. |
| cm | Compute mode for tile processing. |
| bool hmap::export_virtual_array | ( | const VirtualTexture & | vt, |
| ImageWriter & | writer ) |
Streams a VirtualTexture tile-by-tile into an already opened ImageWriter.
| vt | Input VirtualTexture. |
| writer | Reference to target ImageWriter. |
| bool hmap::export_virtual_array | ( | const VirtualTexture & | vt, |
| ImageWriter & | writer, | ||
| const ComputeMode & | cm ) |
Streams a VirtualTexture tile-by-tile into an already opened ImageWriter with custom compute mode.
| vt | Input VirtualTexture. |
| writer | Reference to target ImageWriter. |
| cm | Compute mode for tile processing. |
| void hmap::export_normal_map_png | ( | const std::string & | fname, |
| const Array & | array, | ||
| int | depth = CV_8U ) |
Exports the heightmap normal map as an 8-bit PNG file.
This function generates a normal map from the input heightmap array and exports it as an 8-bit PNG image. The normal map can be used in 3D rendering engines to create realistic lighting and shading effects.
| fname | The name of the file to which the normal map will be exported. |
| array | The input heightmap array from which the normal map is derived. |
| depth | The depth of the PNG image, e.g., CV_8U for 8-bit or CV_16U for 16-bit. Default is CV_8U. |
Example
| void hmap::export_splatmap_png | ( | const std::string & | fname, |
| const Array * | p_r, | ||
| const Array * | p_g = nullptr, | ||
| const Array * | p_b = nullptr, | ||
| const Array * | p_a = nullptr, | ||
| int | depth = CV_8U ) |
Exports four arrays as an RGBA PNG splatmap.
This function combines four input arrays, representing the red (R), green (G), blue (B), and alpha (A) channels, into a single RGBA PNG image. The resulting splatmap can be used in applications like terrain texturing. The PNG image is saved to the specified file name fname. Channels G, B, and A are optional; if not provided, they will default to zero.
| fname | The name of the file to which the RGBA splatmap will be exported. |
| p_r | Pointer to the array representing the red (R) channel. |
| p_g | Pointer to the array representing the green (G) channel. Default is nullptr. |
| p_b | Pointer to the array representing the blue (B) channel. Default is nullptr. |
| p_a | Pointer to the array representing the alpha (A) channel. Default is nullptr. |
| depth | The depth of the PNG image, e.g., CV_8U for 8-bit or CV_16U for 16-bit. Default is CV_8U. |
Example
Result
| void hmap::export_tiled | ( | const std::string & | fname_radical, |
| const std::string & | fname_extension, | ||
| const Array & | array, | ||
| const glm::ivec2 & | tiling, | ||
| int | leading_zeros = 0, | ||
| int | depth = CV_8U, | ||
| bool | overlapping_edges = false, | ||
| bool | reverse_tile_y_indexing = false ) |
Exports a 2D array as a set of grayscale PNG image tiles.
This function divides a given 2D array into smaller rectangular tiles and saves each tile as a grayscale PNG image file. Tiles are named using a combination of the provided file name radical, tile indices, and file extension.
| fname_radical | Base name (radical) for output image files. |
| fname_extension | File extension to use for exported images (e.g., "png"). |
| array | The input 2D array to be tiled and exported. |
| tiling | A 2D vector specifying the number of tiles in the x and y directions. |
| leading_zeros | Number of digits used to pad the tile indices in the filename. |
| depth | Bit depth of the output PNG images (commonly 8 or 16). |
| overlapping_edges | If true, each tile includes an extra row/column from neighboring tiles (for overlap). |
| reverse_tile_y_indexing | If true, Y tile indices are reversed (tile 0 is at the top). |
Each tile is extracted using slicing, adjusted for overlap if specified, and then exported as an individual image file named with its tile indices. For example, an output file might be named radical_01_03.png.
Example
| Array hmap::read_to_array | ( | const std::string & | fname, |
| bool | flip_j = false, | ||
| bool | remap = true ) |
Reads an image file and converts it to a 2D array.
This function uses the OpenCV imread function to load an image from the specified file. The supported file formats are those recognized by OpenCV's imread function, such as JPEG, PNG, BMP, and others. If the image is in color, it is automatically converted to grayscale using the built-in OpenCV codec converter. This conversion process may introduce artifacts depending on the image's original format and content.
| fname | The name of the image file to be read. |
| bool hmap::export_usd | ( | const std::string & | fname, |
| const Array & | elevation = {}, | ||
| const std::vector< Forest > & | forests = {}, | ||
| const std::vector< RockField > & | rock_fields = {}, | ||
| const std::vector< Cloud > & | clouds = {}, | ||
| const std::vector< Path > & | paths = {}, | ||
| MeshType | mesh_type = MeshType::TRI, | ||
| float | elevation_scaling = 0.2f, | ||
| const std::string & | texture_fname = "", | ||
| const std::string & | normal_map_fname = "", | ||
| float | max_error = 5e-4f, | ||
| bool | fit_boundaries = false ) |
Exports a composite scene (terrain, forests, rock fields, clouds, and paths) to Universal Scene Description (USD).
Generates a USD stage (.usda, .usdc, or .usdz) containing:
| fname | Output file name (.usda, .usdc, or .usdz). |
| elevation | Optional heightmap array representing terrain elevation. |
| forests | Optional vector of Forest containers whose trees are exported as points. |
| rock_fields | Optional vector of RockField containers whose rocks are exported as points. |
| clouds | Optional vector of Cloud objects to export as points primitives. |
| paths | Optional vector of Path objects to export as curve primitives. |
| mesh_type | The type of mesh to generate for the terrain. |
| elevation_scaling | Elevation scaling factor applied to the terrain and 3D points. |
| texture_fname | Optional diffuse texture filename. |
| normal_map_fname | Optional normal map filename. |
| max_error | Maximum error for optimized Delaunay triangulation. |
| fit_boundaries | Scale domain coordinates to [0, 1]. |
Example
| Array hmap::compute_poi_suitability_field | ( | const Array & | heightmap, |
| PoiType | type, | ||
| const PoiGenerationOptions & | options ) |
Computes a normalized suitability/score field in [0, 1] for a given terrain feature type.
| heightmap | Input terrain heightmap array. |
| type | Target point of interest type. |
| options | Generation options controlling neighborhood scale and parameters. |
| Cloud hmap::generate_points_of_interest_cloud | ( | const Array & | heightmap, |
| PoiType | type, | ||
| const PoiGenerationOptions & | options ) |
| std::vector< PointOfInterest > hmap::generate_points_of_interest | ( | const Array & | heightmap, |
| PoiType | type, | ||
| const PoiGenerationOptions & | options ) |
Generates a list of PointOfInterest objects from a heightmap.
| heightmap | Input terrain heightmap array. |
| type | Target point of interest type. |
| options | Generation options. |
| std::vector< glm::vec2 > hmap::generate_points_of_interest_positions | ( | const Array & | heightmap, |
| PoiType | type, | ||
| const PoiGenerationOptions & | options ) |
Generates 2D positions of points of interest from a heightmap.
| heightmap | Input terrain heightmap array. |
| type | Target point of interest type. |
| options | Generation options. |
| std::vector< PointOfInterest > hmap::generate_points_from_score_field | ( | const Array & | score_field, |
| const Array & | heightmap, | ||
| const PoiGenerationOptions & | options, | ||
| PoiType | type = PoiType::CUSTOM ) |
Generates a list of PointOfInterest objects from a precomputed score field.
| score_field | Precomputed suitability / score field in [0, 1]. |
| heightmap | Input terrain heightmap used to sample elevation, slope, and aspect. |
| options | Generation options. |
| type | Optional classification type to assign to the points. |
| Array hmap::connected_components | ( | const Array & | array, |
| float | surface_threshold = 0.f, | ||
| float | background_value = 0.f, | ||
| std::map< float, float > * | p_surfaces = nullptr, | ||
| std::map< float, std::array< float, 2 > > * | p_centroids = nullptr ) |
Identifies and labels connected components within a binary or labeled array, with optional filtering by size.
Classifies terrain into geomorphological features based on the geomorphons method.
| Array hmap::kmeans_clustering2 | ( | const Array & | array1, |
| const Array & | array2, | ||
| int | nclusters, | ||
| std::vector< Array > * | p_scoring = nullptr, | ||
| Array * | p_aggregate_scoring = nullptr, | ||
| glm::vec2 | weights = {1.f, 1.f}, | ||
| std::uint32_t | seed = 1 ) |
Performs k-means clustering on two input arrays, grouping similar data points into clusters.
| Array hmap::kmeans_clustering3 | ( | const Array & | array1, |
| const Array & | array2, | ||
| const Array & | array3, | ||
| int | nclusters, | ||
| std::vector< Array > * | p_scoring = nullptr, | ||
| Array * | p_aggregate_scoring = nullptr, | ||
| glm::vec3 | weights = {1.f, 1.f, 1.f}, | ||
| std::uint32_t | seed = 1 ) |
Performs k-means clustering on three input arrays.
| Array hmap::bulkify | ( | const Array & | z, |
| const PrimitiveType & | primitive_type, | ||
| float | amp = 1.f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Applies a primitive-based displacement to an array.
Adds a scaled primitive pattern (optionally perturbed by noise) to the input array.
| z | Input array. |
| primitive_type | Type of primitive to generate. |
| amp | Amplitude scaling factor. |
| p_noise_x | Optional noise array for X perturbation (can be nullptr). |
| p_noise_y | Optional noise array for Y perturbation (can be nullptr). |
| center | Center of the primitive. |
| bbox | Bounding box of the primitive. |
Example
Result
| void hmap::canyonize | ( | Array & | array, |
| std::uint32_t | seed = 0, | ||
| int | nlevels = 6, | ||
| float | convex_ratio = 3.0f, | ||
| float | gamma_convex = 3.0f, | ||
| float | gamma_concave = 0.3f, | ||
| float | clamp_min_val = -std::numeric_limits<float>::infinity(), | ||
| float | k_smooth = 0.1f, | ||
| float | noise_ratio = 0.2f, | ||
| const Array * | p_noise = nullptr, | ||
| float | vmin = 1.f, | ||
| float | vmax = 0.f ) |
Applies a canyonize filter to a heightmap.
Flattens the bottom with smooth minimum clamping and applies stratification with alternating concave and convex power laws across elevation intervals, with optional strata elevation noise and lateral noise modulation.
| array | The array of values to modify. |
| seed | Random seed for strata level fluctuation. |
| nlevels | Number of stratification levels. |
| convex_ratio | Height ratio of convex strata relative to concave strata (e.g., 3.0). |
| gamma_convex | Power law exponent for convex levels (> 1, e.g., 3.0). |
| gamma_concave | Power law exponent for concave levels (< 1, e.g., 0.3). |
| clamp_min_val | Elevation threshold for flattening the canyon bottom. |
| k_smooth | Smoothing factor for clamp_min_smooth (0 for hard clamp). |
| noise_ratio | Ratio of random elevation variation on strata levels. |
| p_noise | Optional noise array for lateral modulation. |
| vmin | Minimum elevation bounds (auto if vmin >= vmax). |
| vmax | Maximum elevation bounds (auto if vmin >= vmax). |
Example
Result
| void hmap::canyonize | ( | Array & | array, |
| std::uint32_t | seed, | ||
| int | nlevels, | ||
| const Array * | p_mask, | ||
| float | convex_ratio = 3.0f, | ||
| float | gamma_convex = 3.0f, | ||
| float | gamma_concave = 0.3f, | ||
| float | clamp_min_val = -std::numeric_limits<float>::infinity(), | ||
| float | k_smooth = 0.1f, | ||
| float | noise_ratio = 0.2f, | ||
| const Array * | p_noise = nullptr, | ||
| float | vmin = 1.f, | ||
| float | vmax = 0.f ) |
Applies a masked canyonize filter to a heightmap.
| array | The array of values to modify. |
| seed | Random seed for strata level fluctuation. |
| nlevels | Number of stratification levels. |
| p_mask | Optional mask controlling the effect blending. |
| convex_ratio | Height ratio of convex strata relative to concave strata (e.g., 3.0). |
| gamma_convex | Power law exponent for convex levels (> 1, e.g., 3.0). |
| gamma_concave | Power law exponent for concave levels (< 1, e.g., 0.3). |
| clamp_min_val | Elevation threshold for flattening the canyon bottom. |
| k_smooth | Smoothing factor for clamp_min_smooth (0 for hard clamp). |
| noise_ratio | Ratio of random elevation variation on strata levels. |
| p_noise | Optional noise array for lateral modulation. |
| vmin | Minimum elevation bounds (auto if vmin >= vmax). |
| vmax | Maximum elevation bounds (auto if vmin >= vmax). |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| Array hmap::dequantize | ( | const Array & | array, |
| std::uint32_t | seed, | ||
| float | dither_amplitude = 0.01f, | ||
| int | filtering_iterations = 1 ) |
Reduce quantization artifacts using dithering and smoothing.
Adds white noise dithering to the input array and applies iterative Laplacian filtering to smooth quantization steps.
| array | Input quantized array. |
| seed | Random seed used for dithering noise generation. |
| dither_amplitude | Amplitude of the added white noise. |
| filtering_iterations | Number of Laplacian smoothing iterations. |
Example
Result
| Array hmap::distance_shaper | ( | const Array & | array, |
| float | falloff = 0.05f, | ||
| int | directions = 8, | ||
| float | skew = 0.f, | ||
| float | angle = 0.f, | ||
| DistanceMode | mode = DistanceMode::PYRAMID, | ||
| DistanceMethod | method = DistanceMethod::RT, | ||
| float | angular_jitter = 0.f, | ||
| float | falloff_jitter = 0.f, | ||
| float | threshold = 0.f, | ||
| bool | invert_input = false, | ||
| bool | invert_output = false, | ||
| float | mix_ratio = 1.f, | ||
| std::uint32_t | seed = 0, | ||
| const Array * | p_mask = nullptr, | ||
| const Array * | p_dx = nullptr, | ||
| const Array * | p_dy = nullptr ) |
Generates sloped, stratified terrain profiles from shapes and masks using directional distance fields.
Reproduces the behavior of Gaea's Distance node. Can generate multi-directional slopes, terraced / folded rock formations, and anisotropic skewing.
| array | Input heightmap or shape mask. |
| falloff | Slope / distance gradient decay rate. |
| directions | Number of projection directions. |
| skew | Asymmetry / skew strength along orientation angle. |
| angle | Primary orientation angle in degrees. |
| mode | Pattern mode (PYRAMID for flat faces, ASTERISK for star-shaped cuts). |
| method | Distance calculation method (RT or CLASSIC). |
| angular_jitter | Random jitter applied to directional angles in [0, 1]. |
| falloff_jitter | Random variation applied to falloff in [0, 1]. |
| threshold | Cutoff elevation threshold for sources. |
| invert_input | If true, inverts the input prior to distance calculation. |
| invert_output | If true, inverts the output distance field. |
| mix_ratio | Blending factor between original input and output in [0, 1]. |
| seed | Random seed for stochastic jitter. |
| p_mask | Optional blend mask pointer. |
| p_dx | Optional X displacement array for domain warp. |
| p_dy | Optional Y displacement array for domain warp. |
Example
Result
| void hmap::equalize | ( | Array & | array | ) |
Apply histogram equalization to the array values.
This function performs histogram equalization on the input array to enhance the contrast of the image or data by adjusting the intensity distribution.
| array | Input array to be equalized. |
Apply histogram equalization to the array values with a mask.
This function performs histogram equalization on the input array while considering the specified mask. Only the elements of the array corresponding to non-zero values in the mask are equalized.
| array | Input array to be equalized. |
| p_mask | Optional mask array. Only the elements where the mask is non-zero are equalized. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply expansion, or "inflation", to emphasize the bulk of the terrain.
This function expands the features of the terrain represented by the input array. The expansion operation, often referred to as "inflation", increases the prominence of elevated regions, effectively making them more pronounced.
| array | Input array representing the terrain or data to be expanded. |
| ir | Filter radius, which determines the extent of the expansion. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask controls which parts of the array are affected by the expansion. |
Example
Result
| void hmap::expand | ( | Array & | array, |
| int | ir, | ||
| int | iterations = 1 ) |
Apply expansion to emphasize the bulk of the terrain using a filter radius.
This overload applies expansion without the use of a mask, utilizing only the filter radius.
| array | Input array representing the terrain or data to be expanded. |
| ir | Filter radius, which determines the extent of the expansion. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply expansion using a custom kernel.
This overload allows the use of a custom kernel for expansion, offering more control over the operation compared to the filter radius method.
| array | Input array representing the terrain or data to be expanded. |
| kernel | Custom kernel array used to perform the expansion. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply expansion using a custom kernel with an optional mask.
This overload allows the use of a custom kernel for expansion, along with an optional mask to control which parts of the array are affected.
| array | Input array representing the terrain or data to be expanded. |
| kernel | Custom kernel array used to perform the expansion. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask controls which parts of the array are affected by the expansion. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::expand_directional | ( | Array & | array, |
| int | ir, | ||
| float | angle, | ||
| float | aspect_ratio, | ||
| float | anisotropy = 1.f, | ||
| const Array * | p_mask = nullptr ) |
Apply expansion, or "inflation", to emphasize the bulk of the terrain, using a directional kernel.
This function expands features of the terrain represented by the input array, with emphasis applied directionally based on the specified angle. The directional kernel allows for anisotropic expansion, making the expansion more pronounced in a specified direction.
| array | Input array representing the terrain or data to be expanded. |
| ir | Filter radius, determining the extent of the expansion. |
| angle | Angle (in degrees) that sets the direction of the expansion. |
| aspect_ratio | Pulse aspect ratio, determining the shape of the expansion. |
| anisotropy | Pulse width ratio between upstream and downstream sides, default is 1.0 (isotropic expansion). |
| p_mask | Optional filter mask with values expected in the range [0, 1]. The mask controls which parts of the array are affected by the expansion. |
Example
Result
| void hmap::expand_talus | ( | Array & | z, |
| const Array & | mask, | ||
| float | talus, | ||
| std::uint32_t | seed, | ||
| int | ir = 1, | ||
| float | noise_ratio = 0.2f ) |
Expand heights outward from a masked region with a talus slope limit.
Starting from the non-zero cells of mask, heights are propagated outward using a min-heap so lower cells are processed first. Neighbor heights are computed from the source height plus dist * talus, optionally perturbed with noise.
Intuition: grows terrain outward from seed cells, filling empty space while respecting a maximum slope.
| z | Height array modified in-place. |
| mask | Initial region to expand from. |
| talus | Maximum slope per unit distance. |
| seed | RNG seed for noise. |
| ir | Neighborhood radius. |
| noise_ratio | Amplitude of slope noise. |
| void hmap::fill_talus | ( | Array & | z, |
| float | talus, | ||
| std::uint32_t | seed, | ||
| int | ir = 1, | ||
| float | noise_ratio = 0.2f, | ||
| const Array * | p_seed_mask = nullptr ) |
Enforce a talus slope constraint on a height field.
Cells are processed from highest to lowest using a max-heap. Each cell may raise neighboring cells so that the slope relative to the current cell does not exceed the local talus value.
Intuition: stabilizes an existing terrain by redistributing height so slopes do not exceed the talus limit (similar to talus erosion / relaxation but by adding material).
| z | A reference to the 2D array representing the terrain heights. The function modifies this array in place to introduce talus slopes. |
| talus | The critical slope angle that determines where material will move from higher elevations to lower ones. Slopes steeper than this value will be flattened by material transport. |
| seed | The seed for the random number generator, ensuring reproducibility of the noise effects in the talus formation process. The same seed will produce the same terrain modifications. |
| noise_ratio | A parameter that controls the amount of randomness or noise introduced in the talus formation process. The default value is 0.2. |
Example
Result
See unit tests: test_fill_talus.cpp
| void hmap::fill_talus | ( | Array & | z, |
| const Array & | talus, | ||
| std::uint32_t | seed, | ||
| int | ir = 1, | ||
| float | noise_ratio = 0.2f, | ||
| const Array * | p_seed_mask = nullptr ) |
Apply a "folding" filter (successive absolute values) to the array elements.
This function applies a folding filter to the input array, where the values are successively folded (using absolute values) within a specified range, defined by vmin and vmax. The process can be repeated for a number of iterations, with an optional smoothing parameter k to control the intensity of the folding effect.
| array | Input array to which the folding filter is applied. |
| vmin | Minimum reference value used as a lower bound for the folding operation. |
| vmax | Maximum reference value used as an upper bound for the folding operation. |
| iterations | Number of iterations for applying the folding filter. The default is 3. |
| k | Smoothing parameter for the absolute value operation, expected to be greater than 0. It controls the degree of smoothing applied during folding. The default value is 0.05. |
Example
Result
Apply a "folding" filter with default reference values and parameters.
This overload applies the folding filter to the input array with the default number of iterations and smoothing parameter k. The folding is done without explicit minimum and maximum reference values.
| array | Input array to which the folding filter is applied. |
| iterations | Number of iterations for applying the folding filter. The default is 3. |
| k | Smoothing parameter for the absolute value operation, expected to be greater than 0. It controls the degree of smoothing applied during folding. The default value is 0.05. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::fold_periodic | ( | Array & | array, |
| PhasorProfile | phasor_profile, | ||
| float | vmin, | ||
| float | vmax, | ||
| int | iterations = 3, | ||
| float | delta = 0.f ) |
Apply a periodic "folding" filter to the array elements using a periodic phasor profile.
This function applies a folding filter based on a periodic profile function (PhasorProfile) rather than successive absolute-value operations. For each iteration, the function evaluates the periodic profile across the range defined by [vmin, vmax] with an increasing frequency (doubled per iteration).
| array | Input array to which the periodic folding filter is applied. |
| phasor_profile | Type of phasor profile to use for folding. |
| delta | Profile shape parameter (defaults to 0.0). |
| vmin | Minimum reference value used as a lower bound for the folding operation. |
| vmax | Maximum reference value used as an upper bound for the folding operation. |
| iterations | Number of iterations for applying the folding filter. The default is 3. |
| void hmap::fold_periodic | ( | Array & | array, |
| PhasorProfile | phasor_profile = PhasorProfile::PP_COSINE_STD, | ||
| int | iterations = 3, | ||
| float | delta = 0.f ) |
Apply a periodic "folding" filter with default reference values.
This overload applies the periodic folding filter using the array's minimum and maximum values as reference bounds.
| array | Input array to which the periodic folding filter is applied. |
| phasor_profile | Type of phasor profile to use for folding. |
| iterations | Number of iterations for applying the folding filter. The default is 3. |
| delta | Profile shape parameter (defaults to 0.0). |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply a gain correction to the array elements.
This function applies a gain correction to the input array using a power law. The correction enhances or reduces the intensity of the values based on the specified gain factor.
| array | Input array to which the gain correction is applied. |
| factor | Gain factor, expected to be greater than 0. It determines the strength of the gain correction. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask controls which parts of the array are affected by the gain correction. |
Example
Result
| void hmap::gain | ( | Array & | array, |
| float | factor ) |
Apply a gain correction to the array elements without a mask.
This overload applies the gain correction to the entire array without using a mask. The gain correction is performed using the specified gain factor.
| array | Input array to which the gain correction is applied. |
| factor | Gain factor, expected to be greater than 0. It determines the strength of the gain correction. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply gamma correction to the input array.
This function applies gamma correction to the input array, which adjusts the brightness and contrast based on a specified gamma factor. Gamma correction is used to correct or adjust the tonal range of an image or data to achieve a desired visual effect.
| array | Input array to which the gamma correction is applied. |
| gamma | Gamma factor, expected to be greater than 0. It determines the level of correction applied. A gamma value less than 1 will lighten the image, while a value greater than 1 will darken it. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask controls which parts of the array are affected by the gamma correction. |
Example
Result
| void hmap::gamma_correction | ( | Array & | array, |
| float | gamma ) |
Apply gamma correction to the input array without a mask.
This overload applies gamma correction to the entire array without using a mask. The gamma correction is performed using the specified gamma factor.
| array | Input array to which the gamma correction is applied. |
| gamma | Gamma factor, expected to be greater than 0. It determines the level of correction applied. A gamma value less than 1 will lighten the image, while a value greater than 1 will darken it. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply a "local" gamma correction to the input array.
This function performs gamma correction by first normalizing the values locally within a specified neighborhood around each pixel. The normalization is achieved using minimum and maximum filters before applying the gamma correction based on the specified gamma factor. This method allows for localized adjustments of contrast and brightness in the input array.
| array | Input array to which the local gamma correction is applied. |
| gamma | Gamma factor, expected to be greater than 0. It determines the level of correction applied after local normalization. A gamma value less than 1 will lighten the local regions, while a value greater than 1 will darken them. |
| ir | Filter radius that defines the size of the local neighborhood used for normalization. |
| k | Smoothing factor used to control the degree of smoothing applied during normalization. The default value is 0.1. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask controls which parts of the array are affected by the local gamma correction. |
Example
Result
| void hmap::gamma_correction_local | ( | Array & | array, |
| float | gamma, | ||
| int | ir, | ||
| const Array * | p_mask, | ||
| float | k = 0.1f ) |
Apply a "local" gamma correction with a mask to the input array.
This overload applies local gamma correction to the input array using a mask. The gamma correction is performed after normalizing values locally within the specified neighborhood defined by the filter radius. The optional mask allows for selective application of the correction.
| array | Input array to which the local gamma correction is applied. |
| gamma | Gamma factor, expected to be greater than 0. It determines the level of correction applied after local normalization. A gamma value less than 1 will lighten the local regions, while a value greater than 1 will darken them. |
| ir | Filter radius that defines the size of the local neighborhood used for normalization. |
| p_mask | Filter mask, with values expected in the range [0, 1]. The mask controls which parts of the array are affected by the local gamma correction. |
| k | Smoothing factor used to control the degree of smoothing applied during normalization. The default value is 0.1. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Applies the Kuwahara filter to an array with optional per-pixel masking.
This overloaded version of the Kuwahara filter allows applying the filter with a per-pixel mask. The mask determines the blending ratio for each pixel, allowing selective smoothing.
| array | The input/output array to apply the filter on. The array is modified in place. |
| ir | The radius of the region to analyze for each pixel. Larger values result in stronger smoothing. |
| mix_ratio | A blending factor between the original and filtered arrays when p_mask is nullptr. Ignored if p_mask is provided. |
Example
Result
Applies the Kuwahara filter to an array with optional per-pixel masking.
This overloaded version of the Kuwahara filter allows applying the filter with a per-pixel mask. The mask determines the blending ratio for each pixel, allowing selective smoothing.
| array | The input/output array to apply the filter on. The array is modified in place. |
| ir | The radius of the region to analyze for each pixel. Larger values result in stronger smoothing. |
| p_mask | A pointer to an array representing the mask. The values in the mask range from 0.0 to 1.0, specifying the blending ratio for each pixel. If nullptr, the filter is applied without masking. |
| mix_ratio | A blending factor between the original and filtered arrays when p_mask is nullptr. Ignored if p_mask is provided. |
If no mask is provided:
Example
Result
Applies an iterative 8-neighbor Laplacian smoothing filter on an array.
This function performs isotropic Laplacian diffusion on a 2D array using an explicit finite-difference scheme. Each cell is updated according to the local Laplacian computed from its 8 surrounding neighbors:
\[A_{i,j}^{t+1} = A_{i,j}^{t} + \sigma \cdot \left( \sum_{(p,q)\in N_{8}(i,j)} A_{p,q}^{t} - 8A_{i,j}^{t} \right) \]
where ( N_{8}(i,j) ) denotes the 8 neighboring cells.
Boundary cells are handled by clamping neighbor indices to the valid range, effectively replicating edge values at the borders.
| array | The 2D array to be smoothed (modified in place). |
| sigma | Diffusion coefficient (small positive value, e.g. 0.05–0.25). |
| iterations | Number of diffusion iterations to apply. |
Example
Result
| void hmap::laplace | ( | Array & | array, |
| const Array * | p_mask, | ||
| float | sigma = 0.125f, | ||
| int | iterations = 3 ) |
Apply a low-pass Laplace filter with a mask.
This overload applies the Laplace filter to the input array using an optional mask. The mask determines which parts of the array are affected by the filter. The filtering intensity and the number of iterations control the extent of the smoothing effect.
| array | Input array to which the Laplace filter is applied. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the array are affected by the filter. |
| sigma | Filtering intensity, expected to be in the range [0, 1]. It controls the strength of the filtering effect. A value closer to 1 results in more smoothing. The default value is 0.2. |
| iterations | Number of iterations to apply the filter. More iterations will increase the smoothing effect. The default value is 3. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::laplace1d | ( | std::vector< float > & | v, |
| float | sigma = 0.5f, | ||
| int | iterations = 1 ) |
Apply a low-pass Laplace filter to a vector.
This function applies a low-pass Laplace filter to a 1D vector to smooth out high-frequency noise and detail. The filtering intensity and the number of iterations control the extent of the smoothing effect.
| v | Input vector to which the Laplace filter is applied. |
| sigma | Filtering intensity, expected to be in the range [0, 1]. It determines the strength of the filtering effect. A value closer to 1 results in more smoothing. |
| iterations | Number of iterations to apply the filter. More iterations will increase the smoothing effect. The default value is 1. |
| void hmap::laplace_edge_preserving | ( | Array & | array, |
| float | talus, | ||
| float | sigma = 0.2f, | ||
| int | iterations = 3 ) |
Apply a low-pass anisotropic Laplace filter to the input array.
This function applies an anisotropic Laplace filter to the input array. Anisotropic diffusion, also known as edge-preserving smoothing, helps to reduce noise while preserving edges. The effect of the filter is controlled by the talus limit, filtering intensity, and the number of iterations.
| array | Input array to which the anisotropic Laplace filter is applied. |
| talus | Talus limit for edge sensitivity. Gradients above this value are less affected by the filtering, preserving important edges in the data. |
| sigma | Filtering intensity, expected to be in the range [0, 1]. It controls the strength of the filtering effect. A value closer to 1 results in more smoothing. The default value is 0.2. |
| iterations | Number of iterations to apply the filter. More iterations will increase the smoothing effect. The default value is 3. |
Example
Result
| void hmap::laplace_edge_preserving | ( | Array & | array, |
| float | talus, | ||
| const Array * | p_mask, | ||
| float | sigma = 0.2f, | ||
| int | iterations = 3 ) |
Apply a low-pass anisotropic Laplace filter with a mask.
This overload applies the anisotropic Laplace filter to the input array using an optional mask. The mask determines which parts of the array are affected by the filter. The effect of the filtering is controlled by the talus limit, filtering intensity, and the number of iterations.
| array | Input array to which the anisotropic Laplace filter is applied. |
| talus | Talus limit for edge sensitivity. Gradients above this value are less affected by the filtering, preserving important edges in the data. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the array are affected by the filter. |
| sigma | Filtering intensity, expected to be in the range [0, 1]. It controls the strength of the filtering effect. A value closer to 1 results in more smoothing. The default value is 0.2. |
| iterations | Number of iterations to apply the filter. More iterations will increase the smoothing effect. The default value is 3. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply a low-pass high-order filter to the input array.
This function applies a high-order low-pass filter to the input array. The filter can be of 5th, 7th, or 9th order, providing increasingly sharp filtering effects. The filtering intensity is controlled by the sigma parameter, which determines the strength of the filtering.
| array | Input array to which the high-order low-pass filter is applied. |
| order | Filter order, which can be 5, 7, or 9. Higher orders provide more refined filtering. |
| sigma | Filtering intensity, expected to be in the range [0, 1]. It controls the strength of the filtering effect. A value closer to 1 results in more smoothing. The default value is 1.0. |
Example
Result
laplace Convert array values to binary using a threshold.
This function applies a binary filter to the input array, converting all values to either 0 or 1 based on a specified threshold. Values above the threshold are set to 1, while values equal to or below the threshold are set to 0.
| array | Input array to be converted to binary. |
| threshold | Threshold value. Any array value greater than this threshold is set to 1, while values less than or equal to the threshold are set to 0. The default threshold is 0.0. |
Transform the input array elevation to match the histogram of a reference array.
This function performs histogram matching on the input array to adjust its elevation values so that the resulting histogram closely matches the histogram of a reference array. This process is useful for aligning the statistical properties of the input data with those of the reference data. A single input sample maps to the reference median, interpolating between the two central reference values for an even sample count. Empty input or reference arrays leave the input unchanged.
| array | Input array whose elevation values are to be transformed. |
| array_reference | Reference array whose histogram is used as the target for matching. |
Example
Result
| Array hmap::mean_shift | ( | const Array & | array, |
| int | ir, | ||
| float | talus, | ||
| int | iterations = 1, | ||
| bool | talus_weighted = true ) |
Applies the mean shift algorithm to the input array.
The mean shift algorithm iteratively adjusts each value in the input array by averaging nearby values within a specified radius (ir), using either simple or weighted mean computation. The process stops after the specified number of iterations or if convergence criteria are met.
| array | The input array to process. |
| ir | The radius of the neighborhood to consider for mean computation. |
| threshold | The value threshold for considering neighboring elements. Only elements with differences below this threshold are included. |
| iterations | The number of iterations to perform the mean shift process. |
| talus_weighted | If true, uses weighted mean based on differences between values and their neighbors. If false, uses unweighted mean. |
Example
Result
| Array hmap::mean_shift | ( | const Array & | array, |
| int | ir, | ||
| float | talus, | ||
| const Array * | p_mask, | ||
| int | iterations = 1, | ||
| bool | talus_weighted = true ) |
Apply a 3x3 median filter to the input array.
This function applies a 3x3 median filter to the input array to reduce noise while preserving edges. The median filter replaces each pixel with the median value of the 3x3 neighborhood surrounding it. An optional mask can be used to control which parts of the array are filtered.
| array | Input array to which the median filter is applied. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask determines which parts of the array are affected by the median filter. |
Example
Result
| void hmap::median_3x3 | ( | Array & | array | ) |
Apply a 3x3 median filter to the input array without a mask.
This overload applies a 3x3 median filter to the input array, affecting all pixels. The median filter replaces each pixel with the median value of the 3x3 neighborhood surrounding it.
| array | Input array to which the median filter is applied. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Computes a fast pseudo-median approximation of a local neighborhood in an array.
This function approximates the effect of a median filter by computing the local minimum, maximum, and mean values within a square neighborhood of radius ir, and averaging the results:
\[\text{pseudo\_median}(x, y) = \frac{\text{min} + \text{max} + \text{mean}}{3} \]
This method is computationally cheaper than a true median filter and can approximate its noise-reduction and edge-preserving properties to some extent.
| array | Input array (e.g., image or 2D signal). |
| ir | Radius of the square neighborhood (kernel size will be \(2 \cdot ir + 1\)). |
Example
Result
| void hmap::normal_displacement | ( | Array & | array, |
| float | amount = 0.1f, | ||
| int | ir = 0, | ||
| bool | reverse = false ) |
Apply a displacement to the terrain along the normal direction.
This function displaces the terrain along its normal direction, simulating effects like erosion or terrain modification. The amount of displacement and direction (normal or reversed) can be specified. Optionally, a mask can be used to control which parts of the terrain are affected.
| array | Input array representing the terrain. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the array are affected by the displacement. |
| amount | Amount of displacement to apply. The default value is 0.1. |
| ir | Pre-filtering radius. The radius used to smooth the terrain before applying displacement. The default value is 0. |
| reverse | If true, the displacement direction is reversed. The default value is false. |
Example
Result
| void hmap::normal_displacement | ( | Array & | array, |
| const Array * | p_mask, | ||
| float | amount = 0.1f, | ||
| int | ir = 0, | ||
| bool | reverse = false ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply a plateau-shape filter to the input array.
This function applies a plateau-shape filter to the input array, modifying the terrain to create flat, plateau-like regions. The filter's radius and flatness can be adjusted to control the extent and shape of the plateaus. An optional mask can be used to control which parts of the array are affected.
| array | Input array to which the plateau-shape filter is applied. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the array are affected by the filter. |
| ir | Plateau radius. The size of the area over which the plateau effect is applied. |
| factor | Gain factor that controls the flatness of the plateau. The higher the factor, the flatter the resulting plateau. The default value is 1.0. |
Example
Result
| void hmap::plateau | ( | Array & | array, |
| int | ir, | ||
| float | factor ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Quantize array values into discrete levels.
Values are clamped to the range [vmin, vmax] and remapped to nlevels uniformly distributed discrete values.
| array | Input array. |
| nlevels | Number of quantization levels. |
| vmin | Minimum clamp value. |
| vmax | Maximum clamp value. |
Example
Result
Quantize array values using the array min/max range.
| array | Input array. |
| nlevels | Number of quantization levels. |
Example
Result
| void hmap::recast_billow | ( | Array & | array, |
| float | vref, | ||
| float | k ) |
Transform heightmap to give a "billow" like appearance.
This function modifies the heightmap to produce a "billow" effect. The transformation is applied based on a reference elevation (vref) where the elevation is folded. The smoothing coefficient (k) controls the degree of smoothing applied during the transformation.
| array | Input array representing the heightmap to be transformed. |
| vref | Reference elevation where the heightmap values are folded. This value determines the baseline around which the billow effect is centered. |
| k | Smoothing coefficient that influences the degree of smoothness in the billow transformation. Higher values result in more smoothing. |
Example
Result
Transform heightmap to give a "canyon" like appearance.
This function modifies the heightmap to create a "canyon" effect. The transformation is based on a canyon top elevation (vcut). The effect can be adjusted with a gamma factor to control the intensity of the canyon effect. Optional parameters include a filter mask for selective application and a noise array for additional variation.
| array | Input array representing the heightmap to be transformed. |
| vcut | Canyon top elevation. This value defines the threshold for canyon formation. |
| gamma | Gamma factor (> 0) that adjusts the intensity of the canyon effect. A higher value increases the effect. The default value is 4.0. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the heightmap are affected by the transformation. |
| p_noise | Optional noise array used to introduce variation in the canyon effect. If not provided, no additional noise is applied. |
Example
Result
| void hmap::recast_canyon | ( | Array & | array, |
| const Array & | vcut, | ||
| const Array * | p_mask, | ||
| float | gamma = 4.f ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::recast_canyon | ( | Array & | array, |
| float | vcut, | ||
| const Array * | p_mask, | ||
| float | gamma = 4.f, | ||
| const Array * | p_noise = nullptr ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::recast_canyon | ( | Array & | array, |
| float | vcut, | ||
| float | gamma = 4.f, | ||
| const Array * | p_noise = nullptr ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::recast_cracks | ( | Array & | array, |
| float | cut_min = 0.05f, | ||
| float | cut_max = 0.5f, | ||
| float | k_smoothing = 0.01f, | ||
| float | vmin = 0.f, | ||
| float | vmax = -1.f ) |
| void hmap::recast_escarpment | ( | Array & | array, |
| int | ir = 16, | ||
| float | ratio = 0.1f, | ||
| float | scale = 1.f, | ||
| bool | reverse = false, | ||
| bool | transpose_effect = false, | ||
| float | global_scaling = 0.f ) |
Applies an escarpment effect to the given 2D array, modifying its values based on cumulative displacement with optional directional and transpositional transformations.
This function calculates cumulative displacement along the x-axis based on relative elevation differences between adjacent cells. The displacement is scaled and optionally reversed, then used to apply a warping effect to the array, simulating an escarpment feature. An optional global scaling factor can further adjust the displacement effect intensity.
| array | Reference to the 2D array where the escarpment effect will be applied. |
| ir | Radius for the smoothing kernel used on the displacement, controlling the smoothness of the effect. Larger values result in smoother transitions. |
| ratio | The ratio influencing displacement; values > 1.0 increase displacement sensitivity to height differences. |
| scale | The scaling factor for the cumulative displacement, affecting the intensity of the effect. |
| reverse | If true, reverses the direction of the displacement effect. |
| transpose_effect | If true, transposes the array before and after applying the effect. |
| global_scaling | An additional scaling factor for the displacement; if set to 0, a default value is computed based on the array's range and size. Higher values increase the overall effect. |
Example
Result
| void hmap::recast_escarpment | ( | Array & | array, |
| const Array * | p_mask, | ||
| int | ir = 16, | ||
| float | ratio = 0.1f, | ||
| float | scale = 1.f, | ||
| bool | reverse = false, | ||
| bool | transpose_effect = false, | ||
| float | global_scaling = 0.f ) |
Applies an escarpment effect to the given 2D array, with an optional mask to blend the effect.
This overload allows for a blending mask that controls the intensity of the escarpment effect at each point in the array. The mask values range between 0 and 1, where values closer to 1 fully apply the effect, and values closer to 0 reduce it. An optional global scaling factor can further adjust the displacement effect intensity.
| array | Reference to the 2D array where the escarpment effect will be applied. |
| p_mask | Pointer to an optional mask array for blending the effect, where values range from 0 to 1. A nullptr applies the effect fully without blending. |
| ir | Radius for the smoothing kernel used on the displacement, controlling the smoothness of the effect. Larger values result in smoother transitions. |
| ratio | The ratio influencing displacement; values > 1.0 increase displacement sensitivity to height differences. |
| scale | The scaling factor for the cumulative displacement, affecting the intensity of the effect. |
| reverse | If true, reverses the direction of the displacement effect. |
| transpose_effect | If true, transposes the array before and after applying the effect. |
| global_scaling | An additional scaling factor for the displacement; if set to 0, a default value is computed based on the array's range and size. Higher values increase the overall effect. |
Example
Result
Transform heightmap to give a "peak" like appearance.
This function modifies the heightmap to create a "peak" effect, where the elevations are adjusted to emphasize peak-like features. The transformation is applied based on a filter radius (ir) and involves gamma correction and smoothing parameters. The effect can be selectively applied using a filter mask.
| array | Input array representing the heightmap to be transformed. |
| ir | Filter radius used to smooth the heightmap before applying the peak effect. |
| gamma | Gamma factor (> 0) that adjusts the intensity of the peak effect. A higher value increases the effect. The default value is 2.0. For details on gamma correction, see gamma_correction. |
| k | Smoothing parameter (> 0) that controls the degree of smoothing applied during the transformation. Higher values result in more smoothing. The default value is 0.1. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the heightmap are affected by the peak transformation. |
Example
Result
| void hmap::recast_peak | ( | Array & | array, |
| int | ir, | ||
| const Array * | p_mask, | ||
| float | gamma = 2.f, | ||
| float | k = 0.1f ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::recast_rocky_slopes | ( | Array & | array, |
| float | talus, | ||
| int | ir, | ||
| float | amplitude, | ||
| std::uint32_t | seed, | ||
| float | kw, | ||
| float | gamma = 0.5f, | ||
| const Array * | p_noise = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Transform heightmap by adding "rock-like" features at higher slopes.
This function modifies the heightmap to introduce rock-like features, particularly at locations with higher slopes. The transformation is controlled by parameters defining talus limit, filter radius, amplitude, and noise characteristics. The rock features are generated using a specified random seed and can be customized with optional noise and gamma correction. A filter mask can be applied to control which parts of the heightmap are affected.
| array | Input array representing the heightmap to be transformed. |
| talus | Talus limit that determines the threshold above which rock-like features are introduced based on slope steepness. |
| ir | Filter radius used to smooth the heightmap and define the area of influence for adding rock features. |
| amplitude | Amplitude of the rock features. This value controls the intensity of the rock-like appearance. |
| seed | Random number seed used to generate noise patterns for the rock features. Different seeds produce different rock patterns. |
| kw | Noise wavenumber with respect to a unit domain, influencing the frequency of rock features. Higher values result in more detailed rock textures. |
| gamma | Gamma correction coefficient applied to the rock features. This parameter adjusts the contrast of the rock features. The default value is 0.5. |
| p_noise | Optional reference to an input noise array used for generating rock features. If provided, it overrides the default noise generator. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the heightmap are affected by the rock feature transformation. |
| bbox | Bounding box defining the region of interest within the heightmap. This parameter specifies the coordinates of the bounding box in the format {xmin, xmax, ymin, ymax}. The default bounding box covers the entire domain. |
Example
Result
| void hmap::recast_rocky_slopes | ( | Array & | array, |
| float | talus, | ||
| int | ir, | ||
| float | amplitude, | ||
| std::uint32_t | seed, | ||
| float | kw, | ||
| const Array * | p_mask, | ||
| float | gamma = 0.5f, | ||
| const Array * | p_noise = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::recast_sag | ( | Array & | array, |
| float | vref, | ||
| float | k ) |
Transform heightmap to give a "cliff" like appearance.
This function modifies the heightmap to create a "cliff" effect by folding the elevations around a reference height (vref). The transformation is influenced by a smoothing coefficient (k) and can be selectively applied using a filter mask.
| array | Input array representing the heightmap to be transformed. |
| vref | Reference elevation where the heightmap is folded to create the cliff-like appearance. Elevations near this value will be prominently altered. |
| k | Smoothing coefficient that controls the degree of smoothing applied during the transformation. A higher value results in smoother cliffs. The default value is not specified in this function; it must be provided by the user. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the heightmap are affected by the cliff transformation. If not provided, the transformation is applied to the entire heightmap. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::recurve | ( | Array & | array, |
| const std::vector< float > & | t, | ||
| const std::vector< float > & | v ) |
Apply a curve adjustment filter to the array.
This function applies a curve adjustment to the heightmap by mapping input values to output values according to a given correction curve. The curve is monotonically interpolated, and any values outside the defined input range are clipped. The filter can be selectively applied using a mask.
| array | Input array representing the heightmap to be adjusted. |
| t | Vector of input values for the correction curve. These values define the x-coordinates (input values) of the curve. |
| v | Vector of output values for the correction curve. These values define the y-coordinates (output values) of the curve corresponding to the input values in t. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the heightmap are affected by the curve adjustment. If not provided, the curve adjustment is applied to the entire heightmap. |
Example
Result
| void hmap::recurve | ( | Array & | array, |
| const std::vector< float > & | t, | ||
| const std::vector< float > & | v, | ||
| const Array * | p_mask ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply a curve adjustment filter using a "bumpy exponential-shape" curve.
This function adjusts the heightmap using a "bumpy exponential-shape" curve, where the curve has an exponential decay defined by the parameter tau. The curve transformation is applied to the entire heightmap or selectively using a filter mask.
| array | Input array representing the heightmap to be adjusted. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the heightmap are affected by the curve adjustment. If not provided, the adjustment is applied to the entire heightmap. |
| tau | Exponential decay parameter that defines the shape of the "bumpy" curve. Higher values of tau result in a sharper curve. The default value is 0.5. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply a curve adjustment filter using a "sharp exponential-shape" curve.
This function adjusts the heightmap using a "sharp exponential-shape" curve, where the curve has an exponential decay defined by the parameter tau. The curve transformation can be applied to the entire heightmap or selectively using a filter mask.
| array | Input array representing the heightmap to be adjusted. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. The mask specifies which parts of the heightmap are affected by the curve adjustment. If not provided, the adjustment is applied to the entire heightmap. |
| tau | Exponential decay parameter that defines the shape of the "sharp" curve. Higher values of tau result in a steeper curve. The default value is 0.5. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::recurve_kura | ( | Array & | array, |
| float | a, | ||
| float | b ) |
Apply a curve adjustment filter using Kumaraswamy's cumulative distribution function (CDF).
This function transforms the heightmap using Kumaraswamy's CDF, which is defined by two shape parameters, a and b. The transformation applies a curve adjustment that can shape the data closer to 0 or 1 depending on the values of a and b. The adjustment can be applied to the entire heightmap or selectively using a filter mask.
| array | Input array representing the heightmap to be adjusted. |
| a | Parameter 'a' of Kumaraswamy's CDF, which drives the curve shape towards 0. |
| b | Parameter 'b' of Kumaraswamy's CDF, which drives the curve shape towards 1. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. If provided, the adjustment is applied according to this mask. If not provided, the entire heightmap is adjusted. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::recurve_s | ( | Array & | array | ) |
Apply a curve adjustment filter using a smooth "S-shape" curve.
This function adjusts the heightmap using a smooth "S-shape" curve, which transforms the input values in a manner that creates an S-shaped distribution. The transformation can be applied to the entire heightmap or selectively using a filter mask.
| array | Input array representing the heightmap to be adjusted. |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. If provided, the adjustment is applied according to this mask. If not provided, the entire heightmap is adjusted. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::recurve_smoothstep_rational | ( | Array & | array, |
| float | n ) |
Apply a curve adjustment filter using an nth-order smoothstep curve.
This function applies a curve adjustment to the heightmap using a smoothstep function of order n. The smoothstep function provides a smooth transition between 0 and 1, where n determines the smoothness of the transition. The adjustment can be applied to the entire heightmap or selectively using a filter mask.
| array | Input array representing the heightmap to be adjusted. |
| n | Smoothstep order, which determines the degree of smoothness for the transition. n should be a non-negative value (in [0, ∞[). |
| p_mask | Optional filter mask, with values expected in the range [0, 1]. If provided, the adjustment is applied according to this mask. If not provided, the entire heightmap is adjusted. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::reverse_above_theshold | ( | Array & | array, |
| const Array & | threshold, | ||
| float | scaling = 1.f, | ||
| float | transition_extent = 0.f ) |
Applies a smooth reversal of values above a given threshold.
This function modifies the elements of an array by "reversing" values that exceed a given threshold value, optionally blending the effect over a transition range.
For values above the threshold:
For values below the threshold:
| array | Array to modify in place. |
| threshold | Array containing the per-element threshold values. |
| scaling | Multiplier applied to the difference above the threshold. |
| transition_extent | Width of the smooth transition zone for blending. |
Example
Result
| void hmap::reverse_above_theshold | ( | Array & | array, |
| float | threshold, | ||
| float | scaling = 1.f, | ||
| float | transition_extent = 0.f ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::reverse_above_theshold | ( | Array & | array, |
| const Array & | threshold, | ||
| const Array * | p_mask, | ||
| float | scaling = 1.f, | ||
| float | transition_extent = 0.f ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::reverse_above_theshold | ( | Array & | array, |
| float | threshold, | ||
| const Array * | p_mask, | ||
| float | scaling = 1.f, | ||
| float | transition_extent = 0.f ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::ridge_accentuate | ( | Array & | array, |
| float | strength = 0.1f, | ||
| int | ir = 0, | ||
| bool | reverse = false ) |
Accentuate ridges by gradient-directed resampling along the normal direction.
This filter sharpens and accentuates ridgelines in a heightmap. For each pixel, the terrain surface normal is computed at a scale controlled by ir. The sampling position is displaced along the horizontal normal direction by an amount proportional to strength, and the original heightmap is resampled.
| array | Input array representing the terrain (modified in place). |
| strength | Displacement amount / ridge intensity (default is 0.1f). |
| ir | Filter radius used to smooth terrain before computing the normal (default is 0). |
| reverse | If true, inverts displacement direction to form valleys/channels (default is false). |
Example
Result
| void hmap::ridge_accentuate | ( | Array & | array, |
| const Array * | p_mask, | ||
| float | strength = 0.1f, | ||
| int | ir = 0, | ||
| bool | reverse = false ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::saturate | ( | Array & | array, |
| float | vmin, | ||
| float | vmax, | ||
| float | from_min, | ||
| float | from_max, | ||
| float | k = 0.f ) |
Saturate the array values based on the input interval [vmin, vmax] (the output amplitude is not modified).
This function adjusts the heightmap values to fit within the specified range [vmin, vmax]. Values outside the range [from_min, from_max] are clamped to [vmin, vmax]. The output amplitude of the heightmap remains unchanged.
| array | Input array representing the heightmap to be saturated. |
| vmin | The lower bound of the range to remap to. |
| vmax | The upper bound of the range to remap to. |
| from_min | The lower bound of the range to remap from. |
| from_max | The upper bound of the range to remap from. |
Example
Result
See unit tests: test_saturate.cpp
| void hmap::saturate_percentile | ( | Array & | array, |
| float | percentile_low, | ||
| float | percentile_high, | ||
| float | k = 0.f ) |
Saturate values based on percentile range.
Computes low/high bounds from percentiles and applies saturation scaling.
| array | Input array (modified in place). |
| percentile_low | Lower percentile [0–1]. |
| percentile_high | Upper percentile [0–1]. |
| k | Saturation strength. |
Example
Result
See unit tests: test_saturate.cpp
Apply a sharpening filter based on the Laplace operator.
This function applies a sharpening filter to the input array using the Laplace operator. The sharpening effect can be controlled by adjusting the ratio parameter, which determines the balance between the sharpened and non-sharpened output. A ratio of 1 applies full sharpening, while a ratio of 0 applies no sharpening.
| array | Input array representing the heightmap or image to be sharpened. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, sharpening is applied according to this mask. If not provided, the entire array is sharpened. |
| ratio | Ratio of the sharpening effect. A value of 1 applies full sharpening, while a value of 0 applies no sharpening. Default is 1. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply a sharpening filter based on a smooth cone filter.
This function applies a sharpening filter to the input array using a smooth cone filter. The sharpening effect can be controlled by the scale parameter, and the size of the smoothing operation is determined by the ir parameter. The optional filter mask allows selective application of the sharpening effect.
| array | Input array representing the heightmap or image to be sharpened. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, sharpening is applied according to this mask. If not provided, the entire array is sharpened. |
| ir | Filter radius, which determines the size of the smoothing operation. |
| scale | Sharpening scale. Adjusts the intensity of the sharpening effect. Default is 0.5. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::shrink | ( | Array & | array, |
| int | ir, | ||
| int | iterations = 1 ) |
Apply shrinking, or "deflating", to emphasize the ridges in the heightmap.
This function applies a shrinking filter to the input array, which accentuates the ridges by shrinking or deflating the terrain features. The filter radius ir determines the extent of the deflation. You can also apply the shrinking effect selectively using an optional filter mask. Additionally, an alternative method using a custom kernel is available.
| array | Input array representing the heightmap to be processed. |
| ir | Filter radius, which controls the extent of the shrinking effect. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, shrinking is applied according to this mask. If not provided, the entire array is processed. |
| kernel | Optional custom kernel to be used for the shrinking operation. If provided, this kernel will override the default filter radius. |
Example
Result
ex_expand This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::shrink_directional | ( | Array & | array, |
| int | ir, | ||
| float | angle, | ||
| float | aspect_ratio, | ||
| float | anisotropy = 1.f, | ||
| const Array * | p_mask = nullptr ) |
Apply directional shrinking, or "deflating", to emphasize the ridges in the terrain.
This function applies a directional shrinking filter to the input array, enhancing the ridges by shrinking or deflating the terrain features with respect to a specified direction. Parameters include filter radius ir, direction angle, aspect ratio, and anisotropy to control the shape and orientation of the filter. An optional filter mask can be used for selective application.
| array | Input array representing the heightmap to be processed. |
| ir | Filter radius, which controls the extent of the shrinking effect. |
| angle | Angle (in degrees) of the directional filter. |
| aspect_ratio | Pulse aspect ratio, which influences the shape of the filter. |
| anisotropy | Pulse width ratio between upstream and downstream sides. Default is 1. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, shrinking is applied according to this mask. If not provided, the entire array is processed. |
Example
Result
| void hmap::smooth_cone | ( | Array & | array, |
| int | ir ) |
Apply a convolution filter with a cone kernel to smooth the array.
This function performs convolution on the input array using a cone-shaped kernel. The cone radius ir determines the extent of the smoothing effect. An optional filter mask can be used for selective smoothing.
| array | Input array representing the heightmap or image to be smoothed. |
| ir | Cone radius, which controls the extent of the smoothing effect. The cone's half-width is half this radius. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, smoothing is applied according to this mask. If not provided, the entire array is processed. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::smooth_cpulse | ( | Array & | array, |
| int | ir, | ||
| const Array * | p_mask = nullptr, | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Apply filtering to the array using convolution with a cubic pulse kernel.
This function performs convolution on the input array using a cubic pulse kernel. It serves as an alternative to Gaussian smoothing, offering a more compact support with potentially faster computations. For direct comparison with Gaussian smoothing, the pulse radius ir should be set to twice the desired Gaussian half-width.
| array | Input array representing the heightmap or image to be smoothed. |
| ir | Pulse radius, where the half-width of the cubic pulse kernel is half of this value. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, filtering is applied according to this mask. If not provided, the entire array is processed. |
Example
Result
See unit tests: test_smooth_cpulse.cpp
| void hmap::smooth_cpulse_edge_removing | ( | Array & | array, |
| float | talus, | ||
| float | talus_width, | ||
| int | ir ) |
Smooths an array while attenuating edges using a gradient-based pulse.
This function first computes the gradient norm of the input array, applies a sigmoid filter to highlight or attenuate regions based on the local gradient magnitude, and then performs a constrained pulse smoothing pass that respects those gradient-based weights. This is useful for smoothing heightmaps or scalar fields while preserving significant edges such as ridges or cliffs.
| array | Reference to the input array to be smoothed. The array is modified in-place. |
| talus | Threshold value used in the sigmoid function to control where edge attenuation starts. Lower values affect more regions. |
| talus_width | Width (steepness) of the sigmoid transition zone around the talus threshold. |
| ir | Radius of the smoothing kernel used in the constrained pulse smoothing step. |
| void hmap::smooth_flat | ( | Array & | array, |
| int | ir ) |
Applies a smoothing average filter to the given 2D array in both dimensions.
This function creates a smoothing kernel of size (2 \times \text{ir} + 1) with uniform weights, then applies a 1D convolution along both the i (rows) and j (columns) dimensions of the array to achieve a 2D smoothing effect.
| array | Reference to the 2D array to be smoothed. |
| ir | Radius of the smoothing kernel, determining its size as (2 \times \text{ir} + 1). Larger values produce more smoothing. |
| void hmap::smooth_gaussian | ( | Array & | array, |
| int | ir ) |
Apply Gaussian filtering to the array.
This function performs convolution on the input array using a Gaussian kernel, which smooths the array by averaging values within a Gaussian-weighted neighborhood. The ir parameter specifies the Gaussian half-width, which influences the extent of the smoothing effect. An optional filter mask can be provided for selective filtering.
| array | Input array representing the heightmap or image to be smoothed. |
| ir | Gaussian half-width, which determines the extent of the smoothing effect. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, filtering is applied according to this mask. If not provided, the entire array is processed. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::smooth_fill | ( | Array & | array, |
| int | ir, | ||
| float | k = 0.1f, | ||
| Array * | p_deposition_map = nullptr ) |
Apply cubic pulse smoothing to fill lower flat regions while preserving some sharpness.
This function applies a cubic pulse smoothing technique to the input array, specifically designed to fill in lower flat regions without significantly impacting sharp features. It provides a more computationally efficient alternative to the thermal_auto_bedrock method. The p_deposition_map output field captures the amount of smoothing applied.
| array | Input array representing the heightmap or image to be processed. |
| ir | Pulse radius, which determines the extent of the smoothing effect. |
| k | Transition smoothing parameter in the range [0, 1]. It controls the balance between smoothing and preserving sharpness. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, smoothing is applied according to this mask. If not provided, the entire array is processed. |
| p_deposition_map | [out] Optional reference to the deposition map. This output field records the amount of deposition or smoothing applied. |
Example
Result
smooth_cpulse, thermal_auto_bedrock | void hmap::smooth_fill | ( | Array & | array, |
| int | ir, | ||
| const Array * | p_mask, | ||
| float | k = 0.1f, | ||
| Array * | p_deposition_map = nullptr ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::smooth_fill_holes | ( | Array & | array, |
| int | ir ) |
Apply smoothing to fill holes (elliptic concave surfaces).
This function applies a smoothing filter to the input array to fill in holes or concave surfaces. The goal is to smooth out regions that are concave, providing a more uniform appearance.
| array | Input array representing the heightmap or image to be processed. |
| ir | Filter radius, which controls the extent of the smoothing effect. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, smoothing is applied according to this mask. If not provided, the entire array is processed. |
Example
Result
smooth_fill_smear_peaks This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::smooth_fill_smear_peaks | ( | Array & | array, |
| int | ir ) |
Apply smoothing to smear peaks (elliptic convex surfaces).
This function applies a smoothing filter designed to reduce the prominence of peaks or convex surfaces in the input array. It smooths out convex regions, creating a more level surface.
| array | Input array representing the heightmap or image to be processed. |
| ir | Filter radius, which controls the extent of the smoothing effect. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, smoothing is applied according to this mask. If not provided, the entire array is processed. |
Example
Result
smooth_fill_holes This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::smoothstep_local | ( | Array & | array, |
| int | ir ) |
Applies a localized smoothstep operation to the provided array.
This function modifies the input array using a localized smoothstep operation. It calculates the local minimum and maximum values within a radius (ir) and smooths the values in the array based on these bounds.
| array | The 2D array to be smoothed. |
| ir | The radius used to compute the local minimum and maximum values. |
Example
Result
Applies a localized smoothstep operation to the provided array with an optional mask.
If a mask is provided, the function blends the smoothed values with the original array using the mask. Otherwise, it directly applies the localized smoothstep operation.
| array | The 2D array to be smoothed. |
| ir | The radius used to compute the local minimum and maximum values. |
| p_mask | A pointer to an optional mask array. If provided, the smoothed array is blended with the original using this mask. |
Example
Result
| void hmap::steepen | ( | Array & | array, |
| float | scale, | ||
| int | ir = 8 ) |
Steepen (or flatten) the array map.
This function applies a steepening effect to the input array, enhancing the contrast of the gradients or flattening features based on the given filter amplitude. The effect is controlled by the scale parameter, and the ir parameter defines the filtering radius for computing the array gradients.
| array | Input array representing the heightmap or image to be processed. |
| scale | Filter amplitude that determines the extent of steepening or flattening. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, steepening is applied according to this mask. If not provided, the entire array is processed. |
| ir | Filtering radius of the array gradients, which influences the extent of the effect. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::steepen_convective | ( | Array & | array, |
| float | angle, | ||
| int | iterations = 1, | ||
| int | ir = 0, | ||
| float | dt = 0.1f ) |
Steepen array values by applying a nonlinear convection operator in a given direction.
This function applies a nonlinear convection operator to the input array, simulating the effect described by Burger's equation. The steepening effect is applied in the specified direction (angle) and is controlled by several parameters including the number of iterations, smoothing radius, and time step. The input array values are expected to be in the range [-1, 1].
| array | Input array with elements expected to be in the range [-1, 1]. |
| angle | Steepening direction in degrees. |
| iterations | Number of iterations to perform the convection process. |
| ir | Smoothing radius applied to the array values before differentiation. |
| dt | Time step for the convection process, can be chosen smaller than 1 for finer tuning of the steepening effect. |
| p_mask | Optional filter mask, expected in the range [0, 1]. If provided, steepening is applied according to this mask. If not provided, the entire array is processed. |
Example
Result
| void hmap::steepen_convective | ( | Array & | array, |
| float | angle, | ||
| const Array * | p_mask, | ||
| int | iterations = 1, | ||
| int | ir = 0, | ||
| float | dt = 0.1f ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::terrace | ( | Array & | array, |
| std::uint32_t | seed, | ||
| int | nlevels, | ||
| float | gain = 0.9f, | ||
| float | noise_ratio = 0.f, | ||
| const Array * | p_noise = nullptr, | ||
| float | vmin = 0.f, | ||
| float | vmax = -1.f ) |
Applies a terrace effect to the values in an array.
This function adjusts the values in the array by applying a terrace or stepped effect, often used for terrain generation or other natural-looking height variations. The terrace effect is controlled by several parameters such as the number of levels, gain, noise ratio, and optional min/max range. The noise is applied to levels for added randomness, and a gain function is applied to smooth the transitions.
| array | The array of values to modify with the terrace effect. |
| seed | Seed value for random number generation. |
| nlevels | Number of terrace levels to apply. |
| gain | Gain factor for controlling the sharpness of the terrace levels, in [0, 1]. |
| noise_ratio | Ratio of noise applied to each terrace level, except the first and last. |
| p_noise | Optional noise array to introduce additional variation per element. |
| vmin | Minimum value for terracing; if less than vmax, will be auto-determined. |
| vmax | Maximum value for terracing; if less than vmin, will be auto-determined. |
Example
Result
| void hmap::terrace | ( | Array & | array, |
| std::uint32_t | seed, | ||
| int | nlevels, | ||
| const Array * | p_mask, | ||
| float | gain = 0.9f, | ||
| float | noise_ratio = 0.f, | ||
| const Array * | p_noise = nullptr, | ||
| float | vmin = 0.f, | ||
| float | vmax = -1.f ) |
Applies a terrace effect to an array with optional masking.
This overloaded version of the terrace function modifies array based on the terrace levels, gain, noise ratio, and an optional mask array. If a mask is provided, the terrace effect is applied conditionally based on the mask values.
| array | The array of values to modify with the terrace effect. |
| seed | Seed value for random number generation. |
| nlevels | Number of terrace levels to apply. |
| p_mask | Optional mask array. If provided, blends the terrace effect with original values based on the mask. |
| gain | Gain factor for controlling the sharpness of the terrace levels, in [0, 1]. |
| noise_ratio | Ratio of noise applied to each terrace level, except the first and last. |
| p_noise | Optional noise array to introduce additional variation per element. |
| vmin | Minimum value for terracing; if less than vmax, will be auto-determined. |
| vmax | Maximum value for terracing; if less than vmin, will be auto-determined. |
This function:
Example
Result
| std::function< float(float, float)> hmap::make_xy_function_from_array | ( | const Array & | array, |
| const BBox2D & | bbox = BBox2D::unit() ) |
Create a continuous 2D function from a sampled array.
This adaptor takes a discrete 2D array (indexed by i, j) defined over a bounding box and returns a continuous function \(f(x, y)\) that interpolates values at arbitrary 2D positions inside the bounding box.
| array | Input array containing sampled values on a regular grid. |
| bbox | Bounding box of the array in world coordinates, given as (xmin, xmax, ymin, ymax). |
| decltype(auto) hmap::with_noise_function | ( | NoiseType | noise_type, |
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| Fn && | fn ) |
Dispatch a noise functor based on the specified noise type.
| noise_type | The type of noise function to create (e.g., PERLIN, SIMPLEX2, etc.). |
| kw | The frequency scaling vector to be used for the noise function. |
| seed | The random seed for noise generation. |
| fn | Callable invoked with the concrete noise functor. |
| void hmap::add_line_bresenham | ( | CellPath & | out, |
| glm::ivec2 | a, | ||
| glm::ivec2 | b ) |
Rasterizes a segment between two integer points using Bresenham's algorithm.
Ensures full grid connectivity by filling all intermediate integer cells between points a and b.
| out | Output container receiving the rasterized points. |
| a | Start point. |
| b | End point. |
| void hmap::add_noise | ( | CellPath & | path, |
| std::uint32_t | seed, | ||
| float | kw, | ||
| float | amp, | ||
| const glm::ivec2 & | shape, | ||
| NoiseType | noise_type = NoiseType::PERLIN, | ||
| int | octaves = 8, | ||
| float | weight = 0.7f, | ||
| float | persistence = 0.5f, | ||
| float | lacunarity = 2.f ) |
Applies transverse noise displacement along an integer path.
The function computes a global direction from first to last point, derives a perpendicular axis, and displaces each point using procedural noise.
| path | Input/output integer path to deform. |
| seed | Random seed for noise generation. |
| kw | Noise spatial frequency (scale). |
| amp | Maximum displacement amplitude. |
| shape | Optional domain scaling / bounds for noise sampling. |
| noise_type | Type of procedural noise to use. |
| octaves | Number of noise octaves for fractal noise. |
| weight | Blend factor between octaves. |
| persistence | Amplitude decay per octave. |
| lacunarity | Frequency increase per octave. |
Example
Result
| void hmap::enforce_path_adjacency | ( | CellPath & | path | ) |
Ensures that an integer path is grid-adjacent and gap-free.
Reconstructs the path so that every consecutive step moves to a neighboring grid cell (8-connected), filling missing cells if needed.
| path | Input/output path to repair and densify. |
| bool hmap::is_path_adjacent | ( | const CellPath & | path | ) |
Checks if a grid path has no gaps (8-connectivity).
Verifies that each consecutive cell is adjacent using Moore neighborhood (max |dx| <= 1 and max |dy| <= 1).
| path | Input path of grid cells. |
| Array hmap::cloud_sdf_to_array | ( | const Cloud & | cloud, |
| glm::ivec2 | shape, | ||
| const BBox2D & | bbox_array = BBox2D::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
Compute a distance field from a point cloud.
| cloud | Input point cloud. |
| shape | Output array dimensions. |
| bbox_array | Bounding box of the output domain. |
| p_noise_x | Optional x-direction noise (domain warp). |
| p_noise_y | Optional y-direction noise (domain warp). |
Checks whether the point cloud contains duplicate points.
| cloud | Input point cloud. |
| eps | Distance tolerance for considering two points identical. |
| xy_only | If true, compares only the X and Y coordinates. |
| std::vector< float > hmap::interpolate_values_from_array | ( | const Cloud & | cloud, |
| const Array & | array, | ||
| const BBox2D & | bbox ) |
Interpolate values from an array at the points' (x, y) locations.
This method computes interpolated values for each point in the cloud based on its (x, y) coordinates and an underlying array, using bilinear interpolation within the specified bounding box.
| array | The input array from which to interpolate values. |
| bbox | The bounding box of the array. |
Merges two point clouds into one.
| cloud1 | The first point cloud to be merged. This cloud will be the base cloud to which the points from the second cloud are added. |
| cloud2 | The second point cloud whose points will be appended to the first cloud. |
Merges multiple point clouds into a single cloud.
| clouds | A vector of Cloud objects to be merged. |
| Cloud hmap::random_cloud | ( | size_t | count, |
| std::uint32_t | seed, | ||
| const PointSamplingMethod & | method = PointSamplingMethod::RND_LHS, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates a random cloud of points within a bounding box.
| count | Number of points to generate. |
| seed | Random number generator seed. |
| method | Sampling method to use. Defaults to PointSamplingMethod::RND_RANDOM. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
Example
Result
| Cloud hmap::random_cloud_density | ( | size_t | count, |
| const Array & | density, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates a random cloud of points based on a spatial density map.
The probability of placing a point at a location is proportional to the density value at that location.
| count | Number of points to generate. |
| density | 2D array representing spatial density values. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
Example
Result
| Cloud hmap::random_cloud_inverse_sampling | ( | size_t | count, |
| const Array & | density, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates a random cloud of points using inverse transform sampling on a 2D density array.
| count | Number of points to generate. |
| density | 2D array representing spatial density values. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
| Cloud hmap::random_cloud_distance | ( | float | min_dist, |
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates a random cloud of points separated by at least a given minimum distance.
Points are distributed randomly but maintain a minimum separation, producing a blue-noise-like distribution.
| min_dist | Minimum allowed distance between any two points. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
Example
Result
| Cloud hmap::random_cloud_distance | ( | float | min_dist, |
| float | max_dist, | ||
| const Array & | density, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates a random cloud of points separated by a distance range, influenced by a density map.
Points maintain a separation between min_dist and max_dist, and are distributed according to the provided density map.
| min_dist | Minimum allowed distance between points. |
| max_dist | Maximum allowed distance between points. |
| density | 2D array representing spatial density values. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
Example
Result
| Cloud hmap::random_cloud_distance_power_law | ( | float | dist_min, |
| float | dist_max, | ||
| float | alpha, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates a random cloud of points with distances drawn from a power-law distribution.
Distances between points follow a power-law distribution between dist_min and dist_max, with exponent alpha.
| dist_min | Minimum possible distance between points. |
| dist_max | Maximum possible distance between points. |
| alpha | Power-law exponent (larger alpha favors shorter distances). |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
Example
Result
| Cloud hmap::random_cloud_distance_weibull | ( | float | dist_min, |
| float | lambda, | ||
| float | k, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates a random cloud of points with distances drawn from a Weibull distribution.
Distances between points follow a Weibull distribution parameterized by lambda (scale) and k (shape).
| dist_min | Minimum possible distance between points. |
| lambda | Weibull distribution scale parameter. |
| k | Weibull distribution shape parameter. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
Example
Result
| Cloud hmap::random_cloud_jittered | ( | size_t | count, |
| const glm::vec2 & | jitter_amount, | ||
| const glm::vec2 & | stagger_ratio, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates a jittered grid cloud of points.
Points are placed on a grid and then offset by a jitter amount, optionally staggered for a more irregular pattern.
| count | Number of points to generate. |
| jitter_amount | Maximum jitter to apply in each axis (x, y). |
| stagger_ratio | Ratio of staggering between consecutive rows or columns. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
Example
Result
| void hmap::rejection_filter_density | ( | Cloud & | cloud, |
| const Array & | density_mask, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Filter a point cloud using rejection sampling based on a density mask.
Each point in the input cloud is retained or discarded according to a spatially varying probability derived from the provided 2D density mask. The mask is mapped to the bounding box and evaluated as a continuous function over the domain.
| density_mask | 2D array defining the spatial density field over the bounding box. Values should lie in \([0,1]\). |
| seed | Random seed used for reproducible rejection sampling. |
| bbox | Bounding box (xmin, ymin, xmax, ymax) defining the spatial extent of the density mask in world coordinates. |
Scales the point coordinates in a cloud relative to a center point.
Scales the (x, y) coordinates of all points in the cloud relative to a specified center point while preserving each point's value (v). A scale factor smaller than 1 shrinks the point distribution toward the center (creating a margin from domain boundaries), while a scale factor greater than 1 expands it.
| cloud | Input point cloud. |
| scale | Scale factor(s) for x and y axes. |
| center | Center of scaling (defaults to (0.5, 0.5)). |
| int hmap::convert_length_to_pixel | ( | float | x, |
| int | nx, | ||
| bool | lim_inf = true, | ||
| bool | lim_sup = false, | ||
| float | scale = 1.f ) |
Converts a length value to a pixel index in a discretized space.
This function maps a floating-point length x to an integer pixel index, considering the total number of pixels nx and a scaling factor scale. Optionally, it can enforce lower and upper limits on the output index.
| x | The length value to be converted. |
| nx | The number of pixels in the discretized space. |
| lim_inf | If nonzero, enforces a minimum index of 1. |
| lim_sup | If nonzero, enforces a maximum index of nx - 1. |
| scale | The scaling factor relating the length to the pixel space. |
| void hmap::grid_xy_vector | ( | std::vector< float > & | x, |
| std::vector< float > & | y, | ||
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| bool | endpoint = false ) |
Return x and y coordinates of a regular grid, as two 1D vectors.
| x[out] | Vector x. |
| y[out] | Vector y. |
| shape | Shape. |
| bbox | Bounding box. |
| endpoint | Include or not the endpoint. |
| void hmap::rescale_grid_from_unit_square_to_bbox | ( | std::vector< float > & | x, |
| std::vector< float > & | y, | ||
| const UvRect & | uv_rect ) |
Rescale 1D grid vectors from unit square [0, 1] to target UV rectangle.
| x[in,out] | Vector x. |
| y[in,out] | Vector y. |
| uv_rect | Target UV rectangle. |
| Path hmap::bezier | ( | const Path & | path, |
| float | curvature_ratio = 0.3f, | ||
| int | edge_divisions = 10, | ||
| Path::EdgeDivisionMode | edm = Path::EdgeDivisionMode::EDM_PER_EDGE ) |
Smooth the path using Bezier curves.
This method applies Bezier curve smoothing to the path. The curvature_ratio controls the amount of curvature applied, with typical values in the range of [-1, 1], where positive values generally result in more pronounced curvature. The edge_divisions parameter determines the number of subdivisions per edge to create a smoother curve.
Example
Result
| curvature_ratio | Amount of curvature, usually in the range [-1, 1], with positive values resulting in more curvature. |
| edge_divisions | Number of subdivisions per edge to achieve smooth curves. |
| edm | The mode for dividing edges. Default is Path::EdgeDivisionMode::EDM_PER_EDGE. |
See unit tests: test_splines.cpp
| Path hmap::bezier_round | ( | const Path & | path, |
| float | curvature_ratio = 0.3f, | ||
| int | edge_divisions = 10, | ||
| Path::EdgeDivisionMode | edm = Path::EdgeDivisionMode::EDM_PER_EDGE ) |
Smooth the path using Bezier curves (alternative method).
This alternative method applies Bezier curve smoothing to the path. The curvature_ratio parameter affects the curvature amount, similar to the bezier method. The edge_divisions parameter specifies how finely each edge is divided to create a smoother curve.
Example
Result
| curvature_ratio | Amount of curvature, typically within [-1, 1], with positive values for increased curvature. |
| edge_divisions | Number of edge subdivisions for smoothness. |
| edm | The mode for dividing edges. Default is Path::EdgeDivisionMode::EDM_PER_EDGE. |
See unit tests: test_splines.cpp
| Path hmap::bspline | ( | const Path & | path, |
| int | edge_divisions = 10, | ||
| Path::EdgeDivisionMode | edm = Path::EdgeDivisionMode::EDM_PER_EDGE ) |
Smooth the path using B-Spline curves.
This method smooths the path using B-Spline curves, which provide a smooth curve that passes through the control points. The edge_divisions parameter defines the number of subdivisions per edge for achieving smooth curves.
Important: This function does not correctly handle closed polylines (circular contours). If the path is closed, the smoothing may not correctly close the loop, potentially leaving a gap between the start and end points.
Example
Result
| edge_divisions | Number of subdivisions per edge to achieve a smooth B-Spline curve. |
| edm | Mode for dividing edges. Default is EDM_PER_EDGE. |
See unit tests: test_splines.cpp
| Path hmap::catmullrom | ( | const Path & | path, |
| int | edge_divisions = 10, | ||
| Path::EdgeDivisionMode | edm = Path::EdgeDivisionMode::EDM_PER_EDGE ) |
Smooth the path using Catmull-Rom curves.
This method applies Catmull-Rom curve smoothing to the path. Catmull-Rom splines are interpolating splines that pass through each control point. The edge_divisions parameter determines the number of subdivisions per edge for smoothing.
| edge_divisions | Number of edge subdivisions to create a smooth Catmull-Rom curve. |
| edm | Mode for dividing edges. Default is EDM_PER_EDGE. |
Example
Result
See unit tests: test_splines.cpp
| Path hmap::decasteljau | ( | const Path & | path, |
| int | edge_divisions = 10, | ||
| Path::EdgeDivisionMode | edm = Path::EdgeDivisionMode::EDM_PER_EDGE ) |
Smooth the path using De Casteljau curves.
This function smooths a path by applying De Casteljau's algorithm to generate intermediate points along the path, effectively creating a Bézier curve that approximates the original path. The path is divided into segments, and the De Casteljau algorithm is applied to each segment, resulting in a smooth curve.
The parameter edge_divisions controls the number of divisions (sub-segments) created along each segment of the path. A higher number of divisions will result in a smoother curve, but will also increase the computational cost.
| edge_divisions | The number of divisions for each edge of the path. Default is 10, which provides a balanced level of smoothing. |
| edm | Mode for dividing edges (default is EDM_PER_EDGE). |
Example
Result
See unit tests: test_splines.cpp
Simplifies the current path using the Visvalingam-Whyatt algorithm.
This method reduces the number of points in the path to the specified target, n_points_target, while preserving the overall shape. It calculates the area of triangles formed by consecutive points and removes points corresponding to the smallest areas iteratively.
| path | The input path to be decimated. |
| n_points_target | The desired number of points to retain in the path. If the current number of points is less than n_points_target or the path contains fewer than 3 points, the method returns without modifying the path. |
Example
Result
See unit tests: test_decimate_vw.cpp
| Path hmap::fractalize | ( | const Path & | path, |
| int | iterations, | ||
| std::uint32_t | seed, | ||
| float | sigma = 0.2f, | ||
| int | orientation = 0, | ||
| float | persistence = 1.f, | ||
| Array * | p_control_field = nullptr, | ||
| const BBox2D & | bbox = BBox2D{}, | ||
| bool | bounded = false ) |
Applies fractalization to the path by adding points and randomly displacing their positions.
This method enhances the complexity of a path by iteratively adding new points between existing ones and displacing them using Gaussian noise. The process can simulate natural phenomena like terrain generation or random walk paths. The number of iterations determines the level of detail added to the path.
| path | The input path to be fractalized. |
| iterations | Number of iterations to apply the fractalization process. |
| seed | Seed value for random number generation, ensuring reproducibility. |
| sigma | Standard deviation of the Gaussian displacement, relative to the distance between points. |
| orientation | Determines the displacement direction: 0 for random, 1 for inflation, -1 for deflation. |
| persistence | Factor that adjusts the noise intensity across iterations. |
| control_field | Optional pointer to an array that locally modifies the displacement amplitude. |
| bbox | Bounding box that defines the valid area for the control field's influence. |
| bounded | If true, clamps each newly displaced midpoint to the bounding box defined by the initial edge it belongs to. Defaults to false. |
Example
Result
Inflate (offset) a path along its normals using curvature.
Each point is displaced along its normal direction by an amount proportional to local curvature and the given radius.
| path | Input path |
| radius | Inflation radius (scales displacement) |
| resample | If true, resample output to preserve spatial resolution |
Example
Result
| Path hmap::meanderize | ( | const Path & | path, |
| float | ratio, | ||
| float | noise_ratio = 0.1f, | ||
| std::uint32_t | seed = 1, | ||
| int | iterations = 1, | ||
| int | edge_divisions = 10, | ||
| Path::EdgeDivisionMode | edm = Path::EdgeDivisionMode::EDM_PER_EDGE ) |
Add "meanders" to the path.
This method introduces meandering effects to the path by adding random deviations. The amplitude of the meanders is controlled by the ratio parameter, while the noise_ratio controls the amount of randomness. The seed parameter is used to initialize the random number generator, ensuring reproducibility. The iterations parameter defines how many times the meandering process is applied, and edge_divisions controls how finely each edge is subdivided during the meandering.
| path | The input path to be meanderized. |
| ratio | Amplitude ratio of the meanders. Typically a positive value. |
| noise_ratio | Ratio of randomness introduced during meandering. Default is 0.1. |
| seed | Seed for random number generation. Default is 1. |
| iterations | Number of iterations to apply meandering. Default is 1. |
| edge_divisions | Number of sub-divisions of each edge. Default is 10. |
| edm | The mode for dividing edges during the meandering process. Default is EDM_PER_EDGE. |
Example
Result
| Array hmap::path_sdf_bezier_to_array | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const BBox2D & | bbox_array = BBox2D::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| bool | use_bvh = true ) |
Converts a 2D path treated as a piecewise quadratic Bezier curve to a signed distance field (SDF) array.
For each grid cell, computes the distance to the nearest point on the Bezier curves formed by consecutive point triplets, optionally applying domain warping using noise fields.
| path | Input point path. |
| shape | Output array dimensions. |
| bbox_array | Bounding box of the output domain. |
| p_noise_x | Optional x-direction noise (domain warp). |
| p_noise_y | Optional y-direction noise (domain warp). |
| use_bvh | Whether to use BVH acceleration (default: true). |
| Array hmap::path_sdf_bezier_to_array_brute_force | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const BBox2D & | bbox_array = BBox2D::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::path_sdf_bezier_to_array_bvh | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const BBox2D & | bbox_array = BBox2D::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::path_sdf_to_array | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const BBox2D & | bbox_array = BBox2D::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| bool | use_bvh = true ) |
Compute a distance field from a point path.
For each grid cell, computes the distance to the nearest point in the path, optionally applying domain warping using noise fields.
| path | Input point path. |
| shape | Output array dimensions. |
| bbox_array | Bounding box of the output domain. |
| p_noise_x | Optional x-direction noise (domain warp). |
| p_noise_y | Optional y-direction noise (domain warp). |
| use_bvh | Whether to use BVH acceleration (default: true). |
| Array hmap::path_sdf_to_array_brute_force | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const BBox2D & | bbox_array = BBox2D::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::path_sdf_to_array_bvh | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const BBox2D & | bbox_array = BBox2D::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
Removes geometric loops in a 2D path caused by self-intersections.
This function iteratively detects self-intersections in the path and removes the segments forming loops, optionally inserting the exact intersection points.
| path | The input path as a vector of 2D points. |
Example
Result
Scales the point coordinates in a path relative to a center point.
Scales the (x, y) coordinates of all points in the path relative to a specified center point while preserving each point's value (v) and the open/closed state of the path. A scale factor smaller than 1 shrinks the point distribution toward the center (creating a margin from domain boundaries), while a scale factor greater than 1 expands it.
| path | Input path. |
| scale | Scale factor(s) for x and y axes. |
| center | Center of scaling (defaults to (0.5, 0.5)). |
Example
Result
| Path hmap::smooth | ( | const Path & | path, |
| int | navg = 1, | ||
| float | averaging_intensity = 1.f, | ||
| float | inertia = 0.f ) |
Applies a smoothing operation to the path points using a moving average filter.
This method smooths the path points based on a specified number of neighboring points, an averaging intensity, and an inertia factor. The smoothing involves calculating the average of neighboring points within a range defined by navg, and then applying an intensity-based weighted average to blend the original and smoothed values. Additionally, an inertia effect can be applied to gradually adjust point positions based on previous points.
| path | The input path to be smoothed. |
| navg | Number of neighboring points to consider on each side of the current point during the smoothing process. Higher values result in broader smoothing. |
| averaging_intensity | The weight given to the averaged points. A value of 1.0 applies full intensity, resulting in a complete averaging of the neighboring points. Lower values retain more of the original point's position. |
| inertia | The factor by which each point is influenced by its previous point after the initial smoothing pass. A value of 0 has no inertia effect, while a higher value blends the current point's position with that of the preceding point, creating a trailing effect. |
Example
Result
| Path hmap::squiggle | ( | const Path & | path, |
| int | iterations = 4, | ||
| std::uint32_t | seed = 0, | ||
| float | height_ratio = 0.5f, | ||
| int | orientation = 0, | ||
| const Array * | p_weights = nullptr, | ||
| const Array * | p_mask = nullptr, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates a continuous, non-self-intersecting squiggle curve by applying the squiggle recursive triangle subdivision algorithm to each edge of the input path.
Implements the squiggle curve construction from Prusinkiewicz et al., "Generating Mountainous Terrain". Constrained within domain triangles for each edge, ensuring continuity and absence of self-intersections.
| path | The input path to apply the squiggle algorithm to. |
| iterations | Number of recursive subdivision levels per edge (e.g., 2 to 6). |
| seed | Random seed number for deterministic edge selection. |
| height_ratio | Height of the bounding triangle relative to edge length (default 0.5). |
| orientation | Displacement direction: 0 to alternate sides, 1 for positive normal, -1 for negative normal. |
| p_weights | Optional pointer to an Array defining spatial weights to bias path progression. |
| p_mask | Optional pointer to a binary/mask Array (1 = allowed, 0 = forbidden) preventing the path from entering forbidden areas. |
| bbox | Bounding box for spatial sampling. |
Example
Result
Reference: Prusinkiewicz et al., Generating Mountainous Terrain (1993).
| std::vector< Path > hmap::squiggle_branches | ( | const Path & | path, |
| int | iterations = 4, | ||
| std::uint32_t | seed = 0, | ||
| float | branch_probability = 0.3f, | ||
| int | max_branches = 8, | ||
| float | height_ratio = 0.5f, | ||
| int | orientation = 0, | ||
| const Array * | p_weights = nullptr, | ||
| const Array * | p_mask = nullptr, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates squiggle paths with secondary tributary branches along each edge.
| path | The input path. |
| iterations | Number of recursive subdivision levels. |
| seed | Random seed number. |
| branch_probability | Probability of initiating a tributary branch at subdivision steps. |
| max_branches | Maximum number of secondary branches. |
| height_ratio | Height of the bounding triangle relative to edge length. |
| orientation | Displacement direction: 0 to alternate sides, 1 for positive normal, -1 for negative normal. |
| p_weights | Optional spatial weights Array. |
| p_mask | Optional mask Array. |
| bbox | Bounding box for array sampling. |
| Path hmap::truncate_at_first_intersection | ( | const Path & | path, |
| const std::vector< Path > & | existing_paths ) |
Truncates a path at its first intersection with any path in a given set of existing paths. The intersection point is included as the new end point.
| path | The input path to be truncated. |
| existing_paths | Collection of already existing paths. |
| bool hmap::assert_start_end_points | ( | const Path & | path1, |
| const Path & | path2, | ||
| float | tol = 1e-6f, | ||
| bool | verbose = false ) |
Asserts that the start and end points of two paths are within a specified tolerance.
| path1 | The first path to compare. |
| path2 | The second path to compare. |
| tol | Tolerance for comparing the start and end points. Default is 1e-6f. |
| verbose | If true, prints detailed information during comparison. Default is false. |
Calculate the chamfer distance between two paths.
| a | The first path. |
| b | The second path. |
Check if a path contains duplicate points within a given tolerance.
| path | The path to check for duplicates. |
| tol | Tolerance for considering two points as the same. Default is 1e-6. |
Computes the angle between two points relative to the x-axis.
| p1 | The starting point of the vector. |
| p2 | The ending point of the vector. |
Computes the angle formed by three points with p0 as the origin.
| p0 | The reference point (origin). |
| p1 | The first point defining the angle. |
| p2 | The second point defining the angle. |
| float hmap::classify_point | ( | const Point & | p_prev, |
| const Point & | p, | ||
| const Point & | p_next, | ||
| const Point & | pq ) |
Classify point convexity relative to neighboring curve vertices.
Computes the 2D cross product of vectors (p1 - p0) and (p2 - p0).
| p0 | Common origin point. |
| p1 | First destination point. |
| p2 | Second destination point. |
Computes the 2D cross product of vectors p1 and p2.
| p1 | First vector. |
| p2 | Second vector. |
Calculates the curvature formed by three points in 2D space.
| p1 | The first point. |
| p2 | The second point. |
| p3 | The third point. |
Calculates the signed curvature formed by three points in 2D space.
Calculates the Euclidean distance between two points.
| p1 | The first point. |
| p2 | The second point. |
Calculates the squared Euclidean distance between two points.
| p1 | The first point. |
| p2 | The second point. |
| Point hmap::interp_bezier | ( | const Point & | p_start, |
| const Point & | p_ctrl_start, | ||
| const Point & | p_ctrl_end, | ||
| const Point & | p_end, | ||
| float | t ) |
Performs a cubic Bezier interpolation.
| p_start | The first control point (start point). |
| p_ctrl_start | The second control point. |
| p_ctrl_end | The third control point. |
| p_end | The fourth control point (end point). |
| t | The interpolation parameter, ranging from 0 to 1. |
| Point hmap::interp_bspline | ( | const Point & | p0, |
| const Point & | p1, | ||
| const Point & | p2, | ||
| const Point & | p3, | ||
| float | t ) |
Performs a cubic B-spline interpolation.
| p0 | The first control point. |
| p1 | The second control point (start of segment). |
| p2 | The third control point (end of segment). |
| p3 | The fourth control point. |
| t | The interpolation parameter, ranging from 0 to 1. |
| Point hmap::interp_catmullrom | ( | const Point & | p0, |
| const Point & | p1, | ||
| const Point & | p2, | ||
| const Point & | p3, | ||
| float | t ) |
Performs a Catmull-Rom spline interpolation.
| p0 | The first control point. |
| p1 | The second control point (start of segment). |
| p2 | The third control point (end of segment). |
| p3 | The fourth control point. |
| t | The interpolation parameter, ranging from 0 to 1. |
Performs a De Casteljau algorithm-based interpolation for Bezier curves.
| points | A vector of control points defining the Bezier curve. |
| t | The interpolation parameter, ranging from 0 to 1. |
Determines the intersection of two bounding boxes.
| bbox1 | The first bounding box defined as glm::vec4. |
| bbox2 | The second bounding box defined as glm::vec4. |
Checks if a point is within a specified bounding box.
| p | The point to check. |
| bbox | Bounding box {xmin, xmax, ymin, ymax}. |
| bool hmap::is_point_within_bounding_box | ( | float | x, |
| float | y, | ||
| const BBox2D & | bbox ) |
Checks if a point with coordinates (x, y) is within a specified bounding box.
| x | The x-coordinate. |
| y | The y-coordinate. |
| bbox | Bounding box {xmin, xmax, ymin, ymax}. |
Linearly interpolates between two points.
| p1 | The starting point. |
| p2 | The ending point. |
| t | The interpolation factor (0 <= t <= 1). |
| Point hmap::midpoint | ( | const Point & | p1, |
| const Point & | p2, | ||
| int | orientation, | ||
| float | distance_ratio, | ||
| float | t = 0.5f ) |
Computes the midpoint displacement with a perpendicular offset.
| p1 | The first point. |
| p2 | The second point. |
| orientation | Orientation of the perpendicular displacement. |
| distance_ratio | Ratio of displacement relative to segment length. |
| t | Interpolation factor along segment (default 0.5). |
Scales a point relative to a center point.
| p | The input point. |
| scale | Scale factor(s) for x and y axes. |
| center | Center of scaling (defaults to (0.5, 0.5)). |
Scales a point uniformly relative to a center point.
| std::optional< Point > hmap::segment_intersection | ( | const Point & | p1, |
| const Point & | p2, | ||
| const Point & | q1, | ||
| const Point & | q2 ) |
Computes the intersection point of two 2D segments, if it exists.
| p1 | Start point of first segment. |
| p2 | End point of first segment. |
| q1 | Start point of second segment. |
| q2 | End point of second segment. |
Determines the relative side of a query point with respect to a curve segment.
| p1 | Preceding curve point. |
| p2 | Reference curve point. |
| p3 | Succeeding curve point. |
| p_query | Query point to test. |
| void hmap::sort_points | ( | std::vector< Point > & | points | ) |
Sorts a vector of points in ascending order (x, then y, then v).
| points | Vector of points to sort in-place. |
Calculates the unsigned area of a triangle formed by three points.
| p1 | The first point. |
| p2 | The second point. |
| p3 | The third point. |
Calculates the signed area of a triangle formed by three points.
| p1 | The first point. |
| p2 | The second point. |
| p3 | The third point. |
| BBox2D hmap::unit_square_bbox | ( | ) |
Constructs a 4D bounding box for a unit square {0, 1, 0, 1}.
| std::array< std::pair< float, float >, 2 > hmap::bbox_to_ranges2d | ( | const BBox2D & | bbox | ) |
Converts a 2D bounding box into coordinate ranges.
This function takes a bounding box defined by four values (xmin, xmax, ymin, ymax) stored in a glm::vec4 and returns an array of two ranges:
| bbox | Bounding box in the format {xmin, xmax, ymin, ymax}. |
| void hmap::expand_points_domain | ( | std::vector< float > & | x, |
| std::vector< float > & | y, | ||
| std::vector< float > & | value, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Expand grid by translating and copying the values of the current bounding box to the 8 first neighboring bounding boxes.
| x | x coordinates. |
| y | y coordinates. |
| value | values. |
| bbox | Bounding box. |
| void hmap::expand_points_at_domain_boundaries | ( | std::vector< float > & | x, |
| std::vector< float > & | y, | ||
| std::vector< float > & | value, | ||
| const BBox2D & | bbox = BBox2D{}, | ||
| float | boundary_value = 0.f ) |
Expand the grid by adding points on the boundaries of the bounding box.
| x | x coordinates. |
| y | y coordinates. |
| value | values. |
| bbox | Bounding box. |
| corner_value | Value at the boundary points. |
| void hmap::expand_points_domain_corners | ( | std::vector< float > & | x, |
| std::vector< float > & | y, | ||
| std::vector< float > & | value, | ||
| const BBox2D & | bbox = BBox2D{}, | ||
| float | corner_value = 0.f ) |
Expand the grid by adding four points at the corner of the bounding box.
| x | x coordinates. |
| y | y coordinates. |
| value | values. |
| bbox | Bounding box. |
| corner_value | Value at the four corner points. |
| std::function< float(const ps::Point< float, 2 > &)> hmap::make_pointwise_function_from_array | ( | const Array & | array, |
| const BBox2D & | bbox ) |
Create a continuous 2D function from a sampled array.
This adaptor takes a discrete 2D array (indexed by i, j) defined over a bounding box and returns a continuous function \(f(x, y)\) that interpolates values at arbitrary 2D positions inside the bounding box.
The function maps a point \(p = (x, y)\) in world coordinates to array indices \((i, j)\) and interpolates the array values.
| array | Input array containing sampled values on a regular grid. |
| bbox | Bounding box of the array in world coordinates, given as (xmin, xmax, ymin, ymax). |
| std::array< std::vector< float >, 2 > hmap::random_points | ( | size_t | count, |
| std::uint32_t | seed, | ||
| const PointSamplingMethod & | method = PointSamplingMethod::RND_RANDOM, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates random 2D points within a bounding box using a sampling method.
| count | Number of points to generate. |
| seed | Random number generator seed. |
| method | Sampling method to use. Defaults to PointSamplingMethod::RND_RANDOM. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
| std::array< std::vector< float >, 2 > hmap::random_points_density | ( | size_t | count, |
| const Array & | density, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates random 2D points within a bounding box based on a density map.
Points are sampled with probability proportional to the density values.
| count | Number of points to generate. |
| density | 2D array representing spatial density values. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
| std::array< std::vector< float >, 2 > hmap::random_points_inverse_sampling | ( | size_t | count, |
| const Array & | array, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates random 2D points within a bounding box using inverse transform sampling on a 2D density array.
Points are sampled according to continuous row-marginal and conditional column cumulative distributions interpolated from the 2D array.
| count | Number of points to generate. |
| array | 2D array representing spatial density / probability field. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
| std::array< std::vector< float >, 2 > hmap::random_points_distance | ( | float | min_dist, |
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates random 2D points with a minimum separation distance.
Produces a blue-noise-like distribution where no two points are closer than min_dist.
| min_dist | Minimum allowed distance between points. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
| std::array< std::vector< float >, 2 > hmap::random_points_distance | ( | float | min_dist, |
| float | max_dist, | ||
| const Array & | density, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates random 2D points with distance constraints and a density map.
Points are separated by distances between min_dist and max_dist, and are sampled proportionally to the given density map.
| min_dist | Minimum allowed distance between points. |
| max_dist | Maximum allowed distance between points. |
| density | 2D array representing spatial density values. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
| std::array< std::vector< float >, 2 > hmap::random_points_distance_power_law | ( | float | dist_min, |
| float | dist_max, | ||
| float | alpha, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates random 2D points with distances drawn from a power-law distribution.
Distances between points follow a power-law distribution between dist_min and dist_max, with exponent alpha.
| dist_min | Minimum possible distance between points. |
| dist_max | Maximum possible distance between points. |
| alpha | Power-law exponent (larger alpha favors shorter distances). |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
| std::array< std::vector< float >, 2 > hmap::random_points_distance_weibull | ( | float | dist_min, |
| float | lambda, | ||
| float | k, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates random 2D points with distances drawn from a Weibull distribution.
Distances between points follow a Weibull distribution parameterized by lambda (scale) and k (shape).
| dist_min | Minimum possible distance between points. |
| lambda | Weibull distribution scale parameter. |
| k | Weibull distribution shape parameter. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
| std::array< std::vector< float >, 2 > hmap::random_points_jittered | ( | size_t | count, |
| const glm::vec2 & | jitter_amount, | ||
| const glm::vec2 & | stagger_ratio, | ||
| std::uint32_t | seed, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Generates jittered grid-based 2D points.
Points are placed on a regular grid, offset by jitter_amount, and optionally staggered according to stagger_ratio.
| count | Number of points to generate. |
| jitter_amount | Maximum jitter to apply in each axis (x, y). |
| stagger_ratio | Ratio of staggering between consecutive rows or columns. |
| seed | Random number generator seed. |
| bbox | Bounding box in which to generate the points (a,b,c,d = xmin, xmax, ymin, ymax). Defaults to the unit square {0.f, 1.f, 0.f, 1.f}. |
| void hmap::remove_points_outside_bbox | ( | std::vector< float > & | x, |
| std::vector< float > & | y, | ||
| std::vector< float > & | value, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Remove grid points that are outside a given bounding box.
| x | x coordinates. |
| y | y coordinates. |
| value | Values at points. |
| bbox | Bounding box. |
| void hmap::rescale_points_to_unit_square | ( | std::vector< float > & | x, |
| std::vector< float > & | y, | ||
| const BBox2D & | bbox ) |
Rescale coordinate (x, y) so that they fit in a unit-square box based on a given initial bounding box.
| x[in,out] | x coordinates (output). |
| y[in,out] | y coordinates (output). |
| bbox | Initial bounding box. |
Compute the divergence of a 2D gradient field.
Given two scalar fields representing the horizontal and vertical derivatives of a height map:
\[ p(x, y) = \frac{\partial h}{\partial x}, \qquad q(x, y) = \frac{\partial h}{\partial y} \]
this function returns the divergence:
\[ f(x, y) = \frac{\partial p}{\partial x}(x, y) + \frac{\partial q}{\partial y}(x, y) \]
The divergence is a key term for solving the Poisson equation \(\nabla^2 h = f\) when reconstructing a height field from gradients or from a normal map.
| dx | Array of horizontal derivatives ( \(\partial h / \partial x\)). Must have the same dimensions as dy. |
| dy | Array of vertical derivatives ( \(\partial h / \partial y\)). Must have the same dimensions as dx. |
See unit tests: test_gradient.cpp
| std::vector< float > hmap::gradient1d | ( | const std::vector< float > & | v | ) |
Compute the gradient of a 1D vector.
This function calculates the gradient of a 1D vector by computing the difference between successive elements.
| v | Input vector of floats. |
Compute the polar angle of the gradient of a 2D array.
This function calculates the gradient angle of a 2D array, which represents the direction of the steepest ascent. The angle is measured in radians and falls within the range [-π, π]. The direction can be inverted if the downward flag is set to true.
| array | Input 2D array. |
| downward | If true, invert the direction of the gradient. |
Example
Result
See unit tests: test_gradient.cpp
| Array hmap::gradient_angle_circular_smoothing | ( | const Array & | array, |
| int | ir, | ||
| bool | downward = false ) |
Computes a smoothed gradient angle (aspect) field with circular unwrapping.
This function computes the gradient angle (aspect) of the input scalar field and applies a circular smoothing to remove discontinuities caused by the ±π wrap of the arctangent. The angle field is smoothed by converting the angle to a unit vector representation on the circle, applying a local smoothing kernel, and converting it back to an angle. This results in a continuous aspect map that is ideal for visualization or further processing.
| array | Input scalar field (e.g., a heightmap). |
| ir | Radius of the local smoothing kernel applied to the angle vectors. |
| downward | If set to true, angles are adjusted to point in the downslope direction (useful for hydrology or flow simulations). If false, angles point in the upslope direction. |
Example
Result
Compute the gradient norm of a 2D array.
This function calculates the gradient norm (magnitude) of a 2D array. Optionally, the x and y gradients can be computed and stored in p_dx and p_dy respectively.
| array | Input 2D array. |
| p_dx | Pointer to an Array where the x-gradient will be stored (optional). |
| p_dy | Pointer to an Array where the y-gradient will be stored (optional). |
Example
Result
See unit tests: test_gradient.cpp
Compute a smoothed gradient magnitude map.
The input array is downsampled by a factor of ir, the gradient norm is computed on the lower-resolution array, scaled back to the original units, and finally upsampled to the original resolution using bicubic interpolation.
| array | Input array. |
| ir | Downsampling factor (> 0). |
Example
Result
| Array hmap::gradient_norm_prewitt | ( | const Array & | array, |
| Array * | p_dx = nullptr, | ||
| Array * | p_dy = nullptr ) |
Compute the gradient norm of a 2D array using the Prewitt filter.
This function calculates the gradient norm (magnitude) using the Prewitt filter for gradient computation. Optionally, the x and y gradients can be computed and stored in p_dx and p_dy respectively.
| array | Input 2D array. |
| p_dx | Pointer to an Array where the x-gradient will be stored (optional). |
| p_dy | Pointer to an Array where the y-gradient will be stored (optional). |
Example
Result
See unit tests: test_gradient.cpp
| Array hmap::gradient_norm_scharr | ( | const Array & | array, |
| Array * | p_dx = nullptr, | ||
| Array * | p_dy = nullptr ) |
Compute the gradient norm of a 2D array using the Scharr filter.
This function calculates the gradient norm (magnitude) using the Scharr filter for gradient computation. Optionally, the x and y gradients can be computed and stored in p_dx and p_dy respectively.
| array | Input 2D array. |
| p_dx | Pointer to an Array where the x-gradient will be stored (optional). |
| p_dy | Pointer to an Array where the y-gradient will be stored (optional). |
See unit tests: test_gradient.cpp
| Array hmap::gradient_norm_sobel | ( | const Array & | array, |
| Array * | p_dx = nullptr, | ||
| Array * | p_dy = nullptr ) |
Compute the gradient norm of a 2D array using the Sobel filter.
This function calculates the gradient norm (magnitude) using the Sobel filter for gradient computation. Optionally, the x and y gradients can be computed and stored in p_dx and p_dy respectively.
| array | Input 2D array. |
| p_dx | Pointer to an Array where the x-gradient will be stored (optional). |
| p_dy | Pointer to an Array where the y-gradient will be stored (optional). |
See unit tests: test_gradient.cpp
Compute the gradient talus slope of a 2D array.
The talus slope is defined as the largest elevation difference between a cell and its immediate neighbors. This function computes the talus slope for the given 2D array.
| array | Input 2D array. |
See unit tests: test_gradient.cpp
Compute the gradient talus slope and store it in the provided array.
This overload computes the gradient talus slope of a 2D array and stores the result in the given talus array.
| array | Input 2D array. |
| talus | Output array where the gradient talus slope will be stored. |
See unit tests: test_gradient.cpp This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Compute the gradient in the x-direction of a 2D array.
This function calculates the gradient in the x-direction (i.e., horizontal gradient) for the given 2D array.
| array | Input 2D array. |
See unit tests: test_gradient.cpp
Compute the gradient in the x-direction of a 2D array and store it.
This overload calculates the gradient in the x-direction and stores the result in the provided dx array.
| array | Input 2D array. |
| dx | Output array where the gradient in the x-direction will be stored. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
Compute the gradient in the y-direction of a 2D array.
This function calculates the gradient in the y-direction (i.e., vertical gradient) for the given 2D array.
| array | Input 2D array. |
See unit tests: test_gradient.cpp
Compute the gradient in the y-direction of a 2D array and store it.
This overload calculates the gradient in the y-direction and stores the result in the provided dy array.
| array | Input 2D array. |
| dy | Output array where the gradient in the y-direction will be stored. This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. |
Compute the Laplacian of a 2D array.
The Laplacian is a measure of the second-order spatial derivative of the input array. This function computes the Laplacian for the given 2D array.
| array | Input 2D array. |
Example
Result
See unit tests: test_gradient.cpp
Generates a normal map from a given 2D array.
This function calculates the normal vectors for each element in the 2D array and returns them as a tensor. The normal map is commonly used in image processing and 3D graphics to represent surface orientations based on height values.
| array | A 2D array representing the height values from which normals are computed. |
Converts a normal map to a heightmap using direct summation of gradients.
This function computes a heightmap from a given normal map (nmap) by integrating gradients derived from the normal map in two passes. The result is the average of two independent integrations to reduce artifacts from directional bias.
| nmap | A 3D tensor representing the normal map. It should have three channels (X, Y, Z) and a shape of (width, height, 3). The values are assumed to be in the range [0, 1]. |
Result
| Array hmap::normal_map_to_heightmap_poisson | ( | const Texture & | nmap, |
| int | iterations = 500, | ||
| float | omega = 1.5f ) |
| void hmap::solve_poisson_gauss_seidel | ( | const Array & | rhs, |
| Array & | h, | ||
| int | iterations = 500, | ||
| float | omega = 1.0f ) |
Solve the Poisson equation ∇²h = rhs using Gauss–Seidel iteration.
This function assumes Dirichlet boundary conditions (height = 0 at the edges). The algorithm updates interior points according to:
\[ h(x, y) = (1 - \omega) h(x, y) + \omega \cdot 0.25 \big( h(x+1, y) + h(x-1, y) + h(x, y+1) + h(x, y-1) - rhs(x, y) \big) \]
| rhs | Right-hand side (divergence of gradients). |
| h | Height field to update; initialized to 0 or an estimate. |
| iterations | Number of Gauss–Seidel iterations to run. |
| omega | Relaxation parameter (1 = standard Gauss–Seidel, 1 < omega < 2 = over-relaxation). |
Unwraps a 2D phase array to correct discontinuities in phase data.
This function unwraps phase values in the given array, ensuring that discontinuities exceeding \( \pi \) are adjusted to provide a continuous phase result.
| alpha | A 2D array of wrapped phase values. |
Example
Result
Label drainage basins using a priority-flood algorithm.
Starting from boundary cells, this function floods a 2D scalar field inward using a height-ordered priority queue and assigns each cell to a basin. Each boundary cell initializes a unique basin.
Connectivity is 8-neighbor. Spill elevations between basins are detected but not yet recorded.
| z | Input 2D elevation array. |
z.Example
Result
| Array hmap::carve_riverbed | ( | const Array & | z, |
| const Array & | z_river, | ||
| float | talus_riverbank = 0.01f, | ||
| bool | smooth_river_bottom = true, | ||
| float | merging_distance = 8.f, | ||
| std::uint32_t | seed = 0, | ||
| float | riverbank_noise_ratio = 0.f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
Blends and carves smooth riverbanks around modified riverbed profiles.
Compares an initial elevation terrain z with an updated/carved riverbed z_river, identifies modified cells, expands riverbanks using talus slopes, smooths the channel bottom, and blends the carved river with the original terrain using distance-transform based exponential falloff and optional domain warping.
| z | Original terrain elevation array. |
| z_river | Carved riverbed elevation array (or stream bottom). |
| talus_riverbank | Talus slope angle/ratio for riverbank expansion. |
| smooth_river_bottom | Whether to apply Laplace smoothing along the river bottom. |
| merging_distance | Transition distance (in pixels) for blending riverbanks into terrain. |
| seed | Random seed for riverbank noise. |
| riverbank_noise_ratio | Noise ratio for talus expansion roughness. |
| p_noise_x | Optional noise array for domain warping in X. |
| p_noise_y | Optional noise array for domain warping in Y. |
Computes the number of drainage paths for each cell based on the D8 flow direction model.
This function calculates the number of neighboring cells that have flow directions pointing to the current cell according to the D8 model. The result is an array where each cell contains the count of its incoming flow directions.
| d8 | Input array representing the flow directions according to the D8 model. Each cell value indicates the direction of flow according to the D8 convention. |
| void hmap::find_flow_apex | ( | const Array & | z, |
| std::vector< int > & | is, | ||
| std::vector< int > & | js ) |
Identifies flow apex (source) cells using D8 flow routing.
A flow apex is defined as a cell with zero inflow neighbors (no upstream contributors) in the D8 flow graph. These cells correspond to drainage sources, ridge heads, or local flow origins.
| z | Input elevation field. |
| is | Output x-coordinates of flow apex cells. |
| js | Output y-coordinates of flow apex cells. |
| void hmap::find_flow_sinks | ( | const Array & | z, |
| std::vector< int > & | is, | ||
| std::vector< int > & | js ) |
Identifies the indices of flow sinks within the heightmap.
This function locates the cells in the heightmap that are flow sinks (cells with no outflow) and returns their indices. Flow sinks are cells that do not direct flow to any other cell.
| z | Input array representing the heightmap values. |
| is | Output vector containing the row indices i of the flow sinks. |
| js | Output vector containing the column indices j of the flow sinks. |
Example
| std::vector< glm::ivec2 > hmap::find_flow_sinks | ( | const Array & | z | ) |
Find interior flow sinks in a height field.
A sink is a cell whose 8 neighbors all have strictly higher elevation. Border cells are excluded.
| z | Input elevation grid. |
| std::vector< glm::ivec2 > hmap::find_flow_sinks_border | ( | const Array & | z | ) |
Find flow sinks located on the domain border.
A border cell is considered a sink if all its valid neighbors (within bounds) have strictly higher elevation.
| z | Input elevation grid. |
Compute water depth for a uniform flooding level.
Subtracts terrain elevation from a reference water level and clamps negative values to zero.
| z | Input elevation array. |
| zref | Reference water level. |
Example
Result
| Array hmap::flooding_from_boundaries | ( | const Array & | z, |
| float | zref, | ||
| bool | from_east = true, | ||
| bool | from_west = true, | ||
| bool | from_north = true, | ||
| bool | from_south = true, | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Compute flooding starting from the lowest boundary points.
Finds the lowest elevation on the selected boundaries and simulates flooding from those points up to a reference water level.
| z | Input elevation array. |
| zref | Reference water level. |
| from_east | Include east boundary. |
| from_west | Include west boundary. |
| from_north | Include north boundary. |
| from_south | Include south boundary. |
| region | Tile region metadata. |
| comm | Communicator for tiled / distributed execution. |
Example
Result
| Array hmap::flooding_from_point | ( | const Array & | z, |
| int | i, | ||
| int | j, | ||
| float | depth_min = std::numeric_limits<float>::max(), | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Flood terrain starting from a single seed point.
Fills areas below a reference level by propagating from the given cell until higher ground is reached.
| z | Input elevation array. |
| i | Seed point X index. |
| j | Seed point Y index. |
| depth_min | Water depth at the source point (if max, uses 0). |
Example
Result
| Array hmap::flooding_from_point | ( | const Array & | z, |
| const std::vector< int > & | i, | ||
| const std::vector< int > & | j, | ||
| float | depth_min = std::numeric_limits<float>::max(), | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Flood terrain starting from multiple seed points.
Merges flooding results from each point below the reference level.
| z | Input elevation array. |
| i | List of X indices for seeds. |
| j | List of Y indices for seeds. |
| depth_min | Water depth at the source point (if max, uses 0). |
| region | Tile region metadata. |
| comm | Communicator for tiled / distributed execution. |
Example
Result
| Array hmap::flooding_lake_system | ( | const Array & | z, |
| float | surface_threshold = 0.f, | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Estimate lake water depths on a terrain by filling depressions.
This function identifies depressions in a terrain elevation model and simulates the flooding of these areas to produce a lake system. It uses a rough depression-filling algorithm to compute the water surface, then subtracts the original elevations to obtain the water depth at each cell.
| z | Input 2D array representing terrain elevations (height field). |
| surface_threshold | The minimum number of pixels a component must have to be retained. Components smaller than this threshold will be removed. The default value is 0 (no filtering). |
| region | Tile region metadata (for tiled execution). |
| comm | Communicator for multi-tile synchronization. |
Example
Result
Computes the flow accumulation for each cell using the D8 flow direction model.
This function calculates the flow accumulation for each cell in the heightmap based on the D8 flow direction model [Zhou2019]. Flow accumulation represents the total amount of flow that accumulates at each cell from upstream cells.
| z | Input array representing the heightmap values. |
Example
Result
| Array hmap::flow_accumulation_stochastic | ( | const Array & | z, |
| int | n_samples = 1 << 19, | ||
| std::uint32_t | seed = 0, | ||
| const Array * | p_source = nullptr, | ||
| const Array * | p_decay = nullptr ) |
Computes flow accumulation using a stochastic (Monte-Carlo) transport estimator.
Particles are spawned uniformly, advected along the downhill gradient field with exact voxel traversal, attenuated by an optional decay term, and deposit flux into every cell they exit. A final analytic normalization yields the steady-state flux, including for cells no particle visited. Compared to flow_accumulation_d8, the result is smooth and free of axis-aligned artifacts.
Port of the reference implementation of "Stochastic Geomorphological Transport for Terrain Erosion Simulation" (N. McDonald, G. Cordonnier), https://github.com/erosiv/geotransport (MIT).
Results are reproducible up to floating-point summation order (deposits accumulate via unordered atomic adds).
| z | Input array representing the heightmap values. |
| n_samples | Number of Monte-Carlo samples (particles). |
| seed | Random seed number (deterministic for fixed inputs). |
| p_source | Optional per-cell source term (default: uniform 1). |
| p_decay | Optional per-cell decay rate (default: 0, pure accumulation). |
Example
Result
| Array hmap::flow_accumulation_dinf | ( | const Array & | z, |
| float | talus_ref = 0.1f, | ||
| int | iterations = 0, | ||
| const UvTile & | region = {}, | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Computes the flow accumulation for each cell using the Multiple Flow Direction (MFD) model.
This function calculates the flow accumulation for each cell based on the MFD model [Qin2007]. Flow accumulation represents the total amount of flow that accumulates at each cell from upstream cells. The flow-partition exponent is locally defined using a reference talus value, where smaller values of talus_ref will lead to narrower flow streams. The maximum talus value of the heightmap can be used as a reference.
| z | Input array representing the heightmap values. |
| talus_ref | Reference talus used to locally define the flow-partition exponent. Small values will result in thinner flow streams. |
| iterations | Maximum number of boundary exchange iterations across tiles (0 defaults to auto: grid diameter). |
| region | UvTile descriptor for tiled domain positioning. |
| comm | Communicator for multi-tile synchronization. |
Example
Result
| Array hmap::flow_accumulation_dinf_perturbed | ( | const Array & | z, |
| float | talus_ref, | ||
| int | nsamples, | ||
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| float | amp, | ||
| const Array * | p_perturb_scaling = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| int | iterations = 0, | ||
| const UvTile & | region = {}, | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Computes averaged D-infinity flow accumulation with terrain perturbations.
This function estimates flow accumulation using the D∞ (D-infinity) method by perturbing the input elevation map multiple times with Perlin noise. For each sample, a noise field is added to the terrain, the flow accumulation is computed, and results are accumulated and averaged.
The perturbation introduces stochastic variability, which can help reduce numerical artifacts and improve robustness in flat or ambiguous flow regions.
| z | Input elevation array. |
| talus_ref | Reference talus angle (or slope threshold) used by the D∞ algorithm. |
| nsamples | Number of noise-perturbed samples to average. |
| kw | Noise frequency scaling factor. |
| seed | Base random seed (incremented for each sample). |
| amp | Amplitude of the noise perturbation. |
| bbox | Bounding box used for noise generation. |
| iterations | Maximum number of boundary exchange iterations across tiles (0 defaults to auto). |
| region | UvTile descriptor for tiled domain positioning. |
| comm | Communicator for multi-tile synchronization. |
Example
Result
Computes the flow direction from each cell to its downslope neighbor using the D8 model.
This function calculates the direction of flow for each cell in the heightmap using the D8 flow direction model [Greenlee1987]. The D8 model defines eight possible flow directions as follows:
5 6 7 4 . 0 3 2 1 *
| z | Input array representing the heightmap values. |
Computes the flow direction and weights for each direction using the Multiple Flow Direction (MFD) model.
This function calculates the flow direction for each cell and provides the weight for each possible flow direction using the MFD model [Qin2007]. The flow-partition exponent is determined using a reference talus value. Smaller values of talus_ref will lead to thinner flow streams. The maximum talus value of the heightmap can be used as a reference.
| z | Input array representing the heightmap values. |
| talus_ref | Reference talus used to locally define the flow-partition exponent. Smaller values will result in thinner flow streams. |
| std::vector< float > hmap::flow_direction_dinf_flat | ( | const Array & | z, |
| float | talus_ref ) |
Computes the flow direction using the Multiple Flow Direction (MFD) model.
| Array hmap::flow_fixing | ( | const Array & | z, |
| float | riverbed_talus = 0.f, | ||
| int | iterations = 5, | ||
| int | prefilter_ir = 8, | ||
| bool | carve_riverbed = true, | ||
| float | merging_distance = 8.f, | ||
| const Array * | p_noise_r = nullptr ) |
| Array hmap::flow_fixing_drainage_basin | ( | const Array & | z, |
| bool | fast_approx = false, | ||
| float | riverbed_talus = 1e-4f, | ||
| int | iterations = 3, | ||
| bool | carve_riverbed = false, | ||
| float | talus_riverbank = 0.01f, | ||
| float | merging_distance = 8.f, | ||
| std::uint32_t | seed = 0, | ||
| float | noise_strength = 0.f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
Fixes flow paths and unwanted upslopes using a cell-based drainage basin tree network and elevation updates.
This function constructs a stream tree network on the heightmap, resolves internal depressions/lakes towards boundary outlets, and iteratively adjusts terrain elevations along upstream-downstream paths to guarantee unbroken flow while preserving realistic terrain slope gradients.
| z | Input elevation array. |
| iterations | Number of iterative tree-building and elevation update passes. |
| min_slope | Minimum allowed downslope gradient along flow paths. |
| max_slope | Maximum allowed slope gradient. |
| uplift_rate | Rate of elevation adjustment / uplift per unit response time. |
| m_exp | Drainage area exponent for response time calculations. |
| seed | Random seed for stochastic receiver variations. |
| noise_strength | Strength of random perturbation during receiver computation. |
| carve_riverbed | Whether to apply riverbank carving and smoothing along altered paths. |
| talus_riverbank | Talus value used when expanding and carving the riverbed. |
| merging_distance | Distance (in pixels) for blending modified flow paths. |
| p_noise_x | Optional noise array for riverbank domain warping in X. |
| p_noise_y | Optional noise array for riverbank domain warping in Y. |
| Array hmap::flow_fixing_mst | ( | const Array & | z, |
| float | riverbed_talus = 0.f, | ||
| float | elevation_ratio = 0.95f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| float | valley_affinity = 0.5f, | ||
| int | prefilter_ir = 8, | ||
| float | minimum_depth = 1e-4f, | ||
| bool | carve_riverbed = true, | ||
| float | merging_distance = 8.f, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP_UPPER, | ||
| float | radial_profile_parameter = 2.f, | ||
| const Array * | p_noise_r = nullptr, | ||
| bool | use_midpoint = false, | ||
| float | offset_ratio = 0.2f ) |
Resolves flow sinks and unwanted upslopes using Dijkstra pathfinding and a Minimum Spanning Tree (MST) over sinks and boundary outlets.
This function identifies all flow sinks and boundary outlets, computes candidate optimal path connections via multi-source Dijkstra search, constructs a Minimum Spanning Forest (Kruskal's algorithm) guaranteeing that each sink connects to an outlet through the lowest-effort saddle pass, and carves monotonic riverbeds along the MST paths using continuous trench profiles.
| z | Input elevation array. |
| riverbed_talus | Minimum talus (slope) along carved riverbeds. |
| elevation_ratio | Balance factor between elevation level and slope in Dijkstra cost. |
| distance_exponent | Exponent applied to elevation differences in Dijkstra cost. |
| upward_penalization | Penalty factor for uphill moves in Dijkstra search. |
| valley_affinity | Weight for valley/concavity affinity in cost. |
| prefilter_ir | Radius of Gaussian/cpulse prefilter applied before sink detection. |
| minimum_depth | Minimum incision depth below initial terrain elevation. |
| carve_riverbed | Whether to apply riverbank carving and smoothing along altered paths. |
| merging_distance | Distance (in pixels) for blending modified flow paths. |
| radial_profile | Radial profile cross-section for trench carving. |
| use_midpoint | Whether to use midpoint displacement pathfinding instead of classical Dijkstra. |
| offset_ratio | Midpoint displacement amplitude ratio. |
| std::vector< Path > hmap::flow_fixing_mst_paths | ( | const TerrainTriMesh & | mesh, |
| float | riverbed_talus = 0.f, | ||
| float | elevation_ratio = 0.95f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| float | minimum_depth = 1e-4f ) |
Computes river flow paths resolving depressions via Minimum Spanning Tree (MST) on a triangular terrain mesh.
Sinks are identified as local minima on the mesh (excluding boundary vertices). Multi-source Dijkstra expansion computes saddle passes between sinks and the boundary outlet, Kruskal's MST establishes optimal connectivity, and directed paths are reconstructed with monotonic downstream elevation profiles.
| mesh | Input triangular terrain mesh. |
| riverbed_talus | Minimum talus (slope) along resolved paths. |
| elevation_ratio | Weight for absolute elevation in Dijkstra step cost. |
| distance_exponent | Exponent applied to upward elevation changes. |
| upward_penalization | Penalty factor for uphill moves. |
| minimum_depth | Minimum incision depth below mesh vertex elevations. |
| std::vector< Path > hmap::flow_fixing_mst_paths | ( | const Array & | z, |
| size_t | control_points_count = 2048, | ||
| std::uint32_t | seed = 0, | ||
| float | riverbed_talus = 0.f, | ||
| float | elevation_ratio = 0.95f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| float | minimum_depth = 1e-4f ) |
Computes river flow paths resolving depressions via Minimum Spanning Tree (MST) on a triangular mesh generated from a heightmap.
Generates a jittered triangular mesh from the heightmap, solves the MST flow graph, and extracts a set of trenchable Path objects.
| z | Input elevation array. |
| control_points_count | Number of mesh control vertices sampled. |
| seed | Random seed for vertex distribution. |
| riverbed_talus | Minimum talus (slope) along resolved paths. |
| elevation_ratio | Weight for absolute elevation in Dijkstra step cost. |
| distance_exponent | Exponent applied to upward elevation changes. |
| upward_penalization | Penalty factor for uphill moves. |
| minimum_depth | Minimum incision depth below terrain elevation. |
| Array hmap::flow_fixing_mst_triangulated | ( | const Array & | z, |
| size_t | control_points_count = 2048, | ||
| std::uint32_t | seed = 0, | ||
| float | riverbed_talus = 0.f, | ||
| float | elevation_ratio = 0.95f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| float | minimum_depth = 1e-4f, | ||
| float | merging_distance = 8.f, | ||
| RadialProfile | radial_profile = RadialProfile::RP_SMOOTHSTEP_UPPER, | ||
| float | radial_profile_parameter = 2.f, | ||
| const Array * | p_noise_r = nullptr ) |
Resolves flow sinks on a heightmap by computing an MST on a triangular mesh and carving the resulting river paths with trenching.
| z | Input elevation array. |
| control_points_count | Number of mesh control vertices sampled. |
| seed | Random seed for vertex distribution. |
| riverbed_talus | Minimum talus (slope) along carved riverbeds. |
| elevation_ratio | Weight for absolute elevation in Dijkstra step cost. |
| distance_exponent | Exponent applied to upward elevation changes. |
| upward_penalization | Penalty factor for uphill moves. |
| minimum_depth | Minimum incision depth below terrain elevation. |
| merging_distance | Trench width in pixels. |
| radial_profile | Radial profile cross-section for trench carving. |
| radial_profile_parameter | Parameter for radial profile shaping. |
| p_noise_r | Optional noise array for radial trench perturbation. |
| Path hmap::flow_stream | ( | const Array & | z, |
| const glm::ivec2 | ij_start, | ||
| const float | elevation_ratio = 0.5f, | ||
| const float | distance_exponent = 2.f, | ||
| const float | upward_penalization = 100.f, | ||
| const std::vector< Path > & | existing_streams = {}, | ||
| const int | valley_radius = 2, | ||
| const float | valley_factor = 0.35f, | ||
| const bool | truncate_at_intersection = false ) |
Computes the optimal flow path from a starting point to the boundary of a given elevation array.
This function finds the flow path on a grid represented by the input array z, starting from the given point ij_start. It identifies the best path to the boundary, minimizing upward elevation penalties while accounting for distance and elevation factors.
| z | The input 2D array representing elevation values. |
| ij_start | The starting point as a 2D vector of indices (i, j) within the array. |
| elevation_ratio | Weight for elevation difference in the cost function (default: 0.5). |
| distance_exponent | Exponent for the distance term in the cost function (default: 2.0). |
| upward_penalization | Penalty factor for upward elevation changes (default: 100.0). |
| existing_streams | Existing flow streams to favor merging with (default: {}). |
| valley_radius | Radius around existing stream cells to apply depression (default: 2). |
| valley_factor | Attenuation factor per distance unit in valley depression (default: 0.35). |
| truncate_at_intersection | Truncate path at first intersection with an existing stream (default: false). |
The output path consists of:
Example
Result
| Path hmap::flow_stream | ( | const TerrainTriMesh & | mesh, |
| size_t | start_vertex_index, | ||
| float | elevation_ratio = 0.5f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 100.f, | ||
| bool | favor_domain_center = false, | ||
| const std::vector< Path > & | existing_streams = {}, | ||
| float | valley_radius = 0.02f, | ||
| float | valley_factor = 0.35f, | ||
| bool | truncate_at_intersection = false ) |
Computes the optimal flow path from a starting vertex to the boundary of a terrain triangular mesh.
| mesh | Input triangular terrain mesh. |
| start_vertex_index | Index of the starting vertex. |
| elevation_ratio | Weight for elevation difference in the cost function (default: 0.5). |
| distance_exponent | Exponent for the distance/elevation term (default: 2.0). |
| upward_penalization | Penalty factor for upward elevation changes (default: 100.0). |
| favor_domain_center | Favor passing through the center of the domain (default: false). |
| existing_streams | Existing flow streams to favor merging with (default: {}). |
| valley_radius | Radius around existing stream cells to apply attraction (default: 0.02). |
| valley_factor | Attenuation factor per distance unit in valley attraction (default: 0.35). |
| truncate_at_intersection | Truncate path at first intersection with an existing stream (default: false). |
| Path hmap::flow_stream | ( | const TerrainTriMesh & | mesh, |
| glm::vec2 | xy_start, | ||
| float | elevation_ratio = 0.5f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 100.f, | ||
| bool | favor_domain_center = false, | ||
| const std::vector< Path > & | existing_streams = {}, | ||
| float | valley_radius = 0.02f, | ||
| float | valley_factor = 0.35f, | ||
| bool | truncate_at_intersection = false ) |
Computes the optimal flow path from starting 2D coordinates to the boundary of a terrain triangular mesh.
| mesh | Input triangular terrain mesh. |
| xy_start | Starting coordinates (x, y) in [0, 1]. |
| elevation_ratio | Weight for elevation difference in the cost function (default: 0.5). |
| distance_exponent | Exponent for the distance/elevation term (default: 2.0). |
| upward_penalization | Penalty factor for upward elevation changes (default: 100.0). |
| favor_domain_center | Favor passing through the center of the domain (default: false). |
| existing_streams | Existing flow streams to favor merging with (default: {}). |
| valley_radius | Radius around existing stream cells to apply attraction (default: 0.02). |
| valley_factor | Attenuation factor per distance unit in valley attraction (default: 0.35). |
| truncate_at_intersection | Truncate path at first intersection with an existing stream (default: false). |
| Array hmap::generate_riverbed | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| bool | bezier_smoothing = false, | ||
| float | depth_start = 0.01f, | ||
| float | depth_end = 1.f, | ||
| float | slope_start = 64.f, | ||
| float | slope_end = 32.f, | ||
| float | shape_exponent_start = 1.f, | ||
| float | shape_exponent_end = 10.f, | ||
| float | k_smoothing = 0.5f, | ||
| int | post_filter_ir = 0, | ||
| Array * | p_noise_x = nullptr, | ||
| Array * | p_noise_y = nullptr, | ||
| Array * | p_noise_r = nullptr ) |
Generates a 2D array representing a riverbed based on a specified path.
This function calculates a scalar depth field (dz) for a riverbed shape using a path, which can optionally be smoothed with Bezier curves. It supports noise perturbation and post-filtering to adjust the riverbed's features.
| path | The input path defining the riverbed's trajectory. |
| shape | The dimensions of the output array (width, height). |
| bbox | The bounding box for the output grid in world coordinates. |
| bezier_smoothing | Flag to enable or disable Bezier smoothing of the path. |
| depth_start | The depth at the start of the riverbed. |
| depth_end | The depth at the end of the riverbed. |
| slope_start | The slope multiplier at the start of the riverbed. |
| slope_end | The slope multiplier at the end of the riverbed. |
| shape_exponent_start | The shape exponent at the start of the riverbed. |
| shape_exponent_end | The shape exponent at the end of the riverbed. |
| k_smoothing | The smoothing factor for the riverbed shape adjustments. |
| post_filter_ir | The radius of the post-filtering operation for smoothing the output. |
| p_noise_x | Optional pointer to a noise array for perturbing the x-coordinates. |
| p_noise_y | Optional pointer to a noise array for perturbing the y-coordinates. |
| p_noise_r | Optional pointer to a noise array for perturbing the radial function. |
Example
Result
| Graph hmap::hydrology_paths_to_graph | ( | const std::vector< Path > & | paths, |
| float | snap_tolerance = 1e-4f ) |
Convert a collection of hydrology flow paths into a connected Graph.
Path points within snap_tolerance Euclidean distance are welded into shared nodes, connecting tributaries and main river channels while preserving only the active river network (avoiding dense background meshes).
| paths | Vector of flow paths. |
| snap_tolerance | Spatial distance tolerance for snapping vertices. |
Merge two water depth fields.
Computes the maximum (or smoothed maximum) of two depth arrays.
| depth1 | First water depth array. |
| depth2 | Second water depth array. |
| k_smooth | Smoothing parameter (0 = sharp max). |
| Array hmap::snow_melting_map | ( | const Array & | z, |
| float | melt_start_elevation = 0.f, | ||
| float | melt_end_elevation = 0.5f, | ||
| float | elevation_strength = 1.f, | ||
| float | elevation_exp = 1.f, | ||
| float | sun_azimuth = 0.f, | ||
| float | sun_zenith = 60.f, | ||
| float | aspect_strength = 0.f, | ||
| float | slope_exp = 1.f, | ||
| float | slope_strength = 0.f ) |
Generate a spatial snow melting map from terrain features.
Computes a melting factor in [0,1] from elevation, slope, and sun exposure. Low elevations, steep slopes, and sun-facing orientations increase melting.
| z | Input terrain elevation. |
| melt_start_elevation | Elevation where melting starts (no melt below). |
| melt_end_elevation | Elevation where melting reaches full effect. |
| elevation_exp | Exponent controlling elevation melt falloff. |
| sun_azimuth | Sun azimuth angle in degrees. |
| sun_zenith | Sun zenith angle in degrees. |
| aspect_strength | Weight of sun exposure contribution. |
| slope_exp | Exponent controlling slope sensitivity. |
| slope_strength | Weight of slope contribution. |
Example
Result
| Array hmap::water_depth_from_mask | ( | const Array & | z, |
| const Array & | mask, | ||
| float | mask_threshold = 0.f, | ||
| int | iterations_max = 10000, | ||
| float | tolerance = 1e-2f ) |
Compute water depth over a masked terrain using harmonic interpolation.
This function estimates the water depth above a terrain surface by solving a Laplace equation on the domain defined by mask. The solution is obtained using the harmonic interpolation method with Successive Over-Relaxation (SOR). The resulting water depth is given by the difference between the interpolated surface and the original terrain elevation.
| z | Input 2D array representing the terrain elevations (height field). |
| mask | Mask array of the same shape as z. Values greater than mask_threshold define regions where water can accumulate, while lower values represent boundaries or fixed terrain. |
| mask_threshold | Threshold used to convert mask into a binary field (0 or 1) for identifying water/terrain boundaries. |
| iterations_max | Maximum number of SOR iterations used in the harmonic interpolation. |
| tolerance | Convergence criterion: the algorithm stops if the maximum absolute update between iterations is less than this value. |
Example
Result
| void hmap::water_depth_dry_out | ( | Array & | water_depth, |
| float | dry_out_ratio = 0.5f, | ||
| const Array * | p_mask = nullptr, | ||
| float | depth_max = std::numeric_limits<float>::max() ) |
Apply a drying factor to a water depth field.
This function reduces the water depth values in-place by multiplying them by a given dry_out_ratio. If a mask is provided, the drying is applied only where the mask is non-zero, allowing selective drying of specific regions.
| water_depth | Reference to the 2D array containing water depth values. The array is modified in-place. |
| dry_out_ratio | Multiplicative factor (typically between 0 and 1) used to scale down the water depth. A value of 1 leaves the depth unchanged, while 0 removes all water. |
| p_mask | Optional pointer to a mask array of the same shape as water_depth. Drying is applied only where the mask has non-zero values. If nullptr, the factor is applied uniformly to all cells. |
| depth_max | Maximum water depth, computed automatically by default. |
Example
Result
| Array hmap::water_depth_increase | ( | const Array & | water_depth, |
| const Array & | z, | ||
| float | additional_depth ) |
Simulates a local increase in water depth without global reflooding.
This function propagates an additional water depth over a terrain elevation map (z), starting only from cells that already contain water in the input water_depth array. The propagation is restricted to neighboring cells of higher elevation (8-connectivity), preventing the formation of entirely new flooded basins disconnected from the original water region.
Unlike water_depth_increase_with_flooding(), this function does not perform a full flooding simulation of the domain. It is primarily intended for expanding or softening an existing water mask slightly beyond the current shoreline.
| water_depth | Input array representing the initial water depth. |
| z | Elevation array corresponding to the same grid as water_depth. |
| additional_depth | Additional water depth to propagate from the existing water region. |
Example
Result
| Array hmap::water_depth_increase_with_flooding | ( | const Array & | water_depth, |
| const Array & | z, | ||
| float | additional_depth ) |
Simulates a physical rise in water level with full domain flooding.
This function increases the water level by additional_depth and recomputes flooding over the terrain elevation map (z). Unlike water_depth_increase(), the propagation is not restricted to the vicinity of the original water region: water may spread through connected terrain and flood previously dry areas if they become reachable under the new water level.
The simulation behaves more like a physical flooding process where rising water can overflow barriers, connect basins, and eventually inundate large portions of the domain depending on terrain topology.
| water_depth | Input array representing the initial water depth. |
| z | Elevation array corresponding to the same grid as water_depth. |
| additional_depth | Additional water depth used to raise the global water level. |
Example
Result
| Array hmap::water_frontier_curvature | ( | const Array & | water_depth, |
| int | prefilter_ir, | ||
| bool | extend_values_from_interface = false ) |
Compute the curvature of the water interface from a signed distance field.
The interface curvature is evaluated from the level set built from the water depth mask. Optionally, curvature values can be extended away from the interface using closest-point propagation.
| water_depth | Water depth field. |
| prefilter_ir | Prefilter radius used for curvature evaluation. |
| extend_values_from_interface | Extend interface curvature values to the full domain using closest boundary points. |
Example
Result
Generates a binary mask representing water presence.
This version of the function converts the given water depth array into a binary mask where non-zero values indicate the presence of water.
| water_depth | Input array representing water depth values. |
Example
Result
Computes a gradient-based water mask using an extended water depth model.
This function computes a smooth mask indicating regions that would be newly flooded when the water depth is artificially increased by a specified additional amount. It uses water_depth_increase() to simulate the spread of water over the terrain.
| water_depth | Input array representing the current water depth. |
| z | Elevation array corresponding to the same grid as water_depth. |
| additional_depth | The amount of additional water depth to simulate. |
Example
Result
| bool hmap::assert_almost_equal | ( | const Array & | a, |
| const Array & | b, | ||
| float | tolerance = 1e-6f, | ||
| const std::string & | fname = "", | ||
| AssertResults * | p_results = nullptr ) |
| void hmap::print_array | ( | const Array & | arr, |
| bool | show_coords = false, | ||
| int | width = 6, | ||
| int | precision = 2 ) |
| void hmap::dump_visual_check | ( | const Array & | array, |
| const std::string & | fname = "check.png" ) |
|
inline |
|
inline |
|
inline |
| std::filesystem::path hmap::add_filename_suffix | ( | const std::filesystem::path & | file_path, |
| const std::string & | suffix ) |
Adds a suffix to the filename of a given file path.
This function appends a given suffix to the stem (base name without extension) of a file while preserving the original directory and file extension.
| file_path | The original file path. |
| suffix | The suffix to append to the filename. |
Example
| std::filesystem::path hmap::make_unique_temp_dir | ( | const std::string & | prefix | ) |
Create a unique temporary directory.
Creates and returns a unique directory inside the system temporary directory using the given prefix.
| prefix | Directory name prefix. |
| std::string hmap::zfill | ( | const std::string & | str, |
| int | n_zero ) |
Pads the beginning of a string with zeros until it reaches a specified length.
This function prepends '0' characters to the input string str so that the resulting string has at least n_zero characters. If str is already equal to or longer than n_zero, it is returned unchanged.
| str | The input string to pad. |
| n_zero | The minimum total length of the resulting string after padding. |
Example
|
inlinenodiscard |
Validates that array dimensions are strictly positive.
| shape | Dimensions {x, y} to check. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that an array is initialized, non-empty, and has a consistent buffer size.
| array | Array to check. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that a container or object with an empty() method is not empty.
| container | Container to check. |
| name | Name or description of the container for logging. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that a container has at least min_size elements.
| container | Container to check. |
| min_size | Minimum required number of elements. |
| name | Name or description of the container for logging. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that two arrays have identical shapes and buffer sizes.
| a | First array. |
| b | Second array. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that an array has the expected 2D shape.
| shape | Expected shape {x, y}. |
| b | Array to check. |
| loc | Source location of the caller. |
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
Validates that two Textures have matching 2D shapes.
| a | First texture. |
| b | Second texture. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that a slice extent {i1, i2, j1, j2} is valid and within array boundaries.
| array | Target array. |
| idx | Slice extents: {i1, i2, j1, j2}. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that a slice extent matches the dimensions of a source array.
| dest | Destination array. |
| idx | Slice extents {i1, i2, j1, j2}. |
| src | Source array to assign into the slice. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that a divisor value is not zero.
| value | Divisor value. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that a 2D range vector {low, high} lies within [min_val, max_val] with low <= high.
| range | Range vector {low, high}. |
| min_val | Minimum allowed value. |
| max_val | Maximum allowed value. |
| param_name | Name or description of the range parameter for logging. |
| loc | Source location of the caller. |
|
inlinenodiscard |
Validates that all elements of an array are finite (not NaN or Inf).
| array | Array to check. |
| loc | Source location of the caller. |
|
inlinenodiscard |
|
inlinenodiscardconstexprnoexcept |
Compute the bilinear interpolated value from four input values.
This function calculates the interpolated value at a point within a grid using bilinear interpolation based on four surrounding values.
| f00 | Value at (u, v) = (0, 0). |
| f10 | Value at (u, v) = (1, 0). |
| f01 | Value at (u, v) = (0, 1). |
| f11 | Value at (u, v) = (1, 1). |
| u | The interpolation parameter in the x-direction, expected in [0, 1). |
| v | The interpolation parameter in the y-direction, expected in [0, 1). |
|
inlinenoexcept |
Compute uniform cubic B-spline weights for a fractional parameter in [0, 1).
| t | Fractional parameter in [0, 1). |
| w | Output array of 4 weights. |
|
inlinenodiscardconstexprnoexcept |
| Array hmap::harmonic_interpolation | ( | const Array & | array, |
| const Array & | mask_fixed_values, | ||
| int | iterations_max = 500, | ||
| float | tolerance = 1e-5f, | ||
| float | omega = 0.f, | ||
| int | sync_interval = 0, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Perform harmonic interpolation on a 2D array using the Successive Over-Relaxation (SOR) method.
This function solves the discrete Laplace equation on a regular grid by iteratively updating the values of an input array. Values marked as fixed in the mask_fixed_values remain unchanged throughout the process. The algorithm stops when either the maximum number of iterations is reached or the change between successive iterations falls below the specified tolerance.
| array | Input 2D array providing the initial guess for the solution. |
| mask_fixed_values | Mask of the same shape as array. Cells with a value greater than zero indicate fixed points that must remain unchanged during interpolation. |
| iterations_max | Maximum number of SOR iterations to perform. |
| tolerance | Convergence criterion: the algorithm stops if the maximum absolute update between iterations is less than this value. |
| omega | Relaxation factor (1 < omega < 2 recommended). Values closer to 2 accelerate convergence, but overly large values may cause divergence. |
| Array hmap::harmonic_interpolation | ( | const Array & | array, |
| const Array & | mask_fixed_values, | ||
| const Array & | dx, | ||
| const Array & | dy, | ||
| int | iterations_max = 500, | ||
| float | tolerance = 1e-5f, | ||
| float | omega = 0.f, | ||
| int | sync_interval = 0, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Perform harmonic interpolation on a 2D array with 2D variable diffusion coefficients (Dx, Dy) using the Successive Over-Relaxation (SOR) method.
Solves the steady-state anisotropic diffusion equation:
\[\nabla \cdot (\mathbf{D} \nabla u) = \frac{\partial}{\partial x}\left(D_x \frac{\partial u}{\partial x}\right) + \frac{\partial}{\partial y}\left(D_y \frac{\partial u}{\partial y}\right) = 0 \]
| array | Input 2D array providing the initial guess. |
| mask_fixed_values | Mask where values > 0 indicate fixed boundary constraints. |
| dx | Array of diffusion coefficients in the x-direction. |
| dy | Array of diffusion coefficients in the y-direction. |
| iterations_max | Maximum number of SOR iterations. |
| tolerance | Convergence tolerance. |
| omega | Relaxation factor (0 = auto-computed optimal). |
| Array hmap::interpolate2d | ( | glm::ivec2 | shape, |
| const std::vector< float > & | x, | ||
| const std::vector< float > & | y, | ||
| const std::vector< float > & | values, | ||
| InterpolationMethod2D | interpolation_method, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generic 2D interpolation function.
This function performs interpolation on a 2D grid using the specified interpolation method. It can optionally apply noise and stretching to the input data before interpolation.
| shape | Output array shape. |
| x | x coordinates of the input values. |
| y | y coordinates of the input values. |
| values | Input values at (x, y). |
| interpolation_method | Interpolation method (see InterpolationMethod2D). |
| p_noise_x | Pointer to the input noise array in the x direction (optional). |
| p_noise_y | Pointer to the input noise array in the y direction (optional). |
| bbox | Domain bounding box (default: {0.f, 1.f, 0.f, 1.f}). |
Example
Result
| Array hmap::interpolate2d_delaunay | ( | glm::ivec2 | shape, |
| const std::vector< float > & | x, | ||
| const std::vector< float > & | y, | ||
| const std::vector< float > & | values, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | fill_value = 0.f ) |
2D interpolation using the Delaunay triangulation method.
This function performs 2D interpolation by generating a Delaunay triangulation of the input points and interpolating the values within each triangle.
| shape | Output array shape. |
| x | x coordinates of the input values. |
| y | y coordinates of the input values. |
| values | Input values at (x, y). |
| p_noise_x | Pointer to the input noise array in the x direction (optional). |
| p_noise_y | Pointer to the input noise array in the y direction (optional). |
| bbox | Domain bounding box (default: {0.f, 1.f, 0.f, 1.f}). |
| Array hmap::interpolate2d_delaunay_gradient | ( | glm::ivec2 | shape, |
| const std::vector< float > & | x, | ||
| const std::vector< float > & | y, | ||
| const std::vector< float > & | values, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | fill_value = 0.f, | ||
| float | gradient_scaling = 1.f ) |
2D interpolation using a smoother version of the Delaunay triangulation method.
| Array hmap::interpolate2d_gaussian | ( | glm::ivec2 | shape, |
| const std::vector< float > & | x, | ||
| const std::vector< float > & | y, | ||
| const std::vector< float > & | values, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | sigma = 0.05f, | ||
| float | radius = 0.f ) |
2D interpolation using the Gaussian kernel method.
| Array hmap::interpolate2d_idw | ( | glm::ivec2 | shape, |
| const std::vector< float > & | x, | ||
| const std::vector< float > & | y, | ||
| const std::vector< float > & | values, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | distance_exp = 2.f, | ||
| float | radius = 0.f ) |
2D interpolation using the IDW method.
| Array hmap::interpolate2d_nearest | ( | glm::ivec2 | shape, |
| const std::vector< float > & | x, | ||
| const std::vector< float > & | y, | ||
| const std::vector< float > & | values, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
2D interpolation using the nearest neighbor method.
This function performs 2D interpolation by assigning the value of the nearest point to each point in the output grid.
| shape | Output array shape. |
| x | x coordinates of the input values. |
| y | y coordinates of the input values. |
| values | Input values at (x, y). |
| p_noise_x | Pointer to the input noise array in the x direction (optional). |
| p_noise_y | Pointer to the input noise array in the y direction (optional). |
| bbox | Domain bounding box (default: {0.f, 1.f, 0.f, 1.f}). |
| Array hmap::interpolate2d_nni | ( | glm::ivec2 | shape, |
| const std::vector< float > & | x, | ||
| const std::vector< float > & | y, | ||
| const std::vector< float > & | values, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
2D interpolation using the Natural Neighbor Interpolation method.
| void hmap::interpolate_array_bicubic | ( | const Array & | source, |
| Array & | target, | ||
| bool | endpoint = false, | ||
| bool | pixel_centered = true ) |
Resample an array to a target array using bicubic interpolation.
| source | Source array. |
| target | Target array. |
| endpoint | Whether the upper domain endpoint is included. |
| pixel_centered | Whether coordinates are pixel-centered. |
| void hmap::interpolate_array_bicubic | ( | const Array & | source, |
| Array & | target, | ||
| const UvRect & | uv_rect_source, | ||
| const UvRect & | uv_rect_target, | ||
| bool | endpoint = false, | ||
| bool | pixel_centered = true ) |
Resample a source array into a target array using bicubic interpolation between two local axis-aligned bounding boxes.
| source | Source array. |
| target | Target array. |
| bbox_source | Source local bounding box {xmin, xmax, ymin, ymax}. |
| bbox_target | Target local bounding box {xmin, xmax, ymin, ymax}. |
| endpoint | Whether the upper domain endpoint is included. |
| pixel_centered | Whether coordinates are pixel-centered. |
| void hmap::interpolate_array_bilinear | ( | const Array & | source, |
| Array & | target, | ||
| bool | endpoint = false, | ||
| bool | pixel_centered = true ) |
Resample an array to a target array using bilinear interpolation.
| source | Source array. |
| target | Target array. |
| endpoint | Whether the upper domain endpoint is included. |
| pixel_centered | Whether coordinates are pixel-centered. |
| void hmap::interpolate_array_bilinear | ( | const Array & | source, |
| Array & | target, | ||
| const UvRect & | uv_rect_source, | ||
| const UvRect & | uv_rect_target, | ||
| bool | endpoint = false, | ||
| bool | pixel_centered = true ) |
Resample a source array into a target array using bilinear interpolation between two local axis-aligned bounding boxes.
| source | Source array. |
| target | Target array. |
| bbox_source | Source local bounding box {xmin, xmax, ymin, ymax}. |
| bbox_target | Target local bounding box {xmin, xmax, ymin, ymax}. |
| endpoint | Whether the upper domain endpoint is included. |
| pixel_centered | Whether coordinates are pixel-centered. |
| void hmap::interpolate_array_nearest | ( | const Array & | source, |
| Array & | target, | ||
| bool | endpoint = false ) |
Resample an array to a target array using nearest-neighbor interpolation.
| source | Source array. |
| target | Target array. |
| endpoint | Whether the upper domain endpoint is included. |
| void hmap::interpolate_array_nearest | ( | const Array & | source, |
| Array & | target, | ||
| const UvRect & | uv_rect_source, | ||
| const UvRect & | uv_rect_target, | ||
| bool | endpoint = false ) |
Resample a source array into a target array using nearest-neighbor interpolation between two local axis-aligned bounding boxes.
| source | Source array. |
| target | Target array. |
| bbox_source | Source local bounding box {xmin, xmax, ymin, ymax}. |
| bbox_target | Target local bounding box {xmin, xmax, ymin, ymax}. |
| endpoint | Whether the upper domain endpoint is included. |
| Array hmap::resample_bicubic_warp | ( | const Array & | src, |
| glm::ivec2 | dst_shape, | ||
| float | warp = 0.f, | ||
| std::uint32_t | seed = 0 ) |
Resample an array to a target shape using cubic B-spline interpolation with optional domain noise warping.
| src | Source array to resample. |
| dst_shape | Target output shape. |
| warp | Domain warping amplitude (0 for no warping). |
| seed | Random seed for domain warping noise. |
| void hmap::flatten_terrain | ( | Array & | h_source1, |
| const Array & | h_source2, | ||
| const CoordFrame & | t_source1, | ||
| const CoordFrame & | t_source2, | ||
| bool | bilinear = true ) |
Blend a second terrain array in-place onto a base terrain array using their world-space coordinate frames.
| h_source1 | Base terrain array (modified in-place). |
| h_source2 | Overlay terrain array. |
| t_source1 | World coordinate frame of h_source1. |
| t_source2 | World coordinate frame of h_source2. |
| bilinear | Use bilinear interpolation if true, nearest-neighbor otherwise. |
| void hmap::flatten_terrain | ( | const std::vector< const Array * > & | h_sources, |
| Array & | h_target, | ||
| const std::vector< const CoordFrame * > & | t_sources, | ||
| const CoordFrame & | t_target, | ||
| bool | bilinear = true ) |
Flatten multiple terrain arrays into a target array using their world-space coordinate frames.
| h_sources | Ordered list of source terrain arrays. |
| h_target | Target terrain array. |
| t_sources | World coordinate frames corresponding to h_sources. |
| t_target | World coordinate frame of h_target. |
| bilinear | Use bilinear interpolation if true, nearest-neighbor otherwise. |
| void hmap::interpolate_terrain | ( | const Array & | h_source, |
| Array & | h_target, | ||
| const CoordFrame & | t_source, | ||
| const CoordFrame & | t_target, | ||
| bool | bilinear = true, | ||
| float | fill_value = 0.f, | ||
| Array * | p_mask = nullptr ) |
Project and interpolate a source terrain array onto a target terrain array using their world-space coordinate frames.
| h_source | Source terrain array. |
| h_target | Target terrain array. |
| t_source | World coordinate frame of h_source. |
| t_target | World coordinate frame of h_target. |
| bilinear | Use bilinear interpolation if true, nearest-neighbor otherwise. |
| fill_value | Value assigned to target cells outside t_source. |
| p_mask | Optional output mask (1.f where fill_value was used, 0.f where interpolated). |
| void hmap::flatten_terrain | ( | VirtualArray & | h_source1, |
| const VirtualArray & | h_source2, | ||
| const CoordFrame & | t_source1, | ||
| const CoordFrame & | t_source2, | ||
| const ComputeMode & | cm, | ||
| bool | bilinear = true ) |
Blend a second terrain VirtualArray in-place onto a base terrain VirtualArray using their world-space coordinate frames.
| h_source1 | Base terrain VirtualArray (modified in-place). |
| h_source2 | Overlay terrain VirtualArray. |
| t_source1 | World coordinate frame of h_source1. |
| t_source2 | World coordinate frame of h_source2. |
| cm | Compute mode controlling tiling and CPU distribution. |
| bilinear | Use bilinear interpolation if true, nearest-neighbor otherwise. |
| void hmap::flatten_terrain | ( | const std::vector< const VirtualArray * > & | h_sources, |
| VirtualArray & | h_target, | ||
| const std::vector< const CoordFrame * > & | t_sources, | ||
| const CoordFrame & | t_target, | ||
| const ComputeMode & | cm, | ||
| bool | bilinear = true ) |
Flatten multiple terrain VirtualArrays into a target VirtualArray using their world-space coordinate frames.
| h_sources | Ordered list of source terrain VirtualArrays. |
| h_target | Target terrain VirtualArray. |
| t_sources | World coordinate frames corresponding to h_sources. |
| t_target | World coordinate frame of h_target. |
| cm | Compute mode controlling tiling and CPU distribution. |
| bilinear | Use bilinear interpolation if true, nearest-neighbor otherwise. |
| void hmap::interpolate_terrain | ( | const VirtualArray & | h_source, |
| VirtualArray & | h_target, | ||
| const CoordFrame & | t_source, | ||
| const CoordFrame & | t_target, | ||
| const ComputeMode & | cm, | ||
| bool | bilinear = true, | ||
| float | fill_value = 0.f, | ||
| VirtualArray * | p_mask = nullptr ) |
Project and interpolate a source terrain VirtualArray onto a target terrain VirtualArray using their world-space coordinate frames.
| h_source | Source terrain VirtualArray. |
| h_target | Target terrain VirtualArray. |
| t_source | World coordinate frame of h_source. |
| t_target | World coordinate frame of h_target. |
| cm | Compute mode controlling tiling and CPU distribution. |
| bilinear | Use bilinear interpolation if true, nearest-neighbor otherwise. |
| fill_value | Value assigned to target cells outside t_source. |
| p_mask | Optional output mask (1.f where fill_value was used, 0.f where interpolated). |
| Array hmap::get_kernel | ( | glm::ivec2 | shape, |
| KernelType | kernel_type ) |
Generate a kernel of the specified type.
This function creates a kernel based on the given shape and kernel type. It supports various types of kernels including biweight, cubic pulse, cone, and more. The resulting kernel is returned as an array.
| shape | The dimensions of the kernel to be generated. |
| kernel_type | The type of kernel to generate (e.g., BIWEIGHT, CUBIC_PULSE, etc.). |
| Array hmap::biweight | ( | glm::ivec2 | shape | ) |
Generates a biweight kernel array.
This function creates a biweight kernel, which is a type of kernel function used in statistics for smoothing and interpolation.
For more details on the biweight kernel, refer to the Wikipedia page: https://en.wikipedia.org/wiki/Kernel_%28statistics%29.
| shape | Array shape specifying the dimensions of the kernel. |
| Array hmap::blackman | ( | glm::ivec2 | shape | ) |
Generates a Blackman window array with the specified shape.
The Blackman window is commonly used in signal processing for smoothing or tapering. This function creates a 2D array of values representing the Blackman window, calculated based on the given shape dimensions.
| shape | A 2D vector representing the dimensions of the array. |
| Array hmap::cone | ( | glm::ivec2 | shape | ) |
Generates a cone-shaped kernel array.
This function creates a cone-shaped kernel. The maximum value of the kernel is 1, and the shape of the kernel is determined by the provided array dimensions.
| shape | Array shape specifying the dimensions of the kernel. |
| Array hmap::cone_talus | ( | float | height, |
| float | talus ) |
Generates a cone-shaped kernel with specified height and talus.
This function creates a cone-shaped kernel with a given height and talus. The output array's shape is adjusted accordingly based on the specified height and talus.
| height | Height of the cone. This determines the peak value of the kernel. |
| talus | The slope of the cone, which affects the rate at which the kernel value decreases. |
| Array hmap::cone_smooth | ( | glm::ivec2 | shape | ) |
Generates a cone-shaped kernel with a smooth landing.
This function creates a cone-shaped kernel where the kernel smoothly transitions to zero at the bottom, resulting in a smooth derivative at the cone base.
| shape | Array shape specifying the dimensions of the kernel. |
| Array hmap::cubic_pulse | ( | glm::ivec2 | shape | ) |
| std::vector< float > hmap::cubic_pulse_1d | ( | int | nk | ) |
Generates a 1D cubic pulse kernel.
| nk | The number of samples in the 1D kernel. |
| Array hmap::cubic_pulse_directional | ( | glm::ivec2 | shape, |
| float | angle, | ||
| float | aspect_ratio, | ||
| float | anisotropy ) |
Generates a "directional" cubic pulse kernel.
This function creates a cubic pulse kernel with directional properties. The kernel's shape can be adjusted based on the provided angle, aspect ratio, and anisotropy. This allows for creating kernels that are elongated or compressed in specific directions, making them suitable for applications requiring directional smoothing or filtering.
| shape | Array shape specifying the dimensions of the kernel. |
| angle | Angle (in degrees) defining the direction of the pulse elongation. |
| aspect_ratio | Pulse aspect ratio, which controls the kernel's elongation or compression. |
| anisotropy | Pulse width ratio between upstream and downstream sides of the pulse. |
| Array hmap::cubic_pulse_truncated | ( | glm::ivec2 | shape, |
| float | slant_ratio, | ||
| float | angle ) |
Generates a truncated cubic pulse kernel.
This function creates a cubic pulse kernel that is truncated based on the specified slant ratio and angle. The truncation slope determines how the kernel's values decrease as they approach the edge of the kernel, creating a "cut-off" effect.
| shape | Array shape specifying the dimensions of the kernel. |
| slant_ratio | Truncation slope that affects the kernel's cut-off behavior. |
| angle | Angle (in degrees) that defines the orientation of the truncation. |
Example
Result
Generate a 2D radial cupola kernel.
Values are computed from the normalized radial distance to the center: constant 1 inside radius rc, then smoothly decreasing to 0 at radius 1.
| shape | Size of the output array (width, height). |
| rc | Radius of the inner flat region (normalized, < 1). |
| Array hmap::disk | ( | glm::ivec2 | shape | ) |
Generates a disk-shaped kernel footprint.
This function creates a disk-shaped kernel, which is a circular kernel where the values are radially symmetric around the center.
| shape | Array shape specifying the dimensions of the kernel. |
Generates a smooth, disk-shaped kernel footprint with soft edges.
This function creates a 2D, disk-shaped kernel with radially symmetric values centered in the array. Values inside the cutoff radius r_cutoff are set to 1.0. Between r_cutoff and the normalized radius 1.0, the values smoothly fall off to zero using a parabolic profile to ensure soft transitions at the disk boundary.
The generated array is useful for constructing smooth low-pass filters or spatial masks with circular support.
| shape | The dimensions of the output array (width, height). |
| r_cutoff | Normalized cutoff radius in the range [0.0, 1.0]. Inside this radius, the kernel has a flat value of 1.0; outside, it decays smoothly to 0.0. |
| Array hmap::gabor | ( | glm::ivec2 | shape, |
| float | kw, | ||
| float | angle, | ||
| bool | quad_phase_shift = false ) |
Generates a Gabor kernel of the specified shape.
This function creates a Gabor kernel, which is a type of sinusoidal kernel modulated by a Gaussian envelope. The Gabor kernel is useful for texture analysis and feature extraction. The kernel's frequency and orientation are defined by the wavenumber and angle parameters, respectively.
| shape | Array shape specifying the dimensions of the kernel. |
| kw | Kernel wavenumber, which determines the frequency of the sinusoidal component. |
| angle | Kernel angle (in degrees) that defines the orientation of the sinusoidal component. |
Example
Result
| Array hmap::gabor_dune | ( | glm::ivec2 | shape, |
| float | kw, | ||
| float | angle, | ||
| float | xtop, | ||
| float | xbottom ) |
Generates a modified dune-like Gabor kernel.
This function creates a modified Gabor kernel that has a dune-like profile. The dune profile modifies the standard Gabor kernel to include a top and foot for the dune, giving it a specific shape. The xtop and xbottom parameters control the relative locations of the top and foot of the dune profile, respectively.
| shape | Array shape specifying the dimensions of the kernel. |
| kw | Kernel wavenumber, which determines the frequency of the sinusoidal component. |
| angle | Kernel angle (in degrees) that defines the orientation of the sinusoidal component. |
| xtop | Relative location of the top of the dune profile (in [0, 1]). |
| xbottom | Relative location of the foot of the dune profile (in [0, 1]). |
Example
Result
| Array hmap::hann | ( | glm::ivec2 | shape | ) |
Generates a Hann window array with the specified shape.
The Hann window is commonly used in signal processing for smoothing or tapering. This function creates a 2D array of values representing the Hann window, calculated based on the given shape dimensions.
| shape | A 2D vector representing the dimensions of the array. |
Generate a Lorentzian kernel.
The Lorentzian kernel is characterized by its peak and tails that decay with the distance from the center. The width of the kernel is determined using the provided footprint threshold.
| shape | The dimensions of the kernel. |
| footprint_threshold | Determines the width of the Lorentzian kernel. Default is 0.1. |
| Array hmap::lorentzian_compact | ( | glm::ivec2 | shape | ) |
Generate a modified Lorentzian kernel with compact support.
This version of the Lorentzian kernel is modified to have compact support, meaning it is non-zero only within a certain range. This modification is useful for specific applications requiring compact kernels.
| shape | The dimensions of the kernel. |
| Array hmap::sinc_radial | ( | glm::ivec2 | shape, |
| float | kw ) |
Generates a radial sinc function array with the specified shape and wave number.
This function creates a 2D array of values representing the radial sinc function, calculated based on the given shape and wave number. The sinc function is defined as sin(x) / x and is useful in signal processing and analysis.
| shape | A 2D vector representing the dimensions of the array. |
| kw | The wave number used to scale the radial sinc function. |
| Array hmap::sinc_separable | ( | glm::ivec2 | shape, |
| float | kw ) |
Generates a separable sinc function array with the specified shape and wave number.
This function creates a 2D array of values representing the separable sinc function, calculated as the product of 1D sinc functions along each dimension of the array. The sinc function is defined as sin(x) / x and is useful in signal processing and analysis.
| shape | A 2D vector representing the dimensions of the array. |
| kw | The wave number used to scale the separable sinc function. |
| Array hmap::smooth_cosine | ( | glm::ivec2 | shape | ) |
Generate a smooth cosine kernel.
The smooth cosine kernel is a type of kernel function that smoothly transitions between values, based on a cosine function.
| shape | The dimensions of the kernel. |
| Array hmap::square | ( | glm::ivec2 | shape | ) |
Generate a square-shaped kernel.
The square kernel is a simple, isotropic kernel where the values are constant within the square region. The maximum value within the kernel is 1.
| shape | The dimensions of the kernel. |
| Array hmap::tricube | ( | glm::ivec2 | shape | ) |
Generate a tricube kernel.
The tricube kernel is a type of kernel function that is often used in statistical applications. It has a specific shape defined by the tricube polynomial.
| shape | The dimensions of the kernel. |
Reference See https://en.wikipedia.org/wiki/Kernel_%28statistics%29 for details on the tricube kernel.
Computes the downstream path length to the domain outlet.
For each cell, follows the steepest-descending flow path and returns the number of downstream cells required to leave the domain. Cells whose flow terminates in an internal sink have a path length of 0.
Example
Result
Computes the downstream path length to the nearest sink.
For each cell, follows the steepest-descending flow path and returns the number of downstream cells required to reach a sink. Sink cells have a path length of 0.
Example
Result
Return the local maxima based on a maximum filter with a square kernel.
This function identifies the local maxima in the input array using a maximum filter with a square kernel. The local maxima are determined based on the footprint radius specified by ir. The result is an array where each value represents the local maximum within the defined kernel size.
| array | Input array from which local maxima are to be extracted. |
| ir | Square kernel footprint radius. The size of the kernel used to determine the local maxima. |
Example
Result
local_max_disk, local_min Computes the local median deviation of a 2D array.
This function calculates the absolute difference between the local mean and a pseudo-local median of each element in the input array. The local neighborhood is defined by a square window with radius ir.
| array | The input 2D array of values (e.g., a heightmap). |
| ir | The radius of the square neighborhood window used for computing local statistics. The window size is (2*ir + 1) x (2*ir + 1). |
Example
Result
Return the local minima based on a maximum filter with a square kernel.
This function identifies the local minima in the input array using a maximum filter with a square kernel. The local minima are determined based on the footprint radius specified by ir. The result is an array where each value represents the local minimum within the defined kernel size.
| array | Input array from which local minima are to be extracted. |
| ir | Square kernel footprint radius. The size of the kernel used to determine the local minima. |
Example
Result
local_min Return the local mean based on a mean filter with a square kernel.
This function calculates the local mean of the input array using a mean filter with a square kernel. The local mean is determined by averaging values within a square neighborhood defined by the footprint radius ir. The result is an array where each value represents the mean of the surrounding values within the kernel size.
| array | Input array from which the local mean is to be calculated. |
| ir | Square kernel footprint radius. The size of the kernel used to compute the local mean. |
Example
Result
Calculates the relative elevation within a specified radius, helping to identify local highs and lows.
Relative elevation analysis determines how high or low a point is relative to its surroundings, which can be critical in hydrological modeling and geomorphology.
Usage:
| array | The input array representing the terrain elevation data. |
| ir | The radius (in pixels) within which to calculate the relative elevation for each point. |
Example
Result
Measures the local surface roughness within a given radius.
Compares the original heightmap with a locally smoothed version (using a smooth cubic pulse filter) within the specified radius ir. The result is the magnitude of the local deviation.
| array | The input array representing the terrain elevation data. |
| ir | The radius within which local roughness is computed. |
Example
Result
Computes the ruggedness of each element in the input array.
The ruggedness is calculated as the square root of the sum of squared differences between each element and its neighbors within a specified radius.
| array | The input array for which ruggedness is to be computed. |
| ir | The radius within which neighbors are considered for ruggedness calculation. |
Example
Result
Estimates the rugosity of a surface by analyzing the skewness of the elevation data, which reflects surface roughness.
Rugosity is a measure of terrain roughness, often used in ecological studies and habitat mapping. Higher rugosity values indicate more rugged terrain, which can affect species distribution and water flow.
| z | The input array representing the heightmap data (elevation values). |
| ir | The radius of the square kernel used for calculations, determining the scale of the analysis. |
| convex | Return the convex rugosity if true, and the concave ones if not. |
Example
Result
| Array hmap::topographic_wetness_index | ( | const Array & | z, |
| float | talus_ref = 0.f, | ||
| float | min_slope = 1e-4f ) |
Computes the Topographic Wetness Index (TWI).
TWI (compound topographic index) is a steady-state hydrological indicator estimating the tendency of terrain to accumulate water based on its topography:
\[ \text{TWI} = \ln\left(\frac{a}{\tan(\beta)}\right) \]
where \(a\) is the upslope contributing area computed via \(D_\infty\) flow accumulation, and \(\beta\) is the local slope.
| z | Input elevation array. |
| talus_ref | Reference talus slope for flow partitioning in D-infinity accumulation (if <= 0, automatically determined from max talus). |
| min_slope | Minimum slope threshold \(\tan(\beta)\) to prevent division by zero in flat areas (default: 1e-4f). |
Example
Result
Computes the topographic residual (relief) relative to a smoothed surface.
Subtracts a smoothed version of the elevation (using smooth_cpulse with radius ir) from the input array. Optionally normalizes and clips the output to [-1, 1].
| z | Input elevation array. |
| ir | Radius for smoothing filter. |
| normalize_output | If true, normalizes and clips the residual to [-1, 1]. |
Measures the valley width by calculating the distance from each point in a concave region to the frontier of that region.
Valley width is a geomorphological metric that represents the distance across valleys or concave regions in a terrain. This measurement is particularly useful in hydrological modeling and landscape analysis, where valley dimensions are important.
Usage
| z | The input array representing the heightmap data (elevation values). |
| ir | The radius used for pre-filtering, controlling the scale of analysis (in pixels). The default value is 0, meaning no pre-filtering is applied. |
| ridge_select | If enabled, selects ridges instead of valleys. |
Example
Result
Absolute value.
| array | Input array. |
Smooth absolute value.
| array | Input array. |
| mu | Smoothing coefficient. |
| vshift | Reference value for the zero of the absolute value. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Almost unit identity function.
Maps [0, 1] to itself with zero derivative at 0 and unit derivative at 1. See Inigo Quilez: https://iquilezles.org/articles/functions/
| array | Input array. |
Almost unit identity function (C2 variant).
Ensures smoother behavior by also enforcing second-order continuity at x = 1.
| array | Input array. |
Arctangent.
| array | Input array. |
Element-wise arctangent with quadrant handling.
Computes atan2(y, x) element-wise.
| y | Numerator array. |
| x | Denominator array. |
| Array hmap::build_density_linear | ( | const std::vector< const Array * > & | layers, |
| const std::vector< float > & | weights = {} ) |
Combine a list of layers in linear space.
Multiplies layer values blended with weights:
\[\text{result} = \prod_{i=0}^{N-1} \text{lerp}(1, L_i, w_i) \]
| layers | List of layer arrays (pointers). |
| weights | Per-layer weights (defaults to 1.0 for each layer). |
| Array hmap::build_density_log | ( | const std::vector< const Array * > & | layers, |
| const std::vector< float > & | weights = {}, | ||
| float | eps = 1e-6f ) |
Combine a list of layers in log space.
Computes the weighted geometric combination in log space:
\[\text{result} = \exp\left(\sum_{i=0}^{N-1} w_i \log_{\text{safe}}(L_i, \epsilon)\right) \]
| layers | List of layer arrays (pointers). |
| weights | Per-layer weights (defaults to 1.0 for each layer). |
| eps | Small epsilon value for numerical stability (default: 1e-6). |
Exponential.
| array | Input array. |
Gaussian decay.
| array | Input array. |
| sigma | Gaussian half-width. |
Example
Result
Hypotenuse.
Computes sqrt(array1² + array2²) element-wise.
| array1 | First array. |
| array2 | Second array. |
Binary mask of elements equal to a value.
| array | Input array. |
| value | Reference value. |
Binary mask of non-zero elements.
| array | Input array. |
Binary mask of zero elements.
| array | Input array. |
Linear interpolation.
| array1 | First array. |
| array2 | Second array. |
| t | Interpolation factor in [0,1]. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Base-10 logarithm.
| array | Input array. |
Safe natural logarithm with lower clamp.
Computes std::log(std::max(v, eps)) element-wise.
| array | Input array. |
| eps | Minimum threshold (default: 1e-6). |
Power function.
| array | Input array. |
| exp | Exponent. |
Generalized Rvachev R-function for smooth minimum / intersection (exact zero-set).
| array1 | First array. |
| array2 | Second array. |
| alpha | Parameter in (-1, 1] controlling blending sharpness (default 0.0). |
Generalized Rvachev R-function for smooth maximum / union (exact zero-set).
| array1 | First array. |
| array2 | Second array. |
| alpha | Parameter in (-1, 1] controlling blending sharpness (default 0.0). |
| Array hmap::sigmoid | ( | const Array & | array, |
| float | width = 1.f, | ||
| float | vmin = 0.f, | ||
| float | vmax = 1.f, | ||
| float | x0 = 0.f ) |
Sigmoid function.
Applies the generalized sigmoid transformation element-wise:
\[y = v_{\min} + \frac{v_{\max} - v_{\min}} {1 + \exp\left(-\frac{x - x_0}{\text{width}}\right)} \]
| array | Input array. |
| width | Controls steepness. |
| vmin | Minimum output value. |
| vmax | Maximum output value. |
| x0 | Center offset. |
Example
Result
Cubic smoothstep.
| array | Input array. |
| vmin | Lower bound. |
| vmax | Upper bound. |
Example
Result
Cubic smoothstep (zero derivative at 0 only).
| array | Input array. |
Cubic smoothstep (zero derivative at 1 only).
| array | Input array. |
Quintic smoothstep.
| array | Input array. |
| vmin | Lower bound. |
| vmax | Upper bound. |
Example
Result
Quintic smoothstep (zero derivative at 0 only).
| array | Input array. |
Quintic smoothstep (zero derivative at 1 only).
| array | Input array. |
Seventh-order smoothstep.
| array | Input array. |
Square root.
| array | Input array. |
Safe square root.
Returns sqrt(v) for positive values and 0 otherwise.
| array | Input array. |
Linear threshold.
| array | Input array. |
| x0 | Lower threshold. |
| x1 | Upper threshold. |
Smooth threshold.
| array | Input array. |
| x0 | Lower threshold. |
| x1 | Upper threshold. |
Return the convolution product of the array with a 1D kernel along the 'i' direction.
This function applies a 1D convolution to the input array using the provided kernel, considering the convolution in the row direction ('i' direction).
| array | Input array to be convolved. |
| kernel | 1D kernel to be used for the convolution. |
Example
Result
convolve1d_j Return the convolution product of the array with a 1D kernel along the 'j' direction.
This function applies a 1D convolution to the input array using the provided kernel, considering the convolution in the column direction ('j' direction).
| array | Input array to be convolved. |
| kernel | 1D kernel to be used for the convolution. |
Example
Result
convolve1d_i Return the convolution product of the array with a given 2D kernel.
This function performs a 2D convolution on the input array using the specified 2D kernel. The output array has the same shape as the input array, and symmetry boundary conditions are used.
| array | Input array to be convolved. |
| kernel | 2D kernel to be used for the convolution. |
Example
Return the convolution product of the array with a given 2D kernel, with a truncated output size.
This function performs a 2D convolution on the input array using the specified 2D kernel. The resulting output array is smaller than the input array by the dimensions of the kernel.
| array | Input array to be convolved. |
| kernel | 2D kernel to be used for the convolution. |
Return the approximate convolution product of the array with a Singular Value Decomposition (SVD) of a kernel.
This function approximates the convolution of the input array with a 2D kernel by using its Singular Value Decomposition (SVD). The approximation is based on the first rank singular values and vectors.
| z | Input array to be convolved. |
| kernel | 2D kernel to be used for the convolution. |
| rank | Approximation rank: number of singular values/vectors used for the approximation. |
Example
Result
| Array hmap::convolve2d_svd_rotated_kernel | ( | const Array & | z, |
| const Array & | kernel, | ||
| int | rank = 3, | ||
| int | n_rotations = 6, | ||
| std::uint32_t | seed = 1 ) |
Return the approximate convolution product of the array with a Singular Value Decomposition (SVD) of a kernel combined with kernel rotations.
This function approximates the convolution of the input array with a 2D kernel using its SVD, combined with multiple rotations of the kernel. This can enhance the convolution approximation by considering different orientations of the kernel.
| z | Input array to be convolved. |
| kernel | 2D kernel to be used for the convolution. |
| rank | Approximation rank: number of singular values/vectors used for the approximation. |
| n_rotations | Number of kernel rotations to be considered. |
| seed | Random seed number for kernel rotations. |
Example
Result
| float hmap::abs_smooth | ( | float | a, |
| float | mu ) |
Smooth absolute value.
| a | Input value. |
| mu | Smoothing coefficient. |
| float hmap::almost_unit_identity | ( | float | x | ) |
Almost unit identity function.
Maps [0, 1] to itself with zero derivative at 0 and unit derivative at 1. See Inigo Quilez: https://iquilezles.org/articles/functions/
| x | Input value. |
| float hmap::almost_unit_identity_c2 | ( | float | x | ) |
Almost unit identity function (C2 variant).
Ensures smoother behavior by also enforcing second-order continuity at x = 1.
| x | Input value. |
|
inline |
Approximate hypotenuse.
| a | First value. |
| b | Second value. |
|
inline |
Fast inverse square root approximation.
| a | Input value. |
| int hmap::ceil_div | ( | int | a, |
| int | b ) |
Integer ceiling division.
| a | Numerator (>= 0). |
| b | Denominator (> 0). |
| float hmap::fast_exp | ( | float | x | ) |
Fast exponential approximation.
| x | Input value. |
| float hmap::fast_log | ( | float | x | ) |
Fast natural logarithm approximation.
| x | Input value (must be > 0). |
| float hmap::gain | ( | float | x, |
| float | factor ) |
Gain curve remapping in [0,1].
| x | Input value in [0,1]. |
| factor | Contrast/gain factor. |
| int hmap::highest_power_of_2 | ( | int | n | ) |
Highest power of 2 less than or equal to n.
| n | Input value. |
| float hmap::lerp | ( | float | a, |
| float | b, | ||
| float | t ) |
Linear interpolation.
| a | First value. |
| b | Second value. |
| t | Interpolation factor in [0,1]. |
| float hmap::log_safe | ( | float | x, |
| float | eps = 1e-6f ) |
Safe natural logarithm with lower clamp.
| x | Input value. |
| eps | Minimum value threshold (default: 1e-6). |
| float hmap::power_curve | ( | float | x, |
| float | a, | ||
| float | b ) |
Smooth asymmetric bell-shaped curve on [0,1].
Parameters a and b control left and right curvature. The function is normalized to a maximum of 1.
| x | Input value. |
| a | Left curvature parameter. |
| b | Right curvature parameter. |
| float hmap::r_min | ( | float | f1, |
| float | f2, | ||
| float | alpha = 0.f ) |
Generalized Rvachev R-function for smooth minimum / intersection (exact zero-set).
\[R_{\min}(f_1, f_2, \alpha) = \frac{f_1 + f_2 - \sqrt{f_1^2 + f_2^2 - 2\alpha f_1 f_2}}{1 + \alpha} \]
| f1 | First value. |
| f2 | Second value. |
| alpha | Parameter in (-1, 1] controlling blending sharpness (default 0.0). alpha = 0 gives standard Euclidean R-min, alpha = 1 gives exact min. |
| float hmap::r_max | ( | float | f1, |
| float | f2, | ||
| float | alpha = 0.f ) |
Generalized Rvachev R-function for smooth maximum / union (exact zero-set).
\[R_{\max}(f_1, f_2, \alpha) = \frac{f_1 + f_2 + \sqrt{f_1^2 + f_2^2 - 2\alpha f_1 f_2}}{1 + \alpha} \]
| f1 | First value. |
| f2 | Second value. |
| alpha | Parameter in (-1, 1] controlling blending sharpness (default 0.0). alpha = 0 gives standard Euclidean R-max, alpha = 1 gives exact max. |
| float hmap::sigmoid | ( | float | x, |
| float | width = 1.f, | ||
| float | vmin = 0.f, | ||
| float | vmax = 1.f, | ||
| float | x0 = 0.f ) |
Sigmoid function.
Generalized logistic function:
\[y = v_{\min} + \frac{v_{\max} - v_{\min}} {1 + \exp\left(-\frac{x - x_0}{\text{width}}\right)} \]
| x | Input value. |
| width | Controls steepness. |
| vmin | Minimum output value. |
| vmax | Maximum output value. |
| x0 | Center offset. |
| float hmap::smoothstep3 | ( | float | x | ) |
Cubic smoothstep function.
| x | Input value. |
| float hmap::smoothstep3 | ( | float | x, |
| float | clamp_min, | ||
| float | clamp_max ) |
Cubic smoothstep function with clamping.
| x | Input value. |
| clamp_min | Lower clamp bound. |
| clamp_max | Upper clamp bound. |
| float hmap::smoothstep3_lower | ( | float | x | ) |
Cubic smoothstep (zero derivative at 0 only).
| x | Input value. |
| float hmap::smoothstep3_upper | ( | float | x | ) |
Cubic smoothstep (zero derivative at 1 only).
| x | Input value. |
| float hmap::smoothstep5 | ( | float | x | ) |
Quintic smoothstep function.
| x | Input value. |
| float hmap::smoothstep5_lower | ( | float | x | ) |
Quintic smoothstep (zero derivative at 0 only).
| x | Input value. |
| float hmap::smoothstep5_upper | ( | float | x | ) |
Quintic smoothstep (zero derivative at 1 only).
| x | Input value. |
| float hmap::smoothstep7 | ( | float | x | ) |
Seventh-order smoothstep function.
| x | Input value. |
| float hmap::threshold | ( | float | x, |
| float | x0, | ||
| float | x1 ) |
Linear threshold.
| x | Input value. |
| x0 | Lower bound. |
| x1 | Upper bound. |
| float hmap::threshold_smooth | ( | float | x, |
| float | x0, | ||
| float | x1 ) |
Smooth threshold using smoothstep.
| x | Input value. |
| x0 | Lower bound. |
| x1 | Upper bound. |
| float hmap::trapeze | ( | float | x, |
| float | x0, | ||
| float | x1, | ||
| float | width ) |
Computes a trapezoidal pulse function.
Returns a value in [0, 1] with linear ramps of size width around the interval [x0, x1].
| x | Input value. |
| x0 | Start of the plateau. |
| x1 | End of the plateau. |
| width | Width of the rising and falling ramps. |
| float hmap::trapeze_smooth | ( | float | x, |
| float | x0, | ||
| float | x1, | ||
| float | width ) |
Smooth trapezoidal pulse using cubic smoothstep interpolation.
| x | Input value. |
| x0 | Start of the plateau. |
| x1 | End of the plateau. |
| width | Width of the rising and falling ramps. |
| float hmap::triangle | ( | float | x, |
| float | vmin, | ||
| float | vmax ) |
Triangle function between bounds.
| x | Input value. |
| vmin | Lower bound. |
| vmax | Upper bound. |
| std::function< float(float, float)> hmap::get_distance_function | ( | DistanceFunction | dist_fct, |
| DistanceFunctionAxis | dfa = DistanceFunctionAxis::DFA_XY ) |
Return the requested distance function.
| dist_fct | Distance function type. |
| std::function< float(float)> hmap::get_erosion_profile_function | ( | const ErosionProfile & | erosion_profile, |
| float | delta, | ||
| float & | profile_avg ) |
Generates a function representing an erosion profile based on the specified type and parameters.
This function returns a callable object (std::function) that computes the value of the specified erosion profile for a given phase angle (phi). Optionally, it can compute the average value of the profile over the range [-π, π].
| erosion_profile | The type of erosion profile to generate. |
| delta | A parameter that can influence the profile (depending on the profile choice). |
| profile_avg | Reference to a float that will store the average value of the profile over the range [-π, π]. |
| std::invalid_argument |
erosion_profile is invalid.
| std::function< float(float)> hmap::get_phasor_profile_function | ( | PhasorProfile | phasor_profile, |
| float | delta, | ||
| float * | p_profile_avg = nullptr ) |
Generates a function representing a phasor profile based on the specified type and parameters.
This function returns a callable object (std::function) that computes the value of the specified phasor profile for a given phase angle (phi). Optionally, it can compute the average value of the profile over the range [-π, π].
| phasor_profile | The type of phasor profile to generate. |
| delta | A parameter that can influence the profile (depending on the profile choice). |
| p_profile_avg | Optional pointer to a float. If not nullptr, it will store the average value of the profile over the range [-π, π]. |
| std::invalid_argumentIftheprovided`phasor_profile`isinvalid. |
| std::function< float(float)> hmap::get_radial_profile_function | ( | RadialProfile | radial_profile, |
| float | delta ) |
Returns a normalized radial profile function.
The returned function maps x ∈ [0,1] to a value in [0,1], with f(0) = 0 and f(1) = 1. It is typically used for radial or distance-based falloff in procedural heightmaps.
| radial_profile | Radial profile type. |
| delta | Shape parameter used by some profiles. |
| std::invalid_argumentIftheprofileisinvalid. |
| Array hmap::area_remove | ( | const Array & | array, |
| float | threshold_size, | ||
| float | background_value = 0.f, | ||
| float | fill_value = 0.f ) |
Remove connected components smaller than a given size threshold.
Detects connected regions in the input array and removes those whose area is smaller than threshold_size.
| array | Input array. |
| threshold_size | Minimum component size to keep. |
| background_value | Value used to identify background. |
| fill_value | Value used to replace removed components. |
Example
Result
See unit tests: test_area_remove.cpp
Apply a border algorithm to the input array using a square structure.
| array | Input array to which the border algorithm is applied. |
| ir | Radius of the square kernel used for the border algorithm. |
Example
Result
Apply a closing algorithm to the input array using a square structure.
| array | Input array to which the closing algorithm is applied. |
| ir | Radius of the square kernel used for the closing algorithm. |
Example
Result
Apply closing by reconstruction to the input array.
Performs a dilation followed by a reconstruction by erosion, filling small dark regions while preserving the shape of larger structures.
| array | Input array. |
| ir | Radius of the structuring element. |
| k_smooth_max | Smoothness factor (0 for hard max). |
Smooth contour boundaries of segmented regions.
Reduces staircase artifacts on component borders by smoothing the transition zone around edges.
| array | Input labeled or binary array. |
| ir | Radius of the smoothing kernel. |
| transition_ratio | Controls edge blending width. |
Example
Result
Apply a dilation algorithm to the input array using a square structure.
| array | Input array to which the dilation algorithm is applied. |
| ir | Radius of the square kernel used for the dilation algorithm. |
Example
Result
Expand non-zero regions of an array by morphological dilation, while preserving the original non-zero values.
This function performs a local-maximum (dilation) operation on the input array with a given radius ir, then copies back the original non-zero values so they remain unchanged. Only the surrounding background is filled with expanded values, effectively “growing” the borders of non-zero regions.
| array | Input 2D array where non-zero cells represent regions of interest and zero cells represent background. |
| ir | Radius of the dilation (in grid cells). Defines how far the non-zero values can expand into the background. |
ir cells, while the original non-zero values are kept intact. | Array hmap::distance_transform | ( | const Array & | array, |
| bool | return_squared_distance = false, | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Return the Euclidean distance transform.
Exact transform based on Meijster et al. algorithm [Meijster2000].
| array | Input array to be transformed, will be converted into binary: 1 wherever input is greater than 0, 0 elsewhere. |
| return_squared_distance | Whether the distance returned is squared or not. |
Example
Result
See unit tests: test_distance_transform.cpp
Calculates an approximate distance transform of the input array.
| array | Input array to calculate the distance transform for. |
| return_squared_distance | Optional parameter to return squared distances. Defaults to false. |
Example
Result
See unit tests: test_distance_transform.cpp
| Array hmap::distance_transform_manhattan | ( | const Array & | array, |
| bool | return_squared_distance = false ) |
Calculates the Manhattan distance transform of an array.
| array | Input array. |
| return_squared_distance | If true, returns the squared Manhattan distance instead of the actual distance. |
Example
Result
See unit tests: test_distance_transform.cpp
| Array hmap::distance_transform_with_closest | ( | const Array & | array, |
| Mat< glm::ivec2 > & | closest, | ||
| bool | return_squared_distance = false ) |
Return the Euclidean distance transform.
Exact transform based on Meijster et al. algorithm [Meijster2000].
| array | Input array to be transformed, will be converted into binary: 1 wherever input is greater than 0, 0 elsewhere. |
| return_squared_distance | Whether the distance returned is squared or not. |
See unit tests: test_distance_transform.cpp
Apply an erosion algorithm to the input array using a square structure.
| array | Input array to which the erosion algorithm is applied. |
| ir | Radius of the square kernel used for the erosion algorithm. |
Example
Result
See unit tests: test_erosion.cpp
| void hmap::flood_fill | ( | Array & | array, |
| int | i, | ||
| int | j, | ||
| float | fill_value = 1.f, | ||
| float | background_value = 0.f ) |
Apply a flood fill algorithm to the input array.
| array | Input array to be filled. |
| i | Seed point row index. |
| j | Seed point column index. |
| fill_value | Filling value. |
| background_value | Background value. |
Example
Result
Apply a morphological black hat algorithm to the input array using a square structure.
| array | Input array to which the black hat algorithm is applied. |
| ir | Radius of the square kernel used for the black hat algorithm. |
Example
Result
Apply a morphological gradient algorithm to the input array using a square structure.
| array | Input array to which the gradient algorithm is applied. |
| ir | Radius of the square kernel used for the gradient algorithm. |
Example
Result
Apply a morphological Laplacian operator to the input array using a square structure.
Compared to the classical Laplacian, this operator is more robust to noise and better preserves sharp features, as it relies on morphological extrema rather than linear differences.
| array | Input array to which the morphological Laplacian is applied. |
| ir | Radius of the square kernel used for the underlying dilation and erosion operations. |
Example
Result
Apply a morphological top hat algorithm to the input array using a square structure.
| array | Input array to which the top hat algorithm is applied. |
| ir | Radius of the square kernel used for the top hat algorithm. |
Example
Result
Apply an opening algorithm to the input array using a square structure.
| array | Input array to which the opening algorithm is applied. |
| ir | Radius of the square kernel used for the opening algorithm. |
Example
Result
Apply opening by reconstruction to the input array.
Performs an erosion followed by a reconstruction by dilation, removing small bright features while preserving the shape of larger structures.
| array | Input array. |
| ir | Radius of the structuring element. |
| k_smooth_min | Smoothness factor (0 for hard min). |
| Array hmap::reconstruction_by_dilation | ( | const Array & | marker, |
| const Array & | mask, | ||
| int | ir, | ||
| float | k_smooth_min = 0.f ) |
Perform morphological reconstruction by dilation.
Iteratively dilates the marker image while constraining values to be less than or equal to the mask. The marker must be element-wise <= mask. Optionally uses a smooth minimum controlled by k_smooth_min.
| marker | Initial image (seed), must satisfy marker <= mask. |
| mask | Constraint image (upper bound). |
| ir | Radius of the structuring element. |
| k_smooth_min | Smoothness factor (0 for hard min). |
Example
Result
| Array hmap::reconstruction_by_erosion | ( | const Array & | marker, |
| const Array & | mask, | ||
| int | ir, | ||
| float | k_smooth_max = 0.f ) |
Perform morphological reconstruction by erosion.
Iteratively erodes the marker image while constraining values to be greater than or equal to the mask. The marker must be element-wise >= mask. Optionally uses a smooth maximum controlled by k_smooth_max.
| marker | Initial image (seed), must satisfy marker >= mask. |
| mask | Constraint image (lower bound). |
| ir | Radius of the structuring element. |
| k_smooth_max | Smoothness factor (0 for hard max). |
Example
Result
| Array hmap::relative_distance_from_skeleton | ( | const Array & | array, |
| int | ir_search, | ||
| bool | zero_at_borders = true, | ||
| int | ir_erosion = 1 ) |
Computes the relative distance of each non-zero cell in a binary array from the skeleton and border.
This function calculates a relative distance measure for each non-zero cell in the input array. The measure is defined as the ratio of the cell's distance to the nearest border and the combined distances to the nearest skeleton and border cells. The skeleton is computed using the Zhang-Suen skeletonization algorithm.
| array | The input binary array for which the relative distance map is to be calculated. Non-zero values are considered for processing. |
| ir_search | The search radius for finding the nearest skeleton and border cells. |
| zero_at_borders | If true, the borders of the skeletonized image will be set to zero. |
| ir_erosion | The erosion radius applied to the skeleton. |
Example
Result
| Array hmap::relative_distance_from_skeleton | ( | const Array & | array, |
| const Array & | skeleton, | ||
| int | ir_search, | ||
| int | ir_erosion = 1 ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Computes a skeletonized version of an array.
Extracts or refines the skeleton structure of the input array using a reference skeleton mask. Optionally forces border values to zero to avoid edge artifacts.
| array | Input array to skeletonize. |
| skeleton | Reference skeleton mask or initialization array. |
| zero_at_borders | If true, clears skeleton values at borders. |
Example
Result
| Array hmap::remove_endpoints | ( | const Array & | array, |
| int | iterations = 1, | ||
| float | background_value = 0.f ) |
Removes endpoint-like pixels from a binary/weighted array.
Iteratively filters out isolated or weakly connected pixels based on their neighborhood connectivity. Pixels matching the background value or having fewer than 2 non-background neighbors are removed.
| array | Input array to process. |
| iterations | Number of erosion-like iterations to apply. |
| background_value | Value considered as background (removed). |
Example
Result
Computes the signed curvature of the distance transform.
Computes the Euclidean distance transform of a binary array, optionally smooths it, then returns the divergence of the normalized gradient: κ = div( ∇d / ||∇d|| ). Positive values indicate convex regions, negative values concave regions.
| array | Binary input (non-zero = foreground). |
| prefilter_ir | Optional smoothing radius (0 = no smoothing). |
Example
Result
Computes a signed distance transform using curvature sign.
First computes the unsigned Euclidean distance transform, then assigns its sign from the curvature of the smoothed distance field: sign = sign( div( ∇d / ||∇d|| ) ).
| array | Binary input (non-zero = foreground). |
| prefilter_ir | Optional smoothing radius for curvature evaluation. |
Computes the skeleton of a binary image using the Zhang-Suen skeletonization algorithm.
This function processes a binary input array to extract its skeleton by iteratively thinning the image until no further changes occur. It optionally sets the borders of the resulting skeletonized image to zero.
| array | The input binary array to be skeletonized. Values should typically be 0 or 1. |
| zero_at_borders | If true, the borders of the resulting array will be set to zero. |
Example
Result
See unit tests: test_skeleton.cpp
| Array hmap::morphological_operators | ( | const Array & | array, |
| int | ir, | ||
| hmap::MorphologyOperation | operation, | ||
| MinMaxKernel | kernel_type = MinMaxKernel::DISK ) |
Apply a morphological operation to the input array using a square kernel.
Dispatches to the selected morphological operator (e.g. erosion, dilation, opening, closing, gradient, etc.).
| array | Input array to process. |
| ir | Radius of the square structuring element. |
| operation | Morphological operation to apply. |
| bool hmap::init_openmp | ( | int | num_threads = -1 | ) |
| void hmap::log_openmp_info | ( | ) |
Add a kernel to a specified position in an array.
This function adds the values of a smaller kernel array to the input array, centered at the specified indices (i, j). The kernel is added element-wise.
| array | The input array to which the kernel is added. |
| kernel | The kernel array to be added. |
| i | The row index in the input array where the kernel is centered. |
| j | The column index in the input array where the kernel is centered. |
| void hmap::add_kernel_maximum_smooth | ( | Array & | array, |
| const Array & | kernel, | ||
| float | k_smooth, | ||
| int | i, | ||
| int | j ) |
Adds a smoothed maximum value from a kernel to a specified position in a 2D array.
This function applies a truncated kernel to the given array at position (ic, jc), where the kernel is truncated to ensure it fits within the array's bounds. The maximum value between the current array value and the kernel value is computed using a smoothing factor, and the result is stored back in the array.
| array | Reference to the 2D array (heightmap) where the kernel is applied. |
| kernel | The kernel array containing values to be applied to the array. |
| k_smooth | The smoothing factor used in the maximum_smooth function. |
| ic | The x-coordinate of the center in the array where the kernel is applied. |
| jc | The y-coordinate of the center in the array where the kernel is applied. |
The kernel is truncated to ensure it fits within the bounds of the array. After applying the kernel, the values in the array are updated with the result of the maximum_smooth function.
Combines two arrays by selecting values from a or b based on a slice position.
| a | First input array. |
| b | Second input array. |
| slice_x_pos | Horizontal slice position in [0,1]. |
| slice_y_pos | Vertical slice position in [0,1]. |
Example
Result
Horizontally stack two arrays side by side.
This function concatenates two arrays along their columns, forming a new array with the columns of the first array followed by the columns of the second array.
| array1 | The first array to stack. |
| array2 | The second array to stack. |
Perform diffusion-based inpainting to fill a specified region of an array.
This function fills the region defined by a mask in the input array using diffusion-based inpainting, which propagates known values to missing regions.
| array | Input array with missing regions. |
| mask | Mask specifying the region to be inpainted. |
| iterations | Number of diffusion iterations to perform. |
Example
Result
| std::vector< float > hmap::linspace | ( | float | start, |
| float | stop, | ||
| int | num, | ||
| bool | endpoint = true ) |
Generate a vector of evenly spaced numbers over a specified interval.
This function creates a vector containing evenly spaced values from start to stop. The number of values is specified by num, and endpoint determines whether to include the end value in the output.
| start | Starting value of the interval. |
| stop | End value of the interval. |
| num | Number of values to generate. |
| endpoint | If true, include the end value in the output vector. |
| std::vector< float > hmap::linspace_jitted | ( | float | start, |
| float | stop, | ||
| int | num, | ||
| float | ratio, | ||
| int | seed, | ||
| bool | endpoint = true ) |
Generate a vector of jittered (noised) numbers over a specified interval.
This function creates a vector with values spaced over an interval but with added noise, controlled by the ratio parameter. The noise is applied to an evenly spaced grid. The seed parameter controls the randomness.
| start | Starting value of the interval. |
| stop | End value of the interval. |
| num | Number of values to generate. |
| ratio | Jittering ratio applied to the evenly spaced grid. |
| seed | Random seed for generating jittered values. |
| endpoint | If true, include the end value in the output vector. |
| std::vector< float > hmap::logspace | ( | float | start, |
| float | stop, | ||
| int | num, | ||
| bool | endpoint = true ) |
Generates a logarithmically spaced vector.
Values are distributed evenly in log-space between start and stop.
| start | First value (must be > 0) |
| stop | Last value (must be > 0) |
| num | Number of samples |
| endpoint | If true, includes stop as last element |
| void hmap::fill_array_using_xy_function | ( | Array & | array, |
| const UvRect & | uv_rect, | ||
| const Array * | p_ctrl_param, | ||
| const Array * | p_noise_x, | ||
| const Array * | p_noise_y, | ||
| const Array * | p_stretching, | ||
| Fn && | fct_xy ) |
Fill an array using a scalar function based on (x, y) coordinates.
This function populates an array with values computed from a scalar function that depends on (x, y) coordinates. Additional input arrays can affect the function's computation, such as control parameters, noise, and stretching.
| array | The array to be filled with computed values. |
| bbox | The bounding box of the domain specified as {xmin, xmax, ymin, ymax}. |
| p_ctrl_param | Pointer to an array of control parameters affecting the scalar function. |
| p_noise_x | Pointer to an array of noise values along the x-direction for domain warping. |
| p_noise_y | Pointer to an array of noise values along the y-direction for domain warping. |
| p_stretching | Pointer to an array of local wavenumber multipliers for adjusting the function. |
| fct_xy | The scalar function to compute values at (x, y) with an initial value. |
Example
Result
| void hmap::fill_array_using_xy_function | ( | Array & | array, |
| const UvRect & | uv_rect, | ||
| const Array * | p_ctrl_param, | ||
| const Array * | p_noise_x, | ||
| const Array * | p_noise_y, | ||
| const Array * | p_stretching, | ||
| Fn && | fct_xy, | ||
| int | subsampling ) |
Fill an array using a scalar function based on (x, y) coordinates with subsampling.
This function is similar to the one above but includes a subsampling parameter to optimize performance. The array is subsampled during computation based on the subsampling factor, which determines how frequently the scalar function is applied.
| array | The array to be filled with computed values. |
| bbox | The bounding box of the domain specified as {xmin, xmax, ymin, ymax}. |
| p_ctrl_param | Pointer to an array of control parameters affecting the scalar function. |
| p_noise_x | Pointer to an array of noise values along the x-direction for domain warping. |
| p_noise_y | Pointer to an array of noise values along the y-direction for domain warping. |
| p_stretching | Pointer to an array of local wavenumber multipliers for adjusting the function. |
| fct_xy | The scalar function to compute values at (x, y) with an initial value. |
| subsampling | The factor by which the array is subsampled during computation. |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::find_vertical_cut_path | ( | const Array & | error, |
| std::vector< int > & | path_i ) |
Find the vertical cut path with the minimum cost using dynamic programming.
This function identifies the vertical cut path in an array from the bottom to the top that has the minimum cumulative cost.
| error | Input array containing error or cost values. |
| path_i | Output vector of indices representing the cut path. |
| Array hmap::generate_mask | ( | glm::ivec2 | shape, |
| std::vector< int > | cut_path_i, | ||
| int | ir ) |
Generate a smooth mask based on a cut path.
This function creates a mask based on the vertical cut path indices obtained from the find_vertical_cut_path function. The mask is smoothed using a specified filtering radius.
| shape | Shape of the mask to be generated. |
| cut_path_i | Vector of vertical cut path indices. |
| ir | Filtering radius for smoothing the mask. |
| Array hmap::get_random_patch | ( | const Array & | array, |
| glm::ivec2 | patch_shape, | ||
| std::mt19937 & | gen, | ||
| bool | patch_flip = false, | ||
| bool | patch_rotate = false, | ||
| bool | patch_transpose = false, | ||
| std::vector< Array * > * | p_secondary_arrays = nullptr, | ||
| std::vector< Array > * | p_secondary_patches = nullptr ) |
Extracts a random sub-array (patch) from the input array, with optional transformations.
This function selects a random patch from the specified input array and applies optional transformations such as flipping, rotation, and transposition. Additionally, if a list of secondary arrays is provided, corresponding patches are extracted and transformed in the same way.
| array | The main input array from which the patch is extracted. |
| patch_shape | The shape (dimensions) of the patch to be extracted. |
| gen | Random number generator for selecting patch location. |
| patch_flip | If true, allows the patch to be flipped vertically or horizontally. |
| patch_rotate | If true, allows the patch to be rotated by 90 degrees. |
| patch_transpose | If true, allows the patch to be transposed. |
| p_secondary_arrays | Optional pointer to a list of secondary arrays. If provided, patches will be extracted and transformed from each array in the list, with the same transformations as the primary patch. |
| p_secondary_patches | Optional pointer to a list for storing the transformed patches from each secondary array. |
| std::vector< float > hmap::random_vector | ( | float | min, |
| float | max, | ||
| int | num, | ||
| int | seed ) |
Generate a vector filled with random values within a specified range.
This function creates a vector with random values uniformly distributed between min and max. The number of values and the randomness is controlled by the seed parameter.
| min | Lower bound of the random values. |
| max | Upper bound of the random values. |
| num | Number of random values to generate. |
| seed | Random seed for generating values. |
| void hmap::rescale_vector | ( | std::vector< float > & | vec, |
| float | vmin, | ||
| float | vmax ) |
Rescales the values of a vector to a specified range.
This function linearly rescales all elements in vec so that their new values lie within the range [vmin, vmax]. The rescaling is based on the current minimum and maximum values found in the input vector.
Special cases:
vec is empty, the function does nothing.vec are equal, they are replaced by that constant value.| vec | Reference to the vector of float values to rescale (modified in place). |
| vmin | Desired minimum value after rescaling. |
| vmax | Desired maximum value after rescaling. |
| std::vector< float > hmap::rescaled_vector | ( | const std::vector< float > & | vec, |
| float | vmin, | ||
| float | vmax ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Vertically stack two arrays.
This function concatenates two arrays along their rows, resulting in a new array where the rows of the second array are stacked below the rows of the first array.
| array1 | The first array to be stacked. |
| array2 | The second array to be stacked. |
Applies a transformation function with optional masked blending.
If p_mask is null, the function operates directly on array in-place. Otherwise, the transformation is applied on a temporary copy and blended back into array using the mask values.
| array | Input/output array to modify. |
| p_mask | Optional mask controlling interpolation strength. |
| fn | Transformation function operating in-place on an Array. |
| Array hmap::transform_with_mask | ( | const Array & | array, |
| const Array * | p_mask, | ||
| Fn && | fn ) |
Applies a transformation function with optional masked blending.
The function computes a transformed array using fn(array). If p_mask is provided, the result is blended with the original array using the mask values.
| array | Input array. |
| p_mask | Optional mask controlling interpolation strength. |
| fn | Transformation function returning a new Array. |
| Array hmap::dendry | ( | glm::ivec2 | shape, |
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| Array & | control_function, | ||
| float | eps = 0.05, | ||
| int | resolution = 1, | ||
| float | displacement = 0.075, | ||
| int | primitives_resolution_steps = 3, | ||
| float | slope_power = 2.f, | ||
| float | noise_amplitude_proportion = 0.01, | ||
| bool | add_control_function = true, | ||
| float | control_function_overlap = 0.5f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| int | subsampling = 1 ) |
Dendry is a locally computable procedural function that generates branching patterns at various scales (see [Gaillard2019]).
| shape | Array shape. |
| kw | Noise wavenumber with respect to a unit domain. |
| seed | Random seed number. |
| control_array | Control array (can be of any shape, different from shape). |
| eps | Epsilon used to bias the area where points are generated in cells. |
| resolution | Number of resolutions in the noise function. |
| displacement | Maximum displacement of segments. |
| primitives_resolution_steps | Additional resolution steps in the ComputeColorPrimitives function. |
| slope_power | Additional parameter to control the variation of slope on terrains. |
| noise_amplitude_proportion | Proportion of the amplitude of the control function as noise. |
| add_control_function | Add control function to the output. |
| control_function_overlap | Extent of the extension added at the domain frontiers of the control array. |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::dendry | ( | glm::ivec2 | shape, |
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| const std::function< float(float, float, float)> & | noise_function, | ||
| float | noise_function_offset = 0.f, | ||
| float | noise_function_scaling = 1.f, | ||
| float | eps = 0.05, | ||
| int | resolution = 1, | ||
| float | displacement = 0.075, | ||
| int | primitives_resolution_steps = 3, | ||
| float | slope_power = 2.f, | ||
| float | noise_amplitude_proportion = 0.01, | ||
| bool | add_control_function = true, | ||
| float | control_function_overlap = 0.5f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
| Array hmap::diffusion_limited_aggregation | ( | glm::ivec2 | shape, |
| float | scale, | ||
| std::uint32_t | seed, | ||
| float | seeding_radius = 0.4f, | ||
| float | seeding_outer_radius_ratio = 0.2f, | ||
| float | slope = 8.f, | ||
| float | noise_ratio = 0.2f ) |
Generates a diffusion-limited aggregation (DLA) pattern.
This function simulates the diffusion-limited aggregation process to generate a pattern within a grid of specified dimensions. The DLA process models particles that undergo a random walk until they stick to a seed, gradually forming complex fractal structures.
| shape | The dimensions of the grid where the DLA pattern will be generated. It is represented as a glm::ivec2 object, where the first element is the width and the second element is the height. |
| scale | A scaling factor that influences the density of the particles in the DLA pattern. |
| seeding_radius | The radius within which initial seeding of particles occurs. This radius defines the area where the first particles are placed. |
| seeding_outer_radius_ratio | The ratio between the outer seeding radius and the initial seeding radius. It determines the outer boundary for particle seeding. |
| slope | Slope of the talus added to the DLA pattern. |
| noise_ratio | A parameter that controls the amount of randomness or noise introduced in the talus formation process. |
| seed | The seed for the random number generator, ensuring reproducibility of the pattern. The same seed will generate the same pattern. |
Example
Result
| Array hmap::diffusion_limited_aggregation_trimesh | ( | glm::ivec2 | shape, |
| std::uint32_t | seed, | ||
| size_t | control_points_count = 5000, | ||
| glm::vec2 | seed_position = {0.5f, 0.5f}, | ||
| float | ratio = 0.98f, | ||
| float | stop_proba = 1.f, | ||
| float | slope = 16.f, | ||
| InterpolationMethod2D | interpolation_method = InterpolationMethod2D::ITP2D_DELAUNAY_GRADIENT, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::gabor_noise | ( | glm::ivec2 | shape, |
| float | kw, | ||
| float | angle, | ||
| int | width, | ||
| float | density, | ||
| std::uint32_t | seed ) |
Return a sparse Gabor noise.
| shape | Array shape. |
| kw | Kernel wavenumber, with respect to a unit domain. |
| angle | Kernel angle (in degree). |
| width | Kernel width (in pixels). |
| density | Spot noise density. |
| seed | Random seed number. |
Example
Result
| Array hmap::noise | ( | NoiseType | noise_type, |
| glm::ivec2 | shape, | ||
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | angle = 0.f, | ||
| float | stretch = 1.f ) |
Return an array filled with coherence noise.
| noise_type | Noise type. |
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions. |
| seed | Random seed number. |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::noise_fbm | ( | NoiseType | noise_type, |
| glm::ivec2 | shape, | ||
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| 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 UvRect & | uv_rect = UvRect::unit(), | ||
| float | angle = 0.f, | ||
| float | stretch = 1.f, | ||
| float | stretch_decay = 0.f ) |
Return an array filled with coherence fbm noise.
| noise_type | Noise type. |
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions. |
| seed | Random seed number. |
| octaves | Number of octaves. |
| weigth | Octave weighting. |
| persistence | Octave persistence. |
| lacunarity | Defines the wavenumber ratio between each octaves. |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the weight parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::noise_iq | ( | NoiseType | noise_type, |
| glm::ivec2 | shape, | ||
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| int | octaves = 8, | ||
| float | weight = 0.7f, | ||
| float | persistence = 0.5f, | ||
| float | lacunarity = 2.f, | ||
| float | gradient_scale = 0.05f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | angle = 0.f, | ||
| float | stretch = 1.f, | ||
| float | stretch_decay = 0.f ) |
Return an array filled with coherence fbm noise.
| noise_type | Noise type. |
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions. |
| seed | Random seed number. |
| octaves | Number of octaves. |
| weigth | Octave weighting. |
| persistence | Octave persistence. |
| lacunarity | Defines the wavenumber ratio between each octaves. |
| gradient_scale | Gradient scale. |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the weight parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::noise_jordan | ( | NoiseType | noise_type, |
| glm::ivec2 | shape, | ||
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| int | octaves = 8, | ||
| float | weight = 0.7f, | ||
| float | persistence = 0.5f, | ||
| float | lacunarity = 2.f, | ||
| float | warp0 = 0.4f, | ||
| float | damp0 = 1.f, | ||
| float | warp_scale = 0.4f, | ||
| float | damp_scale = 1.f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | angle = 0.f, | ||
| float | stretch = 1.f, | ||
| float | stretch_decay = 0.f ) |
Return an array filled with coherence fbm noise.
| noise_type | Noise type. |
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions. |
| seed | Random seed number. |
| octaves | Number of octaves. |
| weigth | Octave weighting. |
| persistence | Octave persistence. |
| lacunarity | Defines the wavenumber ratio between each octaves. |
| warp0 | Initial warp scale. |
| damp0 | Initial damp scale. |
| warp_scale | Warp scale. |
| damp_scale | Damp scale. |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the weight parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::noise_parberry | ( | glm::ivec2 | shape, |
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| int | octaves = 8, | ||
| float | weight = 0.7f, | ||
| float | persistence = 0.5f, | ||
| float | lacunarity = 2.f, | ||
| float | mu = 1.02f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | angle = 0.f, | ||
| float | stretch = 1.f, | ||
| float | stretch_decay = 0.f ) |
Return an array filled with coherent fbm Parberry variant of Perlin noise.
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions. |
| seed | Random seed number. |
| octaves | Number of octaves. |
| weigth | Octave weighting. |
| persistence | Octave persistence. |
| lacunarity | Defines the wavenumber ratio between each octaves. |
| mu | Gradient magnitude exponent. |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the weight parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::noise_pingpong | ( | NoiseType | noise_type, |
| glm::ivec2 | shape, | ||
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| 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 UvRect & | uv_rect = UvRect::unit(), | ||
| float | angle = 0.f, | ||
| float | stretch = 1.f, | ||
| float | stretch_decay = 0.f ) |
Return an array filled with coherence fbm pingpong noise.
| noise_type | Noise type. |
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions. |
| seed | Random seed number. |
| octaves | Number of octaves. |
| weigth | Octave weighting. |
| persistence | Octave persistence. |
| lacunarity | Defines the wavenumber ratio between each octaves. |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the weight parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::noise_ridged | ( | NoiseType | noise_type, |
| glm::ivec2 | shape, | ||
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| int | octaves = 8, | ||
| float | weight = 0.7f, | ||
| float | persistence = 0.5f, | ||
| float | lacunarity = 2.f, | ||
| float | k_smoothing = 0.1f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | angle = 0.f, | ||
| float | stretch = 1.f, | ||
| float | stretch_decay = 0.f ) |
Return an array filled with coherence fbm ridged noise.
| noise_type | Noise type. |
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions. |
| seed | Random seed number. |
| octaves | Number of octaves. |
| weigth | Octave weighting. |
| persistence | Octave persistence. |
| lacunarity | Defines the wavenumber ratio between each octaves. |
| k_smoothing | Smoothing parameter. |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the weight parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::noise_slope | ( | NoiseType | noise_type, |
| glm::ivec2 | shape, | ||
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| int | octaves = 8, | ||
| float | weight = 0.7f, | ||
| float | persistence = 0.5f, | ||
| float | lacunarity = 2.f, | ||
| float | gradient_scale = 0.5f, | ||
| float | slope_power = 2.f, | ||
| float | octave_blend = 0.5f, | ||
| float | bias_angle = 0.f, | ||
| float | bias_strength = 0.f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | angle = 0.f, | ||
| float | stretch = 1.f, | ||
| float | stretch_decay = 0.f ) |
Return an array filled with slope-weighted coherence fbm noise.
Modulates higher-octave amplitude by the accumulated low-frequency gradient norm so that flat areas remain smooth while steep slopes develop rugosity.
| noise_type | Noise type. |
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions. |
| seed | Random seed number. |
| octaves | Number of octaves. |
| weight | Octave weighting. |
| persistence | Octave persistence. |
| lacunarity | Defines the wavenumber ratio between each octaves. |
| gradient_scale | Gradient scale influence. |
| slope_power | Exponent controlling slope transition sharpness. |
| octave_blend | Rate at which higher octaves become slope-masked. |
| bias_angle | Preferred slope direction angle in degrees. |
| bias_strength | Directional bias strength in [0, 1]. |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the weight parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| bbox | Domain bounding box. |
| angle | Stretching direction angle in degrees. |
| stretch | Stretching factor along the direction. |
| stretch_decay | Progressive decay of stretching across octaves. |
| Array hmap::noise_swiss | ( | NoiseType | noise_type, |
| glm::ivec2 | shape, | ||
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| int | octaves = 8, | ||
| float | weight = 0.7f, | ||
| float | persistence = 0.5f, | ||
| float | lacunarity = 2.f, | ||
| float | warp_scale = 0.1f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| float | angle = 0.f, | ||
| float | stretch = 1.f, | ||
| float | stretch_decay = 0.f ) |
Return an array filled with coherence fbm swiss noise.
| noise_type | Noise type. |
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions. |
| seed | Random seed number. |
| octaves | Number of octaves. |
| weigth | Octave weighting. |
| persistence | Octave persistence. |
| lacunarity | Defines the wavenumber ratio between each octaves. |
| warp_scale | Warp scale. |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the weight parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::worley_double | ( | glm::ivec2 | shape, |
| glm::vec2 | kw, | ||
| std::uint32_t | seed, | ||
| float | ratio = 0.5f, | ||
| float | k = 0.f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return an array filled with the maximum of two Worley (cellular) noises.
| shape | Array shape. |
| kw | Noise wavenumbers {kx, ky} for each directions, with respect to a unit domain. |
| seed | Random seed number. |
| ratio | Amplitude ratio between each Worley noise. |
| k | Transition smoothing parameter. |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the ratio parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::get_primitive_base | ( | const PrimitiveType & | primitive_type, |
| const glm::ivec2 & | shape, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a primitive shape as a 2D array.
| primitive_type | Type of primitive to generate. |
| shape | Output array resolution. |
| p_noise_x | Optional X-direction noise modulation. |
| p_noise_y | Optional Y-direction noise modulation. |
| center | Center position of the primitive (normalized). |
| bbox | Bounding box of the primitive (normalized). |
| Array hmap::band | ( | glm::ivec2 | shape, |
| float | angle, | ||
| float | length = 0.5f, | ||
| float | width = 0.1f, | ||
| RadialProfile | profile = RadialProfile::RP_SMOOTHSTEP, | ||
| float | profile_param = 0.f, | ||
| const Array * | p_noise_r = nullptr, | ||
| const Array * | p_noise_offset = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generate a bounded band (capsule) mask.
Creates a 0 to 1 mask shaped as a capsule: the value is 1 on a core segment defined by center, angle and length, and falls off to 0 at a distance width from the segment, following the requested radial profile. Typical uses: mountain-range envelopes, island-chain arc envelopes and, with a length larger than the domain, latitude bands / polar caps (place center on or beyond a domain edge).
| shape | Output array shape. |
| angle | Band orientation angle in degrees. |
| length | Core segment length in normalized domain units. A zero length degenerates to a radial bump. |
| width | Falloff half-width in normalized domain units. |
| profile | Radial profile used for the falloff. |
| profile_param | Additional parameter for the profile. |
| p_noise_r | Optional noise array used to locally perturb the falloff distance (edge displacement). |
| p_noise_offset | Optional noise array used to locally offset the band axis position (normalized by width). |
| center | Band center in normalized coordinates. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::biquad_pulse | ( | glm::ivec2 | shape, |
| float | gain = 1.f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a 'biquadratic pulse'.
| shape | Array shape. |
| gain | Gain (the higher, the steeper). |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the gain parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::biquad_pulse_x | ( | glm::ivec2 | shape, |
| const UvRect & | uv_rect = UvRect::unit() ) |
| Array hmap::biquad_pulse_y | ( | glm::ivec2 | shape, |
| const UvRect & | uv_rect = UvRect::unit() ) |
| Array hmap::bump | ( | glm::ivec2 | shape, |
| float | gain = 1.f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a bump.
| shape | Array shape. |
| gain | Gain (the higher, the steeper the bump). |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the gain parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::bump_lorentzian | ( | glm::ivec2 | shape, |
| float | shape_factor = 0.5f, | ||
| float | radius = 0.5f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a 2D Lorentzian bump pattern.
This function fills an array with values computed from a normalized Lorentzian-shaped bump function. The bump is centered at a given position, has a specified radius, and can vary in width depending on a control parameter. Optional noise arrays can be applied to perturb the x and y coordinates before evaluation.
The Lorentzian function is normalized so that it returns 1.0 at the center and smoothly decays to 0.0 at the radius boundary. Outside the radius, the value is exactly 0.
| shape | Dimensions of the output array (width, height). |
| width_factor | Scaling factor controlling the bump width relative to the control parameter. |
| radius | Radius of the bump in the coordinate space of bbox. |
| p_ctrl_param | Optional pointer to an array of per-pixel control parameters. If provided, it modulates the width of the Lorentzian bump. |
| p_noise_x | Optional pointer to an array of x-offset noise values. Values are added to the x coordinate before evaluation. |
| p_noise_y | Optional pointer to an array of y-offset noise values. Values are added to the y coordinate before evaluation. |
| center | Center of the bump in the coordinate space of bbox. |
| bbox | Bounding box (xmin, ymin, xmax, ymax) defining the coordinate space for the array. |
shape containing the bump pattern.radius.Example
Result
| Array hmap::checkerboard | ( | glm::ivec2 | shape, |
| glm::vec2 | kw, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a checkerboard heightmap.
| shape | Array shape. |
| kw | Noise wavenumber with respect to a unit domain. |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::cone | ( | glm::ivec2 | shape, |
| float | slope, | ||
| float | apex_elevation = 1.f, | ||
| bool | smooth_profile = false, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a synthetic conical mountain heightmap.
This function creates a simple cone-shaped elevation field centered at a given position. The cone profile follows a linear slope until it reaches the talus angle, resembling volcanic cones or alluvial fans. Optional displacement noise fields can be applied to perturb the cone shape.
| shape | Output array shape (resolution in x and y). |
| slope | Slope angle of the cone (controls steepness of the sides). |
| center | Center of the cone in normalized coordinates (default = {0.5f, 0.5f}). |
| p_noise_x | Optional pointer to external displacement noise field (X-axis). |
| p_noise_y | Optional pointer to external displacement noise field (Y-axis). |
| bbox | Bounding box of the generation domain in normalized coordinates (default = {0.f, 1.f, 0.f, 1.f}). |
Example
Result
| Array hmap::cone_complex | ( | glm::ivec2 | shape, |
| float | alpha, | ||
| float | radius = 0.5f, | ||
| bool | smooth_profile = true, | ||
| float | valley_amp = 0.2f, | ||
| int | valley_nb = 5, | ||
| float | valley_decay_ratio = 0.5f, | ||
| float | valley_angle0 = 15.f, | ||
| const ErosionProfile & | erosion_profile = ErosionProfile::EP_TRIANGLE_GRENIER, | ||
| float | erosion_delta = 0.01f, | ||
| float | radial_waviness_amp = 0.05f, | ||
| float | radial_waviness_kw = 2.f, | ||
| float | bias_angle = 30.f, | ||
| float | bias_amp = 0.75f, | ||
| float | bias_exponent = 1.f, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a complex conical heightfield with valleys, directional bias, and radial waviness.
This function procedurally constructs an island-like cone shape inside a 2D array. The height at each position is determined from the normalized radial distance to the center, with optional modulation by valleys, directional bias, and radial waviness. An erosion profile is applied to shape the valleys, and an optional control map can modulate the valley amplitude locally. The resulting height values are clamped to [0, 1].
| shape | Output array dimensions (width, height). |
| alpha | Exponent controlling the steepness of the cone slope. |
| radius | Effective radius of the island (in coordinate space units). |
| valley_amp | Global amplitude of valley depressions. |
| valley_nb | Number of valleys around the island. |
| valley_decay_ratio | Controls how valley amplitude decays toward the center. |
| valley_angle0 | Angular offset of the first valley (in degrees). |
| erosion_profile | Erosion profile type used for shaping valley cross-sections. |
| erosion_delta | Smoothing parameter for the erosion profile function. |
| radial_waviness_amp | Amplitude of radial sinusoidal perturbations (coastal waviness). |
| radial_waviness_kw | Frequency multiplier for radial waviness. |
| bias_angle | Direction (in degrees) of the slope bias (e.g. wind or sun exposure). |
| bias_amp | Amplitude of the directional bias effect. |
| bias_exponent | Controls how bias strength varies with radius. |
| center | Center position of the cone in coordinate space. |
| p_ctrl_param | Optional control array; its values modulate the local valley amplitude. If nullptr, the valley amplitude is uniform. |
| p_noise_x | Optional X-displacement noise field for coordinate perturbation. |
| p_noise_y | Optional Y-displacement noise field for coordinate perturbation. |
| bbox | Bounding box defining the world coordinates covered by the array. |
Example
Result
| Array hmap::cone_sigmoid | ( | glm::ivec2 | shape, |
| float | alpha, | ||
| float | radius = 0.5f, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a smooth conical heightmap using a sigmoid-based profile.
This function creates a 2D array representing a cone shape centered at a given position. The height decreases radially from the apex according to a sigmoid-shaped falloff, producing a smooth, rounded cone rather than a sharp linear one. Optionally, displacement noise can be applied along the X and Y axes to perturb the cone surface.
| shape | Dimensions of the output array (width, height). |
| alpha | Peak elevation value of the cone (controls maximum height). |
| radius | Radius of the cone base, expressed in normalized [0, 1] units relative to the bounding box. |
| center | Normalized coordinates of the cone’s center (default = {0.5, 0.5}). |
| p_noise_x | Optional pointer to an array representing horizontal displacement noise (nullptr for none). |
| p_noise_y | Optional pointer to an array representing vertical displacement noise (nullptr for none). |
| bbox | Bounding box of the generated region in (xmin, xmax, ymin, ymax) order. |
Example
Result
| Array hmap::cubic_pulse | ( | glm::ivec2 | shape, |
| const Array * | p_noise_x, | ||
| const Array * | p_noise_y, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a cubic pulse array.
| Array hmap::disk | ( | glm::ivec2 | shape, |
| float | radius, | ||
| float | slope = 1.f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a disk-shaped heightmap with optional modifications.
This function creates a 2D array representing a disk shape with a specified radius, slope, and other optional parameters such as control parameters, noise, and stretching for additional customization.
| shape | Dimensions of the output array (width, height). |
| radius | Radius of the disk, in normalized coordinates (0.0 to 1.0). |
| slope | Slope of the disk edge transition. A larger value makes the edge transition sharper. Defaults to 1.0. |
| p_ctrl_param | Optional pointer to an Array controlling custom parameters for the disk generation. |
| p_noise_x | Optional pointer to an Array for adding noise in the x-direction. |
| p_noise_y | Optional pointer to an Array for adding noise in the y-direction. |
| p_stretching | Optional pointer to an Array for stretching the disk horizontally or vertically. |
| center | Center of the disk in normalized coordinates (0.0 to 1.0). Defaults to {0.5, 0.5}. |
| bbox | Bounding box for the disk in normalized coordinates {x_min, x_max, y_min, y_max}. Defaults to {0.0, 1.0, 0.0, 1.0}. |
Result
| Array hmap::gaussian_pulse | ( | glm::ivec2 | shape, |
| float | sigma, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a gaussian_decay pulse kernel.
| shape | Array shape. |
| sigma | Gaussian sigma (in pixels). |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the half-width parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| center | Primitive reference center. |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::multisteps | ( | glm::ivec2 | shape, |
| float | angle, | ||
| float | r = 1.2f, | ||
| int | nsteps = 8, | ||
| float | elevation_exponent = 0.7f, | ||
| float | shape_gain = 4.f, | ||
| float | scale = 0.5f, | ||
| float | outer_slope = 0.1f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const glm::vec2 & | center = {0.5f, 0.5f}, | ||
| const BBox2D & | bbox = BBox2D::unit() ) |
Generate a multi-step height profile along a rotated axis.
Constructs an Array where values follow a sequence of geometric steps blended with an optional linear transition. Steps are rotated by the given angle, can be shaped with an exponent, and may be modulated by optional control and noise fields.
| shape | Output array resolution. |
| angle | Rotation angle in degrees. |
| r | Geometric ratio between successive step widths. |
| nsteps | Number of steps. |
| elevation_exponent | Exponent shaping step heights. |
| shape_gain | Gain used to reshape intra-step transitions. |
| scale | Scale of the step axis. |
| outer_slope | Slope outside the [0,1] axis interval. |
| p_ctrl_param | Optional control parameter array. |
| p_noise_x | Optional x-axis noise array. |
| p_noise_y | Optional y-axis noise array. |
| center | Center of the step axis. |
| bbox | Bounding box of the domain. |
Example
Result
| Array hmap::paraboloid | ( | glm::ivec2 | shape, |
| float | angle, | ||
| float | a, | ||
| float | b, | ||
| float | v0 = 0.f, | ||
| bool | reverse_x = false, | ||
| bool | reverse_y = false, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a paraboloid.
| shape | Array shape. |
| angle | Rotation angle. |
| a | Curvature parameter, first principal axis. |
| b | Curvature parameter, second principal axis. |
| v0 | Value at the paraboloid center. |
| reverse_x | Reverse coefficient of first principal axis. |
| reverse_y | Reverse coefficient of second principal axis. |
| p_base_elevation | Reference to the control parameter array (acts as a multiplier for the weight parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::polar_shape | ( | glm::ivec2 | shape, |
| float | rmin = 0.1f, | ||
| float | rmax = 0.3f, | ||
| float | aspect_ratio = 1.f, | ||
| float | smoothing_width = 0.1f, | ||
| bool | square_base = false, | ||
| float | angle = 15.f, | ||
| float | sector_angle = 90.f, | ||
| float | vmin = 0.5f, | ||
| float | kt_value = 0.f, | ||
| float | kr_border = 0.f, | ||
| float | kr_border_ratio = 0.1f, | ||
| const Array * | p_noise_r = nullptr, | ||
| const Array * | p_noise_theta = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generate a polar-based shape mask with optional angular and radial perturbations.
Creates a 2D scalar field defined in polar space using radial bounds, sector masking, aspect ratio deformation, and optional noise offsets on radius and angle.
| shape | Output array shape. |
| rmin | Inner radius. |
| rmax | Outer radius. |
| aspect_ratio | Elliptical aspect ratio applied on Y axis. |
| smoothing_width | Smoothing width for radial and angular transitions. |
| square_base | If true, remaps the shape toward a square profile. |
| angle | Global rotation angle in degrees. |
| sector_angle | Angular opening removed from the shape in degrees. |
| vmin | Minimum angular modulation value. |
| kt_value | Angular modulation frequency. |
| kr_border | Angular modulation frequency for the outer border. |
| kr_border_ratio | Blend factor for outer border modulation. |
| p_noise_r | Optional radial noise offset field. |
| p_noise_theta | Optional angular noise offset field. |
| center | Shape center. |
| bbox | Bounding box used for grid generation. |
Example
Result
| Array hmap::quad_surface | ( | glm::ivec2 | shape, |
| float | c00 = 0.f, | ||
| float | c10 = 0.f, | ||
| float | c01 = 0.f, | ||
| float | c11 = 0.f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a surface defined by the four corner values of the domain.
Interpolates values across the domain using a quadratic / bilinear surface function derived from the four corner elevations.
| shape | Dimensions of the output array (width, height). |
| c00 | Elevation at bottom-left corner (xmin, ymin). |
| c10 | Elevation at bottom-right corner (xmax, ymin). |
| c01 | Elevation at top-left corner (xmin, ymax). |
| c11 | Elevation at top-right corner (xmax, ymax). |
| p_ctrl_param | Optional pointer to a control parameter array (multiplier). |
| p_noise_x | Optional pointer to x-direction displacement noise array. |
| p_noise_y | Optional pointer to y-direction displacement noise array. |
| bbox | Bounding box defining the domain coordinates (xmin, xmax, ymin, ymax). |
Example
Result
| Array hmap::rectangle | ( | glm::ivec2 | shape, |
| float | rx, | ||
| float | ry, | ||
| float | angle, | ||
| float | slope = 1.f, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a rectangle-shaped heightmap with optional modifications.
This function creates a 2D array representing a rectangle with specified dimensions, rotation, and optional parameters for customization such as control parameters, noise, and stretching.
| shape | Dimensions of the output array (width, height). |
| rx | Half-width of the rectangle, in normalized coordinates (0.0 to 1.0). |
| ry | Half-height of the rectangle, in normalized coordinates (0.0 to 1.0). |
| angle | Rotation angle of the rectangle in radians. Positive values rotate counterclockwise. |
| slope | Slope of the rectangle edge transition. A larger value makes the edge transition sharper. Defaults to 1.0. |
| p_ctrl_param | Optional pointer to an Array controlling custom parameters for the rectangle generation. |
| p_noise_x | Optional pointer to an Array for adding noise in the x-direction. |
| p_noise_y | Optional pointer to an Array for adding noise in the y-direction. |
| p_stretching | Optional pointer to an Array for stretching the rectangle horizontally or vertically. |
| center | Center of the rectangle in normalized coordinates (0.0 to 1.0). Defaults to {0.5, 0.5}. |
| bbox | Bounding box for the rectangle in normalized coordinates {x_min, x_max, y_min, y_max}. Defaults to {0.0, 1.0, 0.0, 1.0}. |
Result
| Array hmap::slope | ( | glm::ivec2 | shape, |
| float | angle, | ||
| float | slope, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return an array corresponding to a slope with a given overall.
| shape | Array shape. |
| angle | Overall rotation angle (in degree). |
| slope | Slope (assuming a unit domain). |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the slope parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local coordinate multiplier. |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::smooth_cosine | ( | glm::ivec2 | shape, |
| const Array * | p_noise_x, | ||
| const Array * | p_noise_y, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a smooth cosine array.
| Array hmap::step | ( | glm::ivec2 | shape, |
| float | angle, | ||
| float | slope, | ||
| const Array * | p_ctrl_param = nullptr, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a step function (Heaviside with an optional talus slope at the transition).
| shape | Array shape. |
| angle | Overall rotation angle (in degree). |
| slope | Step slope (assuming a unit domain). |
| p_ctrl_param | Reference to the control parameter array (acts as a multiplier for the slope parameter). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local coordinate multiplier. |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
Example
Result
| void hmap::swirl | ( | Array & | dx, |
| Array & | dy, | ||
| float | amplitude = 1.f, | ||
| float | exponent = 1.f, | ||
| const Array * | p_noise = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generate displacements dx and dy to apply a swirl effect to another primitve.
| dx[out] | 'x' displacement (unit domain scale). |
| dy[out] | 'y' displacement (unit domain scale). |
| amplitude | Displacement amplitude. |
| exponent | Distance exponent. |
| p_noise | eference to the input noise array. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::wave_dune | ( | glm::ivec2 | shape, |
| float | kw, | ||
| float | angle, | ||
| float | xtop, | ||
| float | xbottom, | ||
| float | phase_shift = 0.f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a dune shape wave.
| shape | Array shape. |
| kw | Wavenumber with respect to a unit domain. |
| angle | Overall rotation angle (in degree). |
| xtop | Relative location of the top of the dune profile (in [0, 1]). |
| xbottom | Relative location of the foot of the dune profile (in [0, 1]). |
| phase_shift | Phase shift (in radians). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
| Array hmap::wave_sine | ( | glm::ivec2 | shape, |
| float | kw, | ||
| float | angle, | ||
| float | phase_shift = 0.f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a sine wave.
| shape | Array shape. |
| kw | Wavenumber with respect to a unit domain. |
| angle | Overall rotation angle (in degree). |
| phase_shift | Phase shift (in radians). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::wave_square | ( | glm::ivec2 | shape, |
| float | kw, | ||
| float | angle, | ||
| float | phase_shift = 0.f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a square wave.
| shape | Array shape. |
| kw | Wavenumber with respect to a unit domain. |
| angle | Overall rotation angle (in degree). |
| phase_shift | Phase shift (in radians). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::wave_triangular | ( | glm::ivec2 | shape, |
| float | kw, | ||
| float | angle, | ||
| float | slant_ratio, | ||
| float | phase_shift = 0.f, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a triangular wave.
| shape | Array shape. |
| kw | Wavenumber with respect to a unit domain. |
| angle | Overall rotation angle (in degree). |
| slant_ratio | Relative location of the triangle apex, in [0, 1]. |
| phase_shift | Phase shift (in radians). |
| p_noise_x,p_noise_y | Reference to the input noise arrays. |
| p_stretching | Local wavenumber multiplier. |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::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}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Return a caldera-shaped heightmap.
| shape | Array shape. |
| radius | Crater radius at the ridge. |
| sigma_inner | Inner half-width. |
| sigma_outer | Outer half-width. |
| z_bottom | Bottom elevation (ridge is at elevation 1). |
| p_noise | Displacement noise. |
| noise_r_amp | Radial noise amplitude. |
| noise_ratio_z | Vertical noise relative scale (in [0, 1]). |
| center | Primitive reference center. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::caldera | ( | glm::ivec2 | shape, |
| float | radius, | ||
| float | sigma_inner, | ||
| float | sigma_outer, | ||
| float | z_bottom, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| Array hmap::circus | ( | glm::ivec2 | shape, |
| float | radius = 0.4f, | ||
| float | angle = 0.f, | ||
| float | exit_width = 0.35f, | ||
| float | exit_depth = 0.f, | ||
| float | center_depth = 0.1f, | ||
| float | ridge_height = 1.f, | ||
| float | ridge_width = 0.15f, | ||
| float | outer_falloff = 2.f, | ||
| const Array * | p_noise_r = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| Array * | p_mask = nullptr ) |
Generate a procedural circus (glacial cirque / amphitheatre basin) heightmap.
Generates an elevation envelope representing a basin/depression with a defined low exit point, a central depression, and an elevated arc on the side opposite the exit point.
| shape | Output array shape. |
| radius | Circus basin/ridge radius. |
| angle | Exit point direction angle in degrees. |
| exit_width | Angular opening/width factor of the low exit. |
| exit_depth | Elevation at the low exit point. |
| center_depth | Elevation in the central basin depression. |
| ridge_height | Elevation of the opposite ridge arc. |
| ridge_width | Radial width of the ridge crest. |
| outer_falloff | Exponent controlling the outer slope falloff. |
| p_noise_r | Optional radial noise distortion. |
| center | Center position in normalized domain coordinates. |
| bbox | Bounding box coordinates. |
| p_mask | Optional output mask of the circus envelope. |
Example
Result
| Array hmap::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, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| Array * | p_crater_mask = nullptr, | ||
| Array * | p_inner_crater_mask = nullptr ) |
Generate a procedural impact crater heightmap.
Creates a crater-shaped terrain with configurable inner cavity, outer lip, asymmetry, terraces, and optional central peak. Optional masks for the crater region and inner crater region can also be generated.
| shape | Output array shape. |
| radius | Crater radius. |
| center | Crater center position. |
| angle | Main asymmetry orientation angle in degrees. |
| inner_depth | Depth of the crater cavity. |
| inner_exp | Exponent controlling the inner profile shape. |
| lip_height | Height of the crater rim. |
| lip_extent | Extent of the outer rim. |
| lip_exp | Exponent controlling rim falloff. |
| asym_ratio | Asymmetry factor applied along the main direction. |
| central_peak_height | Height of the central peak. |
| central_peak_extent | Radius of the central peak region. |
| n_terraces | Number of inner terraces. |
| terrace_extent | Terrace spacing factor. |
| terrace_exp | Terrace profile exponent. |
| terrace_persistence | Terrace amplitude decay factor. |
| p_noise_r | Optional radial noise distortion. |
| bbox | Bounding box coordinates. |
| p_crater_mask | Optional output crater mask. |
| p_inner_crater_mask | Optional output inner crater mask. |
Example
Result
| Array hmap::crater_field | ( | glm::ivec2 | shape, |
| const std::vector< glm::vec2 > & | centers, | ||
| const std::vector< float > & | radii, | ||
| float | angle = 30.f, | ||
| float | inner_depth = 0.5f, | ||
| float | inner_exp = 3.f, | ||
| float | lip_height = 0.1f, | ||
| float | lip_extent = 0.25f, | ||
| float | lip_exp = 2.f, | ||
| float | asym_ratio = 0.8f, | ||
| float | central_peak_height = 0.05f, | ||
| 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, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| Array * | p_crater_mask = nullptr, | ||
| Array * | p_inner_crater_mask = nullptr, | ||
| bool | scale_elevation_with_radius = true ) |
Generate a field of procedural impact craters from explicit centers and radii.
Uses a KD-tree over crater centers to evaluate only nearby craters per pixel, and scales cavity depth, lip height, and central peak height proportionally to each crater's radius.
| shape | Output array shape. |
| centers | Crater center positions in world coordinates. |
| radii | Crater radii corresponding to centers. |
| angle | Main asymmetry orientation angle in degrees. |
| inner_depth | Depth-to-radius ratio of the crater cavity. |
| inner_exp | Exponent controlling the inner profile shape. |
| lip_height | Rim height-to-radius ratio. |
| lip_extent | Extent of the outer rim. |
| lip_exp | Exponent controlling rim falloff. |
| asym_ratio | Asymmetry factor applied along the main direction. |
| central_peak_height | Central peak height-to-radius ratio. |
| central_peak_extent | Radius of the central peak region. |
| n_terraces | Number of inner terraces. |
| terrace_extent | Terrace spacing factor. |
| terrace_exp | Terrace profile exponent. |
| terrace_persistence | Terrace amplitude decay factor. |
| p_noise_r | Optional radial noise distortion. |
| bbox | Bounding box coordinates. |
| p_crater_mask | Optional output crater mask. |
| p_inner_crater_mask | Optional output inner crater mask. |
| Array hmap::crater_field | ( | glm::ivec2 | shape, |
| std::uint32_t | seed, | ||
| int | n_craters, | ||
| float | r_min = 0.02f, | ||
| float | r_max = 0.2f, | ||
| float | angle = 30.f, | ||
| float | inner_depth = 0.5f, | ||
| float | inner_exp = 3.f, | ||
| float | lip_height = 0.1f, | ||
| float | lip_extent = 0.25f, | ||
| float | lip_exp = 2.f, | ||
| float | asym_ratio = 0.8f, | ||
| float | central_peak_height = 0.05f, | ||
| 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, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| Array * | p_crater_mask = nullptr, | ||
| Array * | p_inner_crater_mask = nullptr, | ||
| bool | scale_elevation_with_radius = true ) |
Generate a field of randomly distributed procedural impact craters.
Randomly samples crater centers within the unit square [0, 1] x [0, 1] and radii in [r_min, r_max] using seed, then delegates to the explicit-input crater_field overload.
| shape | Output array shape. |
| seed | Random number generator seed. |
| n_craters | Number of craters to generate. |
| r_min | Minimum crater radius. |
| r_max | Maximum crater radius. |
| angle | Main asymmetry orientation angle in degrees. |
| inner_depth | Depth-to-radius ratio of the crater cavity. |
| inner_exp | Exponent controlling the inner profile shape. |
| lip_height | Rim height-to-radius ratio. |
| lip_extent | Extent of the outer rim. |
| lip_exp | Exponent controlling rim falloff. |
| asym_ratio | Asymmetry factor applied along the main direction. |
| central_peak_height | Central peak height-to-radius ratio. |
| central_peak_extent | Radius of the central peak region. |
| n_terraces | Number of inner terraces. |
| terrace_extent | Terrace spacing factor. |
| terrace_exp | Terrace profile exponent. |
| terrace_persistence | Terrace amplitude decay factor. |
| p_noise_r | Optional radial noise distortion. |
| bbox | Bounding box coordinates. |
| p_crater_mask | Optional output crater mask. |
| p_inner_crater_mask | Optional output inner crater mask. |
| Array hmap::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 BBox2D & | bbox = BBox2D::unit() ) |
Generates a 2D island mask by perturbing a radial boundary with noise.
Creates a binary mask of a single connected island using radial distance from a center point and adding an FBM-based angular displacement.
| shape | Output array size (width, height). |
| radius | Base island radius. |
| seed | Noise seed. |
| displacement | Amplitude of boundary perturbation. |
| noise_type | Type of underlying noise function. |
| kw | Angular frequency for sampling the noise. |
| octaves | Number of FBM octaves. |
| weight | Base amplitude of the FBM. |
| persistence | Amplitude falloff per octave. |
| lacunarity | Frequency multiplier per octave. |
| center | Center of the island in normalized coordinates. |
| bbox | Bounding box for coordinate remapping. |
Example
Result
| Array hmap::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, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Generates a land mask of an island chain scattered along a path.
Spawns island_count islands along the input path. Each island is an fbm-perturbed radial blob (same construction as island_land_mask). Island positions follow the path arc length, optionally jittered along and across the path by scatter. Island sizes follow a signed falloff: size_falloff = 0 gives uniform sizes, +1 shrinks the islands toward the path end (hotspot-chain look, largest island at the head), -1 shrinks them toward the start; size_jitter adds per-island random variation.
| shape | Output array shape. |
| path | Input path (at least two points), in normalized domain coordinates. |
| seed | Random seed number. |
| island_count | Number of islands spawned along the path. |
| island_radius | Base island radius in normalized domain units. |
| size_falloff | Signed size falloff along the path, in [-1, 1]. |
| size_jitter | Per-island random radius variation ratio. |
| scatter | Random island displacement along and across the path. |
| displacement | Amplitude of the fbm boundary perturbation. |
| noise_type | Noise type used for the boundary perturbation. |
| kw | Noise wavenumber. |
| octaves | Number of fbm octaves. |
| weight | Octave weighting. |
| persistence | Octave persistence. |
| lacunarity | Defines the wavenumber ratio between octaves. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::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}, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| Array * | p_rift_mask = nullptr, | ||
| Array * | p_bottom_mask = nullptr ) |
Generate a rift-shaped primitive.
Creates a longitudinal depression centered around a rotated axis. The rift shape is defined by an outer radial profile, an optional bottom profile, and configurable inner/outer slopes. Noise fields can be used to locally perturb the radius and axial offset of the structure.
| shape | Output array shape. |
| angle | Rift orientation angle in degrees. |
| radius | Rift half-width in normalized domain units. |
| axial_slope | Longitudinal slope applied along the rift axis. |
| depth | Rift depth amplitude. |
| scale_with_depth | If true, scale radial features proportionally to the depth value. |
| profile | Radial profile used for the outer rift shape. |
| profile_param | Additional parameter for the outer profile. |
| bottom_extent | Relative extent of the flat or inner bottom region inside the rift. |
| bottom_depth | Additional depth contribution applied to the bottom region. |
| bottom_profile | Radial profile used for the bottom region. |
| bottom_profile_param | Additional parameter for the bottom profile. |
| outer_slope | Slope factor controlling the outer falloff. |
| p_noise_r | Optional noise array used to locally modulate the rift radius. |
| p_noise_offset | Optional noise array used to locally offset the rift axis position. |
| center | Rift center in normalized coordinates. |
| bbox | Domain bounding box. |
Example
Result
| Array hmap::valley_head | ( | glm::ivec2 | shape, |
| float | angle = 0.f, | ||
| float | min_depth = 0.f, | ||
| float | max_depth = 0.2f, | ||
| float | min_width = 0.02f, | ||
| float | max_width = 0.15f, | ||
| float | depth_length = 0.5f, | ||
| float | width_length = 0.5f, | ||
| float | development_power = 2.f, | ||
| float | profile_power = 1.3f, | ||
| const Array * | p_noise_offset = nullptr, | ||
| const Array * | p_noise_r = nullptr, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| Array * | p_mask = nullptr ) |
Generate a procedural natural valley head / valley incision deformation heightmap.
Creates a valley head incision that smoothly emerges at the origin and progressively deepens and widens downstream following exponential saturation laws and smooth lateral falloff.
| shape | Output array shape. |
| angle | Valley orientation angle in degrees. |
| min_depth | Valley depth at the head. |
| max_depth | Maximum incision depth at maturity. |
| min_width | Valley width at the head. |
| max_width | Mature valley width. |
| depth_length | Distance scale over which depth develops. |
| width_length | Distance scale over which width develops. |
| development_power | Exponent controlling how quickly the incision emerges. |
| profile_power | Cross-section exponent (1 = sharp V, > 1 = rounded U-shape). |
| p_noise_offset | Optional cross-section centerline offset noise. |
| p_noise_r | Optional width / radial noise. |
| center | Valley head position. |
| bbox | Bounding box coordinates. |
| p_mask | Optional output mask for incision intensity. |
Example
Result
| Array hmap::white | ( | glm::ivec2 | shape, |
| float | a, | ||
| float | b, | ||
| std::uint32_t | seed ) |
Return an array filled with white noise.
| shape | Array shape. |
| a | Lower bound of random distribution. |
| b | Upper bound of random distribution. |
| seed | Random number seed. |
Example
Result
white_sparse Return an array filled 1 with a probability based on a density map.
| density_map | Density map. |
| seed | Random number seed. |
Example
Result
| Array hmap::white_sparse | ( | glm::ivec2 | shape, |
| float | a, | ||
| float | b, | ||
| float | density, | ||
| std::uint32_t | seed ) |
Return an array sparsely filled with white noise.
| shape | Array shape. |
| a | Lower bound of random distribution. |
| b | Upper bound of random distribution. |
| density | Array filling density, in [0, 1]. If set to 1, the function is equivalent to white. |
| seed | Random number seed. |
Example
Result
white | Array hmap::white_sparse_binary | ( | glm::ivec2 | shape, |
| float | density, | ||
| std::uint32_t | seed ) |
| float hmap::fast_hash32_to_unit_float | ( | unsigned int | seed, |
| size_t | k ) |
Generates a fast deterministic uniform float in [0,1) using a 32-bit hash.
| seed | Base seed value. |
| k | Sample index. |
| float hmap::hash01 | ( | uint32_t | a, |
| uint32_t | b ) |
Computes a pseudo-random float in [0, 1) by hashing two 32-bit integers.
| a | First 32-bit value. |
| b | Second 32-bit value. |
| uint32_t hmap::hash32 | ( | uint32_t | x | ) |
Integer hash function (Murmur3 / finalize style 32-bit mixer).
| x | Input 32-bit value. |
| uint64_t hmap::splitmix64 | ( | uint64_t | x | ) |
Computes a deterministic 64-bit hash using the SplitMix64 algorithm.
This function is used to generate reproducible pseudo-random values from integer inputs without maintaining any internal state. It is suitable for generating deterministic per-sample random seeds.
| x | Input 64-bit value. |
| float hmap::splitmix64_to_unit_float | ( | unsigned int | seed, |
| size_t | k ) |
Generates a deterministic uniform float in [0,1) from a seed and sample index.
The function combines the base seed and sample index, hashes the result using SplitMix64, and converts the generated bits into a floating-point value in the range [0,1). The output is deterministic and independent for each sample index.
| seed | Base seed value. |
| k | Sample index. |
| float hmap::uniform01 | ( | uint64_t | h | ) |
Converts a 64-bit hash value into a deterministic uniform float in [0, 1).
Extracts the upper 24 bits of the input hash and scales them to produce a single-precision floating-point value. The 24-bit resolution matches the mantissa precision of a float, providing a deterministic pseudo-random uniform distribution.
| h | 64-bit hash value. |
| float hmap::vnoise | ( | float | x, |
| float | y, | ||
| uint32_t | seed = 0 ) |
Computes 2D value noise in [-1, 1] using a hash-based lattice.
| x | X coordinate. |
| y | Y coordinate. |
| seed | Random seed. |
| void hmap::chop | ( | Array & | array, |
| float | vmin ) |
Set to zero any value lower than vmin.
This function processes the input array and sets any value that is less than the specified lower bound vmin to zero. This operation effectively "chops off" values that fall below the threshold, which can be useful for filtering out unwanted low values in data processing tasks.
| array | Input array to be processed. Values lower than vmin will be set to zero. |
| vmin | Lower bound threshold. Values below this threshold will be set to zero. |
Example
Result
| void hmap::chop_max_smooth | ( | Array & | array, |
| float | vmax ) |
Set to zero any value lower than vmax and apply a linear decrease slope between vmax / 2 and vmax.
This function processes the input array and sets any value below the upper bound vmax to zero. Additionally, it applies a linear decrease slope to values that fall between vmax / 2 and vmax. This creates a smooth transition where values gradually approach zero as they get closer to vmax, providing a more nuanced adjustment compared to a sharp cutoff.
| array | Input array to be processed. Values below vmax will be adjusted, with a linear decrease applied between vmax / 2 and vmax. |
| vmax | Upper bound threshold. Values below this threshold will be zeroed, with linear decrease applied in the specified range. |
Example
Result
Clamp array elements to a target range.
This function restricts the values in the input array to be within a specified range. Values below vmin are set to vmin, and values above vmax are set to vmax. This operation ensures that all elements of the array remain within the defined bounds.
| array | Input array to be clamped. |
| vmin | Lower bound of the clamping range (default is 0). |
| vmax | Upper bound of the clamping range (default is 1). |
Example
Result
Clamps the values of an array according to the specified mode.
This function modifies the input array in place based on one of three clamping modes:
| array | Reference to the array whose values will be clamped. |
| vmax | The maximum absolute value used for clamping. |
| mode | The clamping mode to apply (see ::ClampMode). |
| void hmap::clamp_min | ( | Array & | array, |
| float | vmin ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Clamp array values lower than a given bound with a smooth transition.
This function smoothly clamps values in the input array that are below the specified lower bound vmin. The smoothing parameter k controls the degree of smoothness applied during the clamping process.
| array | Input array to be clamped. |
| vmin | Lower bound for clamping. |
| k | Smoothing parameter in the range [0, 1] (default is 0.2f). |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| float hmap::clamp_min_smooth | ( | float | x, |
| float | vmin, | ||
| float | k = 0.2f ) |
Clamp a single value lower than a given bound with a smooth transition.
This function smoothly clamps a single value that is below the specified lower bound vmin. The smoothing parameter k controls the degree of smoothness applied during the clamping process.
| x | Input value to be clamped. |
| vmin | Lower bound for clamping. |
| k | Smoothing parameter in the range [0, 1] (default is 0.2f). |
| void hmap::clamp_max | ( | Array & | array, |
| float | vmax ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Clamp array values larger than a given bound with a smooth transition.
This function smoothly clamps values in the input array that are above the specified upper bound vmax. The smoothing parameter k controls the degree of smoothness applied during the clamping process.
| array | Input array to be clamped. |
| vmax | Upper bound for clamping. |
| k | Smoothing parameter in the range [0, 1] (default is 0.2f). |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| void hmap::clamp_oblique_plane | ( | Array & | array, |
| float | vmax, | ||
| float | angle, | ||
| float | slope, | ||
| bool | use_max_operator = true, | ||
| float | k = 0.f, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const BBox2D & | bbox = BBox2D::unit() ) |
Clamps an array against an oblique plane.
Generates a sloped plane and clamps the input array either with a min or max operator, optionally using a smooth transition controlled by k.
| array | Array to be modified. |
| vmax | Offset applied to the generated plane. |
| angle | Plane angle in radians. |
| slope_value | Slope intensity of the plane. |
| use_max_operator | If true, apply a max-clamp; otherwise apply a min-clamp. |
| k | Smoothness factor (0 for hard clamp). |
| center | Center of the plane. |
| bbox | Bounding box used to generate the plane. |
Example
Result
Clamp array values within a given interval with a smooth transition.
This function smoothly clamps values in the input array to be within a specified range. Values below vmin are smoothly transitioned to vmin, and values above vmax are smoothly transitioned to vmax. The smoothing parameter k controls the degree of smoothness applied during the clamping process.
| array | Input array to be clamped. |
| vmin | Lower bound of the clamping range. |
| vmax | Upper bound of the clamping range. |
| k | Smoothing parameter in the range [0, 1] (default is 0.2f). |
Return the element-wise maximum of two arrays.
This function computes the element-wise maximum between two input arrays. Each element in the resulting array is the maximum of the corresponding elements from array1 and array2.
| array1 | First input array. |
| array2 | Second input array. |
Return the element-wise maximum of an array and a scalar value.
This overloaded function computes the element-wise maximum between an input array and a scalar value. Each element in the resulting array is the maximum of the corresponding element from the input array and the scalar value.
| array1 | Input array. |
| value | Scalar value to compare with each element of the array. |
Return the polynomial cubic smooth element-wise maximum of two arrays.
This function computes the element-wise maximum of two input arrays with a smooth transition to avoid discontinuities that are present in the standard maximum function. The smoothness is controlled by the parameter k, which determines how smoothly the transition between the two arrays occurs.
The smooth transition is achieved using a polynomial cubic function, which provides a smooth blend between the two arrays. This approach helps in avoiding abrupt changes and can be useful in applications requiring smooth transitions.
| array1 | First array to be compared. |
| array2 | Second array to be compared. |
| k | Smoothing parameter in the range [0, 1]. Higher values result in smoother transitions between the arrays (default is 0.2). |
Example
Result
minimum_smooth, minimum, maximum | float hmap::maximum_smooth | ( | const float | a, |
| const float | b, | ||
| float | k = 0.2 ) |
Return the polynomial cubic smooth maximum of two scalar values.
This function computes the smooth maximum of two scalar values with a polynomial cubic smooth transition. The parameter k controls the degree of smoothness applied to the maximum calculation, ensuring a continuous and smooth blend between the two values.
The smooth transition helps in avoiding abrupt changes, making this function suitable for applications that require smooth variations.
| a | First scalar value. |
| b | Second scalar value. |
| k | Smoothing parameter in the range [0, 1]. Higher values result in smoother transitions between the values (default is 0.2). |
Example
Result
minimum_smooth, minimum, maximum This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Return the element-wise minimum of two arrays.
This function computes the element-wise minimum between two input arrays. Each element in the resulting array is the minimum of the corresponding elements from array1 and array2.
| array1 | First input array. |
| array2 | Second input array. |
Return the element-wise minimum of an array and a scalar value.
This overloaded function computes the element-wise minimum between an input array and a scalar value. Each element in the resulting array is the minimum of the corresponding element from the input array and the scalar value.
| array1 | Input array. |
| value | Scalar value to compare with each element of the array. |
Return the polynomial cubic smooth element-wise minimum of two arrays.
This function computes a smooth element-wise minimum between two input arrays using a polynomial cubic smoothing function. The smoothing parameter k controls the blending between the arrays, reducing the discontinuity found in a standard minimum operation. For details on the smoothing technique, refer to Inigo Quilez's articles.
| array1 | First input array. |
| array2 | Second input array. |
| k | Smoothing parameter in the range [0, 1] that determines the degree of blending between the two arrays (default is 0.2). |
maximum_smooth, minimum, maximum | float hmap::minimum_smooth | ( | const float | a, |
| const float | b, | ||
| float | k ) |
Return the polynomial cubic smooth minimum of two scalar values.
This overloaded function computes a smooth minimum between two scalar values using a polynomial cubic smoothing function. The smoothing parameter k controls the blending between the values, reducing discontinuity compared to a standard minimum operation.
| a | First scalar value. |
| b | Second scalar value. |
| k | Smoothing parameter in the range [0, 1] that determines the degree of blending between the two values (default is 0.2). |
| void hmap::remap | ( | Array & | array, |
| float | vmin, | ||
| float | vmax, | ||
| float | from_min, | ||
| float | from_max ) |
Remap array elements from a starting range to a target range.
This function maps the values in the input array from one specified range to another. By default, the function uses the minimum and maximum values of the input array as the starting range. The target range is specified by vmin and vmax.
| array | Input array to be remapped. |
| vmin | The lower bound of the target range to remap to. |
| vmax | The upper bound of the target range to remap to. |
| from_min | The lower bound of the starting range to remap from. |
| from_max | The upper bound of the starting range to remap from. |
Example
See unit tests: test_remap.cpp
| void hmap::remap | ( | Array & | array, |
| float | vmin = 0, | ||
| float | vmax = 1, | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Remap array elements from a starting range to a target range (default range).
This overloaded function remaps the values in the input array from the default starting range (the minimum and maximum values of the array) to a target range specified by vmin and vmax.
| array | Input array to be remapped. |
| vmin | The lower bound of the target range to remap to (default is 0). |
| vmax | The upper bound of the target range to remap to (default is 1). |
| comm | Optional communicator for collective reduction across tiles. |
See unit tests: test_remap.cpp This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Remap array elements from a starting range to a target range.
This function adjusts the values in the input array by scaling them and shifting them to fit within a new range. The scaling factor determines how much the values are stretched or compressed, and the reference value shifts the values to align with the target range.
| array | Input array to be rescaled. |
| scaling | Amplitude scaling factor to adjust the range of array elements. |
| vref | Reference 'zero' value used to shift the values (default is 0.f). |
| void hmap::normalize_and_clip | ( | Array & | array, |
| float | multiplier = 2.5f, | ||
| bool | smooth_transition = true, | ||
| bool | range_01 = false, | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Normalize an array around its mean and clip values.
Centers the array by subtracting its mean, scales by (multiplier * std), and clamps the result to [-1, 1] (or [0, 1] if range_01 is true). When smooth_transition is enabled, applies smoothstep3 to soften transitions around the clipping boundaries.
| array | Input array to be normalized and clipped. |
| multiplier | Standard deviation multiplier (default is 2.5f). |
| smooth_transition | If true, applies smoothstep3 to the clipped output. |
| range_01 | If true, maps output to [0, 1]; if false, [-1, 1]. |
| comm | Optional communicator for collective reduction across tiles. |
| ScatterField hmap::merge_scatter_fields | ( | const std::vector< ScatterField > & | fields, |
| bool | merge_by_class = true ) |
Merges multiple ScatterField instances into a single instance.
| fields | List of ScatterField instances. |
| merge_by_class | If true, preserves existing class IDs. If false, assigns a new unique class ID for each input field corresponding to its index in fields. |
| ScatterField hmap::merge_scatter_fields | ( | const std::vector< ScatterField > & | fields, |
| const std::vector< BBox2D > & | bboxs, | ||
| bool | merge_by_class = true ) |
Merges multiple ScatterField instances with associated bounding boxes into a single instance, resolving overlaps by keeping items from earlier fields in the input order.
| fields | List of ScatterField instances. |
| bboxs | Bounding box for each input field {xmin, xmax, ymin, ymax}. |
| merge_by_class | If true, preserves existing class IDs. If false, assigns a new unique class ID for each input field corresponding to its index in fields. |
| Array hmap::scatter_field_to_heightmap | ( | const ScatterField & | field, |
| glm::ivec2 | shape, | ||
| ScatterShape | shape_type = SCATTER_SHAPE_DISK, | ||
| float | height_radius_ratio = 1.0f, | ||
| std::optional< uint32_t > | class_id = std::nullopt, | ||
| Array * | p_rock_map = nullptr, | ||
| uint32_t | seed = 0, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Converts a ScatterField into a heightmap by representing each scattered object as a local elevation increase on GPU.
| field | Input ScatterField. |
| shape | Dimensions of the output heightmap {nx, ny}. |
| shape_type | Object geometry shape. |
| height_radius_ratio | Ratio of object maximum height relative to its radius. |
| class_id | Optional class identifier to filter items. |
| p_rock_map | Optional output array for the rock map with normalized amplitude in [0, 1]. |
| seed | Random seed for procedural shape variation. |
| bbox | Domain bounding box {xmin, xmax, ymin, ymax}. |
| ScatterField hmap::seed_scatter_clusters | ( | size_t | class_count, |
| size_t | item_count, | ||
| const Array & | density, | ||
| const Array & | exclusion, | ||
| float | cluster_spread = 0.05f, | ||
| size_t | points_per_cluster = 8, | ||
| const ScatterSeedingOptions & | options = {} ) |
Generates a clustered scatter distribution using inverse transform sampling for cluster centers and local cluster regions.
| class_count | Number of distinct classes/categories. |
| item_count | Target total number of items. |
| density | Global density map array. |
| exclusion | Exclusion map array. |
| cluster_spread | Half-extent of the bounding box surrounding each cluster center. |
| points_per_cluster | Number of child points sampled per parent cluster. |
| options | Seeding options. |
| ScatterField hmap::seed_scatter_kmeans | ( | size_t | class_count, |
| size_t | item_count, | ||
| const Array & | density, | ||
| const Array & | exclusion, | ||
| float | cluster_randomness = 0.0f, | ||
| size_t | k_neighbors = 4, | ||
| const ScatterSeedingOptions & | options = {} ) |
Generates a multi-class scatter distribution using 2D inverse transform sampling for positions and PointSampler k-means clustering to tag classes.
| class_count | Number of distinct item classes. |
| item_count | Target total number of items. |
| density | Global density map array. |
| exclusion | Exclusion map array. |
| cluster_randomness | Randomness factor in [0, 1] added to cluster features. |
| k_neighbors | Number of nearest spatial neighbors used to extract compactness features. |
| options | Seeding options. |
| Array hmap::sdf_2d_polyline | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| bool | use_bvh = true ) |
Computes the signed distance field (SDF) of a 2D polyline.
This function calculates the distance of each grid cell in the specified 2D array to the closest segment of a polyline. The polyline is represented by a Path object, and optional noise fields can be added to perturb the array coordinates.
| path | The polyline path represented as a Path object containing the nodes. |
| shape | The dimensions (width, height) of the output array grid. |
| bbox | The bounding box of the array grid in the format (xmin, xmax, ymin, ymax). |
| p_noise_x | Pointer to an optional noise array for perturbing x-coordinates (can be nullptr). |
| p_noise_y | Pointer to an optional noise array for perturbing y-coordinates (can be nullptr). |
Example
Result
| Array hmap::sdf_2d_polyline_brute_force | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::sdf_2d_polyline_bvh | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::sdf_2d_polyline_bezier | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| bool | use_bvh = true ) |
See hmap::sdf_2d_polyline, with a Bezier approximation of the path.
| Array hmap::sdf_2d_polyline_bezier_brute_force | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::sdf_2d_polyline_bezier_bvh | ( | const Path & | path, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::sdf_2d_graph | ( | const Graph & | graph, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| bool | use_bvh = true ) |
Computes the 2D unsigned distance field to a graph network.
Calculates the Euclidean distance from each cell to the closest edge of the graph. Supports accelerated BVH queries and coordinate perturbation.
| graph | Input graph containing nodes and edges. |
| shape | Dimensions (width, height) of the output array grid. |
| bbox | Bounding box of the array grid in the format (xmin, xmax, ymin, ymax). |
| p_noise_x | Pointer to an optional noise array for perturbing x-coordinates. |
| p_noise_y | Pointer to an optional noise array for perturbing y-coordinates. |
| use_bvh | Whether to use BVH spatial acceleration (default: true). |
| Array hmap::sdf_2d_graph_brute_force | ( | const Graph & | graph, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::sdf_2d_graph_bvh | ( | const Graph & | graph, |
| glm::ivec2 | shape, | ||
| const UvRect & | uv_rect = UvRect::unit(), | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr ) |
| Array hmap::perturb_mask_contour | ( | const Array & | mask, |
| const Array & | noise, | ||
| float | max_displacement, | ||
| int | ir = 1 ) |
Perturb the contour of a binary mask using a displacement field, while trying to preserve a single connected component without holes.
This function takes a binary mask and a noise map of the same size, computes the boundary of the mask, estimates a local outward normal for each boundary pixel, and displaces that pixel by an amount proportional to the noise value. The displacement is clamped to remain inside the image domain.
| mask | Input binary mask as an Array (0 = background, >0 = foreground). Must be at least 3×3 in size. |
| noise | Noise field providing signed displacement factors, typically in [-1, 1]. Must have the same dimensions as mask. |
| max_displacement | Maximum displacement magnitude in pixels applied along the estimated boundary normal for each pixel. |
| ir | Neighborhood radius used for normal estimation and contour reconnection. |
Example
Result
Mask adjustement using a 'scanning' method.
See https://www.shadertoy.com/view/stjSRR
| array | Input array. |
| contrast | Contrast. |
| brightness | Brightness. |
Example
Result
Return angle selection for a given angle and a tolerance half-width on this value.
| array | Input array. |
| angle | Selected angle (degree). |
| sigma | Selected angle tolerance (degree). |
Example
Result
| Array hmap::select_blob_log | ( | const Array & | array, |
| int | ir, | ||
| bool | normalize = false, | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Return blob detection using the Laplacian of Gaussian (LoG) approach.
| array | Input array. |
| ir | Kernel radius. |
| normalize | If true, normalize and clip output to [0, 1] using standard deviation with a smooth transition. |
| comm | Communicator for collective normalization. |
Example
Result
| Array hmap::select_cavities | ( | const Array & | array, |
| int | ir, | ||
| bool | concave = true, | ||
| bool | normalize = false, | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Return holes or bumps detection based on the mean curvature of the heightmap.
| array | Input array. |
| ir | Kernel radius. |
| concave | Select 'holes' if set to true, and select 'bumps' if set to false. |
| normalize | If true, normalize and clip output to [0, 1] using standard deviation with a smooth transition. |
| comm | Communicator for collective normalization. |
Example
Result
Return an array with elements equal to 1 where input elements are equal to value.
| array | Input array. |
| value | Criteria value. |
Example
Result
Return an array weighted by the gap between the gradient angle and a given angle.
| array | Input array. |
| angle | Reference angle (degree). |
Return an array filled with 1 where the gradient is larger than a given value and 0 elsewhere.
| array | Input array. |
| talus_center | Reference talus. |
Return an array weighted (exponantial decay) by the gradient norm of the input array.
| array | Input array. |
| talus_center | Reference talus. |
| talus_sigma | Talus half-width. |
Return an array weighted (square inverse) by the gradient norm of the input array.
| array | Input array. |
| talus_center | Reference talus. |
| talus_sigma | Talus half-width. |
Return an array with elements equal to 1 where input elements are larger than value.
| array | Input array. |
| value | Criteria value. |
Example
Result
Return an array with elements equal to 1 where input elements are within the bounds provided.
| array | Input array. |
| value1 | Lower bound. |
| value2 | Upper bound. |
Example
Result
| Array hmap::select_inward_outward_slope | ( | const Array & | array, |
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const BBox2D & | bbox = BBox2D::unit() ) |
Return an array with positive values if the slope is pointing to the center (slope is inward), and negative values otherwise (slope is outward).
| array | Input array. |
| center | Reference center. |
| bbox | Domain bounding box. |
Example
Result
Return an array with elements equal to 1 where input elements are smaller than value.
| array | Input array. |
| value | Criteria value. |
Example
Result
Selects the midrange values of the input array within a specified range.
| array | The input array from which the midrange values are selected. |
| gain | The gain factor to scale the selected midrange values. |
| vmin | The minimum value for range. |
| vmax | The maximum value for range. |
Example
Result
Selects and scales the midrange values of the input array.
This function extracts the midrange portion of the input array and scales it by the specified gain.
| array | The input array from which the midrange values are selected. |
| gain | The gain factor to scale the selected midrange values. |
Example
Result
| void hmap::select_multiband3 | ( | const Array & | array, |
| Array & | band_low, | ||
| Array & | band_mid, | ||
| Array & | band_high, | ||
| float | ratio1, | ||
| float | ratio2, | ||
| float | overlap, | ||
| float | vmin, | ||
| float | vmax ) |
Splits the input array into three bands (low, mid, and high) based on given ratios and overlap.
This function processes the input array and divides it into three value bands: low, mid, and high. The bands are determined by the provided ratios and overlap. Optionally, a range (vmin, vmax) can be applied to the values in the array.
| array | The input array that contains the data to be split into bands. |
| band_low | The output array for the low-value band. |
| band_mid | The output array for the mid-value band. |
| band_high | The output array for the high-value band. |
| ratio1 | The ratio that defines the split between the low and mid bands. |
| ratio2 | The ratio that defines the split between the mid and high bands. |
| overlap | The amount of overlap between adjacent bands. |
| vmin | The minimum value for range filtering. Values below vmin will be clamped. (Optional, only in the first function) |
| vmax | The maximum value for range filtering. Values above vmax will be clamped. (Optional, only in the first function) |
Example
Result
| void hmap::select_multiband3 | ( | const Array & | array, |
| Array & | band_low, | ||
| Array & | band_mid, | ||
| Array & | band_high, | ||
| float | ratio1, | ||
| float | ratio2, | ||
| float | overlap ) |
Splits the input array into three bands (low, mid, and high) based on given ratios and overlap.
This function processes the input array and divides it into three value bands: low, mid, and high. The bands are determined by the provided ratios and overlap.
| array | The input array that contains the data to be split into bands. |
| band_low | The output array for the low-value band. |
| band_mid | The output array for the mid-value band. |
| band_high | The output array for the high-value band. |
| ratio1 | The ratio that defines the split between the low and mid bands. |
| ratio2 | The ratio that defines the split between the mid and high bands. |
| overlap | The amount of overlap between adjacent bands. |
Example
Result
Return an array filled with non-zero values where the input is in the interval [value - sigma, value + sigma]. Output array values have a cubic pulse distribution within this interval.
| array | Input array. |
| value | Central value. |
| sigma | Pulse width. |
Example
Result
Return a selection mask for a value range [vmin, vmax] with smooth transitions of specified width at both ends.
The output value is 1.0 inside [vmin, vmax], 0.0 outside [vmin - width, vmax
| array | Input array. |
| vmin | Lower range bound. |
| vmax | Upper range bound. |
| width | Transition width at the boundaries. |
Return an array filled with a criterion based on the occurence of a river bed.
| array | Input array. |
| talus_ref | Reference talus used to localy define the flow-partition. |
| clipping_ratio | Flow accumulation clipping ratio. |
Example
Result
| Array hmap::select_transitions | ( | const Array & | array1, |
| const Array & | array2, | ||
| const Array & | array_blend ) |
Return an array filled with 1 at the blending transition between two arrays, and 0 elsewhere.
| array1 | Input array 1. |
| array2 | Input array 2. |
| array_blend | Blending of array 1 and 2 to analyze. |
Example
Result
| Array hmap::select_valley | ( | const Array & | z, |
| int | ir, | ||
| bool | ridge_select = false, | ||
| bool | normalize = false, | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
| Array hmap::smooth_mask_preserve_frontier | ( | const Array & | mask, |
| float | feather_width, | ||
| const UvTile & | region = UvTile::dummy(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Smooths a binary mask with an inward falloff while preserving its 0-boundary.
Computes a smooth falloff inside the non-zero region of the mask towards the 0/1 frontier using distance transform and smoothstep. The 0-set of the output remains identical to the input mask (no dilation beyond the boundary).
| mask | Input binary mask ({0, 1}). |
| feather_width | Width of the feathering falloff in grid units. |
Compute the shaded relief map (hillshading) from a heightmap.
This function calculates the shaded relief map of the input array based on the sun's azimuth (direction) and zenith (elevation) angles. The shading effect simulates the appearance of topographic features based on light direction.
| z | Input array representing the heightmap. |
| azimuth | Sun azimuth (direction) in degrees. |
| zenith | Sun zenith (elevation) in degrees. |
| talus_ref | Reference talus used to normalize gradient computations. It can be useful when working with true angles. Default is 1.f. |
Example
Result
topographic_shading Compute the shadow intensity using a grid-based technique.
This function calculates the shadow intensity from the input array using a grid-based approach. The shadow talus parameter influences the calculation of shadow intensity.
| z | Input array representing the heightmap. |
| shadow_talus | Parameter affecting the shadow intensity computation. |
| Array hmap::shadow_heightmap | ( | const Array & | z, |
| float | azimuth = 180.f, | ||
| float | zenith = 45.f, | ||
| float | distance = 0.2f ) |
Compute crude shadows from a heightmap.
This function generates crude shadow effects from the input heightmap using the specified light azimuth, zenith, and distance. The method is based on the technique described in https://www.shadertoy.com/view/Xlsfzl.
| z | Input array representing the heightmap. |
| azimuth | Light azimuth (direction) in degrees. Default is 180.f. |
| zenith | Light zenith (elevation) in degrees. Default is 45.f. |
| distance | Light distance. Default is 0.2f. |
| Array hmap::topographic_shading | ( | const Array & | z, |
| float | azimuth, | ||
| float | zenith, | ||
| float | talus_ref = 1.f ) |
Compute the topographic shadow intensity in the range [-1, 1].
This function calculates the topographic shadow intensity of the input array based on the sun's azimuth and zenith. The shadow intensity is normalized to fall within the range [-1, 1].
| z | Input array representing the heightmap. |
| azimuth | Sun azimuth (direction) in degrees. |
| zenith | Sun zenith (elevation) in degrees. |
| talus_ref | Reference talus used to normalize gradient computations. It can be useful when working with true angles. Default is 1.f. |
Example
Result
hillshade | Path hmap::dijkstra | ( | const Path & | path, |
| const Array & | array, | ||
| const UvRect & | uv_rect, | ||
| float | elevation_ratio = 0.f, | ||
| float | distance_exponent = 0.5f, | ||
| float | upward_penalization = 0.1f, | ||
| Array * | p_mask_nogo = nullptr ) |
Divide the path by adding points based on the lowest elevation difference between each pair of edge endpoints.
This method uses the elevation map to subdivide the path by adding intermediate points where the elevation difference between edges is minimal. The elevation_ratio parameter balances the influence of absolute elevation versus elevation difference in the cost function used for path finding. The distance_exponent affects the weight function used in Dijkstra's algorithm. Areas defined by the p_mask_nogo mask are avoided.
Example
Result
| array | Elevation map used to determine elevation differences along the path. |
| bbox | Bounding box of the domain, defining the area where elevation data is valid. |
| edge_divisions | Number of subdivisions per edge; set to 0 for automatic division based on array shape. |
| elevation_ratio | Ratio used to balance absolute elevation and elevation difference in the cost function. |
| distance_exponent | Exponent used in the Dijkstra weight function to adjust the influence of distance. |
| p_mask_nogo | Optional mask array defining areas to avoid; points in these areas will not be considered. |
| Path hmap::find_cut_path_dijkstra | ( | const Array & | z, |
| DomainBoundary | start, | ||
| DomainBoundary | end, | ||
| float | dijk_elevation_ratio = 0.9f, | ||
| float | dijk_distance_exponent = 2.f, | ||
| float | dijk_upward_penalization = 100.f, | ||
| std::uint32_t | seed = 0, | ||
| bool | favor_boundary_center = true, | ||
| bool | favor_lower_elevation = true, | ||
| bool | favor_sinks = true, | ||
| bool | favor_domain_center = false ) |
Find a Dijkstra-based cut path between two domain boundaries.
Selects the lowest point on the start and end boundaries of heightmap z, then computes a path between them using a weighted Dijkstra search. The path cost combines elevation, distance, and uphill penalization. The result is returned as normalized (x, y) coordinates and elevation samples.
| z | Heightmap array. |
| start | Boundary where the path begins. |
| end | Boundary where the path ends. |
| dijk_elevation_ratio | Weight of elevation in the cost. |
| dijk_distance_exponent | Exponent applied to distance cost. |
| dijk_upward_penalization | Extra penalty for uphill moves. |
| favor_domain_center | Favor passing through the center of the domain. |
Example
Result
| Path hmap::find_cut_path_dijkstra | ( | const Array & | z, |
| DomainBoundary | start, | ||
| DomainBoundary | end, | ||
| std::uint32_t | seed, | ||
| size_t | control_points_count = 2048, | ||
| bool | favor_boundary_center = true, | ||
| bool | favor_lower_elevation = true, | ||
| bool | favor_sinks = true, | ||
| bool | favor_domain_center = false, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Generate a cut path across a heightmap using a random triangular mesh and Dijkstra shortest path search (tileable).
| z | Heightmap array (or tile). |
| start | Start boundary. |
| end | End boundary. |
| seed | Random seed for mesh point generation. |
| control_points_count | Number of control points sampled for the mesh. |
| favor_boundary_center | Favor points near the center of the boundary. |
| favor_lower_elevation | Favor lower elevation points on the boundary. |
| favor_sinks | Favor local depressions. |
| favor_domain_center | Favor passing through the center of the domain. |
| region | Tile region metadata. |
| comm | Tiled communicator instance. |
| Path hmap::find_cut_path_midpoint | ( | const Array & | z, |
| DomainBoundary | start, | ||
| DomainBoundary | end, | ||
| std::uint32_t | seed, | ||
| float | offset_ratio = 0.2f, | ||
| int | steps = 16, | ||
| bool | favor_boundary_center = true, | ||
| bool | favor_lower_elevation = true, | ||
| bool | favor_sinks = true, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Generate a stochastic cut path using midpoint displacement.
Creates a path between the start and end boundaries of heightmap z by recursively subdividing and perturbing a segment. The result is a natural, irregular path defined by normalized (x, y) coordinates and elevations.
| z | Heightmap array. |
| start | Start boundary. |
| end | End boundary. |
| seed | Random seed. |
| midp_iterations | Number of subdivision steps. |
| midp_sigma | Displacement amplitude. |
| favor_boundary_center | Favor points near the center of the boundary. |
| favor_lower_elevation | Favor lower elevation points on the boundary. |
| favor_sinks | Favor local depressions. |
| region | Tile region metadata. |
| comm | Tiled communicator instance. |
Example
Result
| Path hmap::find_cut_path_multiscale | ( | const Array & | z, |
| DomainBoundary | start, | ||
| DomainBoundary | end, | ||
| int | n_levels = 3, | ||
| int | corridor_radius = 4, | ||
| float | corridor_decay = 1.f, | ||
| float | dijk_elevation_ratio = 0.9f, | ||
| float | dijk_distance_exponent = 2.f, | ||
| float | dijk_upward_penalization = 100.f, | ||
| std::uint32_t | seed = 0, | ||
| bool | favor_boundary_center = true, | ||
| bool | favor_lower_elevation = true, | ||
| bool | favor_sinks = true, | ||
| bool | use_astar = false, | ||
| bool | smooth_path = false ) |
Find a fast coarse-to-fine multiscale cut path between two domain boundaries.
Selects candidate boundary cells on the start and end boundaries, then computes a path using hierarchical multiscale search with corridor restriction.
| z | Heightmap array. |
| start | Boundary where the path begins. |
| end | Boundary where the path ends. |
| n_levels | Number of multiscale pyramid levels. |
| corridor_radius | Corridor radius in grid cells. |
| corridor_decay | Corridor radius decay factor per level. |
| dijk_elevation_ratio | Weight of elevation in the cost. |
| dijk_distance_exponent | Exponent applied to distance cost. |
| dijk_upward_penalization | Extra penalty for uphill moves. |
| seed | Seed for boundary cell selection. |
| favor_boundary_center | Bias boundary cell toward center. |
| favor_lower_elevation | Bias boundary cell toward lower elevation. |
| favor_sinks | Bias boundary cell toward local sinks. |
| use_astar | Use A* heuristic. |
| smooth_path | Smooth the resulting path. |
| void hmap::find_path_dijkstra | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| glm::ivec2 | ij_end, | ||
| std::vector< int > & | i_path, | ||
| std::vector< int > & | j_path, | ||
| float | elevation_ratio = 0.1f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| const Array * | p_mask_nogo = nullptr, | ||
| const Array * | p_node_weights = nullptr ) |
Finds the path with the lowest elevation and elevation difference between two points in a 2D array using Dijkstra's algorithm.
This function calculates the shortest path considering both elevation and elevation differences. It uses a cost function that balances between absolute elevation and elevation change. The path is determined by minimizing the combined cost function.
| ij_start | Starting coordinates (i, j) for the pathfinding. |
| ij_end | Ending coordinates (i, j) for the pathfinding. |
| i_path[out] | Vector to store the resulting shortest path indices in the i direction. |
| j_path[out] | Vector to store the resulting shortest path indices in the j direction. |
| elevation_ratio | Balance factor between absolute elevation and elevation difference in the cost function. Should be in the range [0, 1[. |
| distance_exponent | Exponent used in the distance calculation between points. A higher exponent increases the cost of elevation gaps, encouraging the path to minimize elevation changes and reduce overall cumulative elevation gain. |
| upward_penalization | Penalize upstream slopes. |
| p_mask_nogo | Optional pointer to an array mask that defines areas to avoid during pathfinding. |
Example
Result
| void hmap::find_path_dijkstra | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| std::vector< glm::ivec2 > | ij_end_list, | ||
| std::vector< std::vector< int > > & | i_path_list, | ||
| std::vector< std::vector< int > > & | j_path_list, | ||
| float | elevation_ratio = 0.1f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| const Array * | p_mask_nogo = nullptr, | ||
| const Array * | p_node_weights = nullptr ) |
| Path hmap::find_path_dijkstra | ( | const Array & | z, |
| glm::vec2 | start, | ||
| glm::vec2 | end, | ||
| std::uint32_t | seed, | ||
| size_t | control_points_count = 2048, | ||
| bool | favor_domain_center = false, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Generate a path between two points across a heightmap using a random triangular mesh and Dijkstra shortest path search (tileable).
| z | Heightmap array (or tile). |
| start | Start coordinates (x, y) in [0, 1]. |
| end | End coordinates (x, y) in [0, 1]. |
| seed | Random seed for mesh point generation. |
| control_points_count | Number of control points sampled for the mesh. |
| favor_domain_center | Favor passing through the center of the domain. |
| region | Tile region metadata. |
| comm | Tiled communicator instance. |
| std::vector< glm::ivec2 > hmap::find_path_dijkstra | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| glm::ivec2 | ij_end, | ||
| float | elevation_ratio = 0.1f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| const Array * | p_mask_nogo = nullptr, | ||
| const Array * | p_node_weights = nullptr ) |
Overload of find_path_dijkstra returning a vector of grid indices.
| z | Heightmap array. |
| ij_start | Start grid index (i, j). |
| ij_end | End grid index (i, j). |
| elevation_ratio | Weight of absolute elevation in cost. |
| distance_exponent | Exponent applied to distance cost. |
| upward_penalization | Penalty factor for uphill moves. |
| p_mask_nogo | Optional obstacle mask. |
| p_node_weights | Optional node/cell cost multiplier weights. |
| Path hmap::find_path_dijkstra | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| glm::ivec2 | ij_end, | ||
| const UvRect & | uv_rect, | ||
| float | elevation_ratio = 0.1f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| const Array * | p_mask_nogo = nullptr, | ||
| const Array * | p_node_weights = nullptr ) |
Overload of find_path_dijkstra returning a Path mapped to a bounding box with point values holding sampled terrain elevations.
| z | Heightmap array. |
| ij_start | Start grid index (i, j). |
| ij_end | End grid index (i, j). |
| bbox | Bounding box for coordinate remapping. |
| elevation_ratio | Weight of absolute elevation in cost. |
| distance_exponent | Exponent applied to distance cost. |
| upward_penalization | Penalty factor for uphill moves. |
| p_mask_nogo | Optional obstacle mask. |
| p_node_weights | Optional node/cell cost multiplier weights. |
| std::vector< glm::ivec2 > hmap::find_path_midpoint | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| glm::ivec2 | ij_end, | ||
| float | offset_ratio = 0.2f, | ||
| int | max_it = 0, | ||
| int | steps = 16 ) |
Compute a path between two points using iterative midpoint refinement.
The algorithm subdivides segments and shifts midpoints along the perpendicular direction to locally minimize the scalar field z. This is a fast heuristic alternative to graph-based methods (not guaranteed optimal).
| z | 2D scalar field (weights). |
| ij_start | Start index. |
| ij_end | End index. |
| offset_ratio | Relative transverse displacement (per segment length). |
| max_it | Max iterations (0 = automatic based on distance). |
| steps | Number of samples for transverse search. |
Example
Result
| void hmap::find_path_midpoint | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| glm::ivec2 | ij_end, | ||
| std::vector< int > & | i_path, | ||
| std::vector< int > & | j_path, | ||
| float | offset_ratio = 0.2f, | ||
| int | max_it = 0, | ||
| int | steps = 16 ) |
Overload of find_path_midpoint returning path indices in i and j vectors.
| z | 2D scalar field (weights). |
| ij_start | Start index. |
| ij_end | End index. |
| i_path[out] | Vector storing path i indices. |
| j_path[out] | Vector storing path j indices. |
| offset_ratio | Relative transverse displacement (per segment length). |
| max_it | Max iterations (0 = automatic based on distance). |
| steps | Number of samples for transverse search. |
| Path hmap::find_path_midpoint | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| glm::ivec2 | ij_end, | ||
| const UvRect & | uv_rect, | ||
| float | offset_ratio = 0.2f, | ||
| int | max_it = 0, | ||
| int | steps = 16 ) |
Overload of find_path_midpoint returning a Path mapped to a bounding box with point values holding sampled terrain elevations.
| z | 2D scalar field (weights). |
| ij_start | Start index. |
| ij_end | End index. |
| bbox | Bounding box for coordinate remapping. |
| offset_ratio | Relative transverse displacement (per segment length). |
| max_it | Max iterations (0 = automatic based on distance). |
| steps | Number of samples for transverse search. |
| void hmap::find_path_multiscale | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| glm::ivec2 | ij_end, | ||
| std::vector< int > & | i_path, | ||
| std::vector< int > & | j_path, | ||
| int | n_levels = 3, | ||
| int | corridor_radius = 4, | ||
| float | corridor_decay = 1.f, | ||
| float | elevation_ratio = 0.1f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| const Array * | p_mask_nogo = nullptr, | ||
| bool | use_astar = false, | ||
| bool | smooth_path = false ) |
Finds a shortest path on a 2D grid using a fast coarse-to-fine multiscale approach.
This function solves pathfinding across multiple grid resolutions to drastically reduce the number of explored cells on large grids while maintaining high path quality. A coarse path is found on downsampled cost maps, upsampled to the next finer resolution, and restricted to a narrow search corridor at each stage.
| z | Heightmap or cost array. |
| ij_start | Starting grid index (i, j). |
| ij_end | Target grid index (i, j). |
| i_path[out] | Vector storing resulting path i indices. |
| j_path[out] | Vector storing resulting path j indices. |
| n_levels | Number of multiscale pyramid levels (>= 1). |
| corridor_radius | Radius of search corridor in grid cells. |
| corridor_decay | Decay factor applied to corridor radius per level. |
| elevation_ratio | Weight factor for absolute elevation vs gradient. |
| distance_exponent | Exponent applied to elevation differences. |
| upward_penalization | Penalty factor for moving uphill. |
| p_mask_nogo | Optional pointer to mask of impassable regions. |
| use_astar | Use A* heuristic instead of Dijkstra. |
| smooth_path | Apply smoothing to the resulting path. |
Example
Result
| std::vector< glm::ivec2 > hmap::find_path_multiscale | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| glm::ivec2 | ij_end, | ||
| int | n_levels = 3, | ||
| int | corridor_radius = 4, | ||
| float | corridor_decay = 1.f, | ||
| float | elevation_ratio = 0.1f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| const Array * | p_mask_nogo = nullptr, | ||
| bool | use_astar = false, | ||
| bool | smooth_path = false ) |
Overload of find_path_multiscale returning a vector of grid indices.
| z | Heightmap or cost array. |
| ij_start | Starting grid index (i, j). |
| ij_end | Target grid index (i, j). |
| n_levels | Number of multiscale pyramid levels (>= 1). |
| corridor_radius | Radius of search corridor in grid cells. |
| corridor_decay | Decay factor applied to corridor radius per level. |
| elevation_ratio | Weight factor for absolute elevation vs gradient. |
| distance_exponent | Exponent applied to elevation differences. |
| upward_penalization | Penalty factor for moving uphill. |
| p_mask_nogo | Optional pointer to mask of impassable regions. |
| use_astar | Use A* heuristic instead of Dijkstra. |
| smooth_path | Apply smoothing to the resulting path. |
| Path hmap::find_path_multiscale | ( | const Array & | z, |
| glm::ivec2 | ij_start, | ||
| glm::ivec2 | ij_end, | ||
| const UvRect & | uv_rect, | ||
| int | n_levels = 3, | ||
| int | corridor_radius = 4, | ||
| float | corridor_decay = 1.f, | ||
| float | elevation_ratio = 0.1f, | ||
| float | distance_exponent = 2.f, | ||
| float | upward_penalization = 0.1f, | ||
| const Array * | p_mask_nogo = nullptr, | ||
| bool | use_astar = false, | ||
| bool | smooth_path = false ) |
Overload of find_path_multiscale returning a Path object mapped to a bounding box, with point values containing the elevation sampled from the heightmap.
| z | Heightmap or cost array. |
| ij_start | Starting grid index (i, j). |
| ij_end | Target grid index (i, j). |
| bbox | Bounding box domain for coordinate remapping. |
| n_levels | Number of multiscale pyramid levels (>= 1). |
| corridor_radius | Radius of search corridor in grid cells. |
| corridor_decay | Decay factor applied to corridor radius per level. |
| elevation_ratio | Weight factor for absolute elevation vs gradient. |
| distance_exponent | Exponent applied to elevation differences. |
| upward_penalization | Penalty factor for moving uphill. |
| p_mask_nogo | Optional pointer to mask of impassable regions. |
| use_astar | Use A* heuristic instead of Dijkstra. |
| smooth_path | Apply smoothing to the resulting path. |
|
inline |
Maps a discrete index i in [0, n) to a UV coordinate in [0, 1].
|
inline |
Maps a UV coordinate in [0, 1] to a continuous index in [0, n - 1].
|
inline |
Computes the exact UV rectangle of a tile (including halo) within a domain of global_shape.
Estimate the isotropic dominant length scale of a 2D heightmap.
Computes the e-folding lag of the autocorrelation function (averaged over i and j directions) via binary search. Returns max(ni, nj) for flat arrays.
| array | Input 2D heightmap, accessed via array(i, j). |
| max_lag_fraction | Search range as a fraction of the shorter dimension. |
Example
See unit tests: test_autocorr_length_scale.cpp
Estimate axis-aligned dominant length scales of a 2D heightmap.
Independently computes the e-folding autocorrelation lag along the i and j grid axes. Use when the field is anisotropic but aligned with the grid. Returns {ni, nj} for flat arrays.
| array | Input 2D heightmap, accessed via array(i, j). |
| max_lag_fraction | Search range as a fraction of each axis length. |
See unit tests: test_autocorr_length_scale.cpp
Apply linear regression for detrending of a 2D array.
This function performs detrending on the input array by applying linear regression separately to each row and column, removing trends from the data.
| array | Input 2D array to be detrended. |
Example
Result
| void hmap::normalize | ( | Array & | array, |
| NormalizationMethod | method ) |
In-place normalization of an array.
Applies a normalization transform to the input array depending on the selected method. The operation modifies the array directly.
Supported methods:
| array | Input/output array to normalize in-place. |
| method | Normalization strategy to apply. |
See unit tests: test_normalized.cpp
| Array hmap::normalized | ( | const Array & | array, |
| NormalizationMethod | method ) |
Returns a normalized copy of an array.
This is a convenience wrapper around normalize().
| array | Input array to normalize. |
| method | Normalization strategy to apply. |
See unit tests: test_normalized.cpp
| float hmap::variance | ( | const Array & | array, |
| float * | p_mean = nullptr ) |
Compute the population variance of a 2D array.
| array | Input 2D array, accessed via array(i, j). |
| p_mean | Pointer to a precomputed mean (avoids recomputation); if null, the mean is computed internally. |
See unit tests: test_variance.cpp
| Array hmap::loose_symmetry | ( | const Array & | array, |
| SymmetryType | symmetry_type = SymmetryType::SYMMETRY_LEFT_TO_RIGHT, | ||
| float | strength = 1.f, | ||
| int | factor = 4, | ||
| int | patch_size = 16, | ||
| int | analysis_stride = 2, | ||
| int | synthesis_stride = 8, | ||
| int | sparsity = 1, | ||
| bool | flatten_center = false, | ||
| float | flatten_radius = 0.05f ) |
Synthesize a heightmap with natural, approximate symmetry using exemplar-based super-resolution.
This function creates a heightmap with recognizable symmetrical macro features while retaining natural variation and avoiding strict geometric pixel-mirroring. It extracts the macro shape of the input (with optional pre-filtering), applies geometric symmetry to construct a guide field, and transfers the un-mirrored high-resolution features and textures of the input exemplar onto the symmetrical guide using sparse patch coding.
| array | Input heightmap providing the exemplar features. |
| symmetry_type | Type of symmetry to apply to the guide field. |
| strength | Symmetry strength in [0, 1] controlling interpolation between the original macro base and the symmetrical guide. Default is 1.0. |
| factor | Super-resolution amplification factor (>= 1). |
| patch_size | Side of square patches for sparse coding (>= 2). |
| analysis_stride | Patch stride on the exemplar grid. |
| synthesis_stride | Patch stride on the synthesis grid. |
| sparsity | Maximum number of atoms used to code each patch. |
| flatten_center | If true, flattens the elevation along the symmetry axis or center point towards minimum elevation. |
| flatten_radius | Radius (in normalized [0, 1] units) around the symmetry axis/center for the flattening transition. |
Example
Result
| Array hmap::non_parametric_sampling | ( | const Array & | array, |
| glm::ivec2 | patch_shape, | ||
| std::uint32_t | seed, | ||
| float | error_threshold = 0.1f ) |
Synthesize a new heightmap based on an input array using a non-parametric sampling method.
This method generates a new heightmap by sampling patches from the input array non-parametrically. It is a slow process and is based on the technique described in [Efros1999].
| array | Input array from which patches are sampled. |
| patch_shape | Shape of the patches used for sampling. |
| seed | Random seed number for patch selection. |
| error_threshold | Threshold for patch selection based on error. |
Example
Result
| Array hmap::quilting | ( | const std::vector< const Array * > & | p_arrays, |
| glm::ivec2 | patch_base_shape, | ||
| glm::ivec2 | tiling, | ||
| float | overlap, | ||
| std::uint32_t | seed, | ||
| std::vector< Array * > | secondary_arrays = {}, | ||
| bool | patch_flip = true, | ||
| bool | patch_rotate = true, | ||
| bool | patch_transpose = true, | ||
| float | filter_width_ratio = 0.25f ) |
Synthesize a new heightmap by stitching together small patches from input heightmaps.
This function creates a new heightmap by stitching patches from a set of input heightmaps. The stitching process allows for flipping, rotating, and transposing patches, and includes options for smoothing based on the overlap between patches. This technique is based on [Efros2001].
| p_arrays | Vector of pointers to input heightmaps. |
| patch_base_shape | Shape of the patches to be used. |
| tiling | Number of patches in each direction (x, y). |
| overlap | Overlap between patches, in the range ]0, 1[. |
| seed | Random seed number for patch placement. |
| secondary_arrays | Optional channels transformed using the guide's patches and seams. Each must match every guide's shape; otherwise an empty array is returned without modifying the channels. Pointers may repeat or alias a guide. |
| patch_flip | Allow flipping of patches (up-down, left-right). |
| patch_rotate | Allow 90-degree rotation of patches (for square patches). |
| patch_transpose | Allow transposition of patches (for square patches). |
| filter_width_ratio | Ratio of filter width to overlap length for smoothing. |
Example
Result
| Array hmap::quilting_blend | ( | const std::vector< const Array * > & | p_arrays, |
| glm::ivec2 | patch_base_shape, | ||
| float | overlap, | ||
| std::uint32_t | seed, | ||
| bool | patch_flip = true, | ||
| bool | patch_rotate = true, | ||
| bool | patch_transpose = true, | ||
| float | filter_width_ratio = 0.25f ) |
Synthesize a new heightmap by stitching together small patches from a list of input heightmaps.
This function creates a new heightmap by stitching patches from a set of input heightmaps, similar to quilting, but the patches are blended together. The blending options include flipping, rotating, and transposing patches, with smoothing based on the overlap between patches.
| p_arrays | Vector of pointers to input heightmaps. |
| patch_base_shape | Shape of the patches to be used. |
| overlap | Overlap between patches, in the range ]0, 1[. |
| seed | Random seed number for patch placement. |
| patch_flip | Allow flipping of patches (up-down, left-right). |
| patch_rotate | Allow 90-degree rotation of patches (for square patches). |
| patch_transpose | Allow transposition of patches (for square patches). |
| filter_width_ratio | Ratio of filter width to overlap length for smoothing. |
Example
Result
| Array hmap::quilting_expand | ( | const Array & | array, |
| float | expansion_ratio, | ||
| glm::ivec2 | patch_base_shape, | ||
| float | overlap, | ||
| std::uint32_t | seed, | ||
| std::vector< Array * > | secondary_arrays = {}, | ||
| bool | keep_input_shape = false, | ||
| bool | patch_flip = true, | ||
| bool | patch_rotate = true, | ||
| bool | patch_transpose = true, | ||
| float | filter_width_ratio = 0.25f ) |
Synthesize a new heightmap by expanding the input heightmap and stitching patches.
This function generates a larger heightmap by expanding the input heightmap and stitching patches based on the given parameters. The expansion ratio determines the new size of the heightmap, and the function includes options for flipping, rotating, and transposing patches. The output can be either the same shape as the input or expanded based on the given ratio.
| array | Input heightmap to be expanded. |
| expansion_ratio | Ratio by which to expand the heightmap (e.g., 2 for doubling the size). |
| patch_base_shape | Shape of the patches to be used. |
| overlap | Overlap between patches, in the range ]0, 1[. |
| seed | Random seed number for patch placement. |
| keep_input_shape | If true, the output heightmap retains the input shape. |
| patch_flip | Allow flipping of patches (up-down, left-right). |
| patch_rotate | Allow 90-degree rotation of patches (for square patches). |
| patch_transpose | Allow transposition of patches (for square patches). |
| filter_width_ratio | Ratio of filter width to overlap length for smoothing. |
Example
Result
| Array hmap::quilting_shuffle | ( | const Array & | array, |
| glm::ivec2 | patch_base_shape, | ||
| float | overlap, | ||
| std::uint32_t | seed, | ||
| std::vector< Array * > | secondary_arrays = {}, | ||
| bool | patch_flip = true, | ||
| bool | patch_rotate = true, | ||
| bool | patch_transpose = true, | ||
| float | filter_width_ratio = 0.25f ) |
Synthesize a new heightmap by reshuffling patches of the input heightmap.
This function generates a new heightmap by reshuffling patches of the input heightmap, effectively creating a new pattern while keeping the same shape as the input heightmap. The function includes options for patch flipping, rotating, and transposing.
| array | Input heightmap to be reshuffled. |
| patch_base_shape | Shape of the patches to be used. |
| overlap | Overlap between patches, in the range ]0, 1[. |
| seed | Random seed number for patch placement. |
| patch_flip | Allow flipping of patches (up-down, left-right). |
| patch_rotate | Allow 90-degree rotation of patches (for square patches). |
| patch_transpose | Allow transposition of patches (for square patches). |
| filter_width_ratio | Ratio of filter width to overlap length for smoothing. |
Example
Result
| Array hmap::terrain_super_resolution | ( | const Array & | array, |
| const Array & | exemplar, | ||
| int | factor, | ||
| int | patch_size = 16, | ||
| int | analysis_stride = 8, | ||
| int | synthesis_stride = 8, | ||
| int | sparsity = 1 ) |
Synthesize a high-resolution heightmap from a low-resolution input using an exemplar-based sparse patch representation (terrain amplification).
The exemplar is downsampled by factor and every patch_size x patch_size patch of the downsampled exemplar (mean removed, radial mask applied, unit norm) becomes an atom of a dictionary, paired with the corresponding patch_size * factor high-resolution patch. Each patch of the input is then sparse-coded against the low-resolution atoms with orthogonal matching pursuit, and the same coefficients are applied to the paired high-resolution atoms to synthesize the output, which is blended from the overlapping patches using the mask as weight. This technique is based on [Guerin2016].
With sparsity = 1 (the setting of the reference implementation), each input patch is replaced by the detail of its best-correlated exemplar patch. The strides control the density of the patch grids: smaller strides give more atoms and more overlap at a higher cost. The patch mask vanishes at the patch corners, so synthesis_stride should not exceed about 0.7 * patch_size to keep the output fully covered; uncovered pixels, if any, are filled with a bicubic upsampling of the input.
Memory usage scales with the number of atoms times (patch_size * factor)^2: large exemplars with small analysis_stride can require a lot of memory.
| array | Low-resolution input heightmap. |
| exemplar | High-resolution exemplar heightmap providing the detail. |
| factor | Amplification factor (>= 1); the output shape is array.shape * factor. |
| patch_size | Side of the square patches on the low-resolution grid (>= 2). |
| analysis_stride | Stride of the patch grid over the downsampled exemplar, in [1, patch_size]. |
| synthesis_stride | Stride of the patch grid over the input, in [1, patch_size]. |
| sparsity | Maximum number of atoms used to code each patch (>= 1). |
Example
Result
| std::vector< float > hmap::cubic_pulse | ( | const TerrainTriMesh & | mesh | ) |
Compute a cubic pulse value for each mesh vertex.
| TerrainTriMesh hmap::generate_terrain_tri_mesh_from_heightmap | ( | const Array & | z, |
| float | max_error, | ||
| int | max_triangles = 0, | ||
| int | max_points = 0 ) |
Generate a terrain mesh from a heightmap.
| TerrainTriMesh hmap::generate_terrain_tri_mesh_from_heightmap_random | ( | const Array & | z, |
| int | control_points_count, | ||
| std::uint32_t | seed, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator * | p_comm = nullptr ) |
Generate a random terrain mesh from a heightmap tile.
| TerrainAlignment hmap::compute_terrain_alignment | ( | const Array & | lower, |
| const CoordFrame & | frame_lower, | ||
| const Array & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| TerrainAlignMode | mode, | ||
| float | huber_delta = 0.1f, | ||
| int | max_iterations = 10 ) |
Compute alignment parameters to fit upper to lower over their common valid area.
| TerrainAlignment hmap::compute_terrain_alignment | ( | const VirtualArray & | lower, |
| const CoordFrame & | frame_lower, | ||
| const VirtualArray & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| TerrainAlignMode | mode, | ||
| float | huber_delta = 0.1f, | ||
| int | max_iterations = 10, | ||
| int | coarse_size = 128 ) |
Compute alignment parameters for VirtualArray inputs using a coarse Array representation.
| void hmap::apply_terrain_alignment | ( | Array & | upper, |
| const TerrainAlignment & | alignment ) |
Apply precomputed alignment parameters to an Array in-place.
| void hmap::apply_terrain_alignment | ( | VirtualArray & | upper, |
| const TerrainAlignment & | alignment, | ||
| const ComputeMode & | cm = ComputeMode{} ) |
Apply precomputed alignment parameters to a VirtualArray in-place.
| void hmap::align_terrains | ( | const Array & | lower, |
| const CoordFrame & | frame_lower, | ||
| Array & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| TerrainAlignMode | mode, | ||
| float | huber_delta = 0.1f, | ||
| int | max_iterations = 10 ) |
Align upper to lower in-place over their common valid area.
| void hmap::align_terrains | ( | const VirtualArray & | lower, |
| const CoordFrame & | frame_lower, | ||
| VirtualArray & | upper, | ||
| const CoordFrame & | frame_upper, | ||
| TerrainAlignMode | mode, | ||
| float | huber_delta = 0.1f, | ||
| int | max_iterations = 10, | ||
| int | coarse_size = 128, | ||
| const ComputeMode & | cm = ComputeMode{} ) |
Align upper VirtualArray to lower VirtualArray in-place.
| void hmap::flip_lr | ( | Texture & | texture | ) |
Flip the texture horizontally (left/right).
| texture | Input texture to be flipped. |
| void hmap::flip_ud | ( | Texture & | texture | ) |
Flip the texture vertically (up/down).
| texture | Input texture to be flipped. |
| void hmap::rot180 | ( | Texture & | texture | ) |
Rotate the texture by 180 degrees.
| texture | Input texture to be rotated. |
| void hmap::rot270 | ( | Texture & | texture | ) |
Rotate the texture by 270 degrees counterclockwise.
| texture | Input texture to be rotated. |
| void hmap::rot90 | ( | Texture & | texture | ) |
Rotate the texture by 90 degrees counterclockwise.
| texture | Input texture to be rotated. |
| void hmap::scale_uv | ( | Texture & | texture, |
| glm::vec2 | uv_scale ) |
Scale the texture in UV space with wrapping boundary.
| texture | Input texture to be scaled. |
| uv_scale | Scaling factors for U and V dimensions. |
Return the transposed texture.
| texture | Input texture to be transposed. |
| void hmap::flip_lr | ( | Array & | array | ) |
Flip the array horizontally (left/right).
This function flips the input array along the vertical axis, resulting in a left-to-right mirror image of the original array.
| array | Input array to be flipped horizontally. |
Example
Result
| void hmap::flip_ud | ( | Array & | array | ) |
Flip the array vertically (up/down).
This function flips the input array along the horizontal axis, resulting in an up-to-down mirror image of the original array.
| array | Input array to be flipped vertically. |
Example
Result
| void hmap::radial_displacement_to_xy | ( | const Array & | dr, |
| Array & | dx, | ||
| Array & | dy, | ||
| float | smoothing = 1.f, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Interpret the input array dr as a radial displacement and convert it to a pair of displacements dx and dy in cartesian coordinates.
| dr | Radial displacement. |
| dx | Displacent in x direction (output). |
| dy | Displacent in y direction (output). |
| smoothing | Smoothing parameter to avoid discontinuity at the origin. |
| center | Origin center. |
| bbox | Domain bounding box. |
Example
Result
| void hmap::rot180 | ( | Array & | array | ) |
Rotate the array by 180 degrees.
This function rotates the input array by 180 degrees in the counterclockwise direction. The dimensions of the array will be adjusted accordingly.
| array | Input array to be rotated by 180 degrees. |
| void hmap::rot270 | ( | Array & | array | ) |
Rotate the array by 270 degrees.
This function rotates the input array by 270 degrees in the counterclockwise direction. The dimensions of the array will be adjusted accordingly.
| array | Input array to be rotated by 270 degrees. |
| void hmap::rot90 | ( | Array & | array | ) |
Rotate the array by 90 degrees.
This function rotates the input array by 90 degrees in the counterclockwise direction. The dimensions of the array will be adjusted accordingly.
| array | Input array to be rotated by 90 degrees. |
Example
Result
| void hmap::rotate | ( | Array & | array, |
| float | angle, | ||
| bool | zoom_in = true, | ||
| bool | zero_padding = false ) |
Rotate the array by a specified angle.
This function rotates the input array by a given angle in degrees. The rotation can be performed with optional zero-padding, which fills in the borders with zeros instead of using symmetric padding. This is particularly useful when the array contains zero values at its borders.
| array | Input array to be rotated. |
| angle | Rotation angle in degrees. |
| zoom_in | If true, zoom in after rotation (default is true). |
| zero_padding | If true, use zero-padding to fill the borders; otherwise, use symmetry (default is false). |
Example
Result
Rotates a scalar displacement field into directional X and Y components.
This function converts a scalar displacement map into two directional components (dx and dy) according to a given rotation angle. It is typically used to orient procedural displacements, such as those applied to terrain heightmaps or noise-based distortion fields.
| delta | Input scalar displacement field. |
| angle | Rotation angle in degrees (counterclockwise). |
| dx | Output array receiving the X-axis displacement component. |
| dy | Output array receiving the Y-axis displacement component. |
| void hmap::scale_uv | ( | Array & | array, |
| glm::vec2 | uv_scale ) |
Scale the array in UV space with wrapping boundary.
| array | Input array to be scaled. |
| uv_scale | Scaling factors for U and V dimensions. |
| Array hmap::symmetrize | ( | const Array & | array, |
| SymmetryType | symmetry_type = SymmetryType::SYMMETRY_LEFT_TO_RIGHT, | ||
| bool | flatten_center = false, | ||
| float | flatten_radius = 0.05f ) |
Enforces geometric symmetry on an array.
This function reflects or averages portions of the input array across the specified symmetry axis or plane according to symmetry_type.
| array | Input array to symmetrize. |
| symmetry_type | Type of symmetry operation to apply. |
| flatten_center | If true, flattens the elevation along the symmetry axis or center point towards minimum elevation. |
| flatten_radius | Radius (in normalized [0, 1] units) around the symmetry axis/center for the flattening transition. |
| Array hmap::translate | ( | const Array & | array, |
| float | dx, | ||
| float | dy, | ||
| bool | periodic = false, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Translates a 2D array by a specified amount along the x and y axes.
This function shifts the contents of the input array by dx and dy units along the x and y axes, respectively. It supports both periodic boundary conditions, where the array wraps around, and non-periodic conditions, where the shifted areas are filled with zeros.
| array | The input 2D array to be translated. This array remains unmodified. |
| dx | The translation distance along the x-axis. Positive values shift the array to the right. |
| dy | The translation distance along the y-axis. Positive values shift the array downward. |
| periodic | If set to true, the translation is periodic, meaning that elements that move out of one side of the array reappear on the opposite side. If false, the areas exposed by the translation are filled with zeros. The default is false. |
| p_noise_x | Optional pointer to a 2D array that contains x-direction noise to be added to the translation. If provided, the noise values are added to dx on a per-element basis. |
| p_noise_y | Optional pointer to a 2D array that contains y-direction noise to be added to the translation. If provided, the noise values are added to dy on a per-element basis. |
| bbox | Domain bounding box. |
Example
Result
Return the transposed array.
This function returns a new array that is the transpose of the input array. The transpose operation swaps the rows and columns of the array, effectively flipping the array over its diagonal.
| array | Input array to be transposed. |
| Array hmap::zoom | ( | const Array & | array, |
| float | zoom_factor, | ||
| bool | periodic = false, | ||
| glm::vec2 | center = {0.5f, 0.5f}, | ||
| const Array * | p_noise_x = nullptr, | ||
| const Array * | p_noise_y = nullptr, | ||
| const UvRect & | uv_rect = UvRect::unit() ) |
Applies a zoom effect to a 2D array with an adjustable center.
This function scales the input 2D array by a specified zoom factor, effectively resizing the array's contents. The zoom operation is centered around a specified point within the array, allowing for flexible zooming behavior. The function supports both periodic boundary conditions, where the array wraps around, and non-periodic conditions, where areas outside the original array bounds are filled with zeros.
| array | The input 2D array to be zoomed. This array remains unmodified. |
| zoom_factor | The factor by which to zoom the array. A value greater than 1 enlarges the contents, while a value between 0 and 1 reduces them. |
| periodic | If set to true, the zoom is periodic, meaning that elements moving out of the array bounds due to the zoom reappear on the opposite side. If false, areas outside the original array bounds are filled with zeros. The default is false. |
| center | The center of the zoom operation, specified as a glm::vec2 with coordinates in the range [0, 1], where {0.5f, 0.5f} represents the center of the array. The default center is {0.5f, 0.5f}. |
| p_noise_x | Optional pointer to a 2D array that contains x-direction noise to be added during the zoom operation. If provided, the noise values are applied to the x-coordinates of the zoomed array on a per-element basis. |
| p_noise_y | Optional pointer to a 2D array that contains y-direction noise to be added during the zoom operation. If provided, the noise values are applied to the y-coordinates of the zoomed array on a per-element basis. |
| bbox | Domain bounding box. |
Example
Result
Apply a warping effect to the array.
This function applies a warping effect to the input array by translating its elements according to the specified x and y translation arrays. The warp effect distorts the array based on the displacement values provided by p_dx and p_dy.
| array | Input array to be warped. |
| p_dx | Pointer to the array containing x-axis translation values. |
| p_dy | Pointer to the array containing y-axis translation values. |
Example
Result
| void hmap::warp_directional | ( | Array & | array, |
| float | angle, | ||
| float | amount = 0.02f, | ||
| int | ir = 4, | ||
| bool | reverse = false ) |
Apply a warping effect following the downward local gradient direction (deflate/inflate effect).
This function applies a warping effect to the input array based on the downward local gradient direction, creating a deflate or inflate effect. The warp amount, pre-filtering radius, and displacement direction can be customized.
| array | Input array to be warped. |
| angle | The angle to determine the gradient direction. |
| amount | Amount of displacement (default is 0.02f). |
| ir | Pre-filtering radius to smooth the input data (default is 4). |
| reverse | Reverse the displacement direction if set to true (default is false). |
Example
Result
| void hmap::warp_directional | ( | Array & | array, |
| float | angle, | ||
| const Array * | p_mask, | ||
| float | amount = 0.02f, | ||
| int | ir = 4, | ||
| bool | reverse = false ) |
Apply a warping effect following the downward local gradient direction (deflate/inflate effect) with a mask.
This overloaded function applies a warping effect to the input array using a specified mask. The mask controls the regions where the warp effect is applied, with values expected in the range [0, 1]. The warp is based on the downward local gradient direction.
| array | Input array to be warped. |
| angle | The angle to determine the gradient direction. |
| p_mask | Pointer to the mask array that filters the effect, expected in [0, 1]. |
| amount | Amount of displacement (default is 0.02f). |
| ir | Pre-filtering radius to smooth the input data (default is 4). |
| reverse | Reverse the displacement direction if set to true (default is false). |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Apply a warping effect following the downward local gradient direction (deflate/inflate effect).
This function applies a warping effect to the input array based on the downward local gradient direction, simulating a deflate or inflate effect. The effect can be customized by adjusting the displacement amount, pre-filtering radius, and whether the displacement direction is reversed.
| array | Input array to be warped. |
| amount | Amount of displacement (default is 0.02f). |
| ir | Pre-filtering radius to smooth the input data (default is 4). |
| reverse | Reverse the displacement direction if set to true (default is false). |
Example
Result
| void hmap::warp_downslope | ( | Array & | array, |
| const Array * | p_mask, | ||
| float | amount = 0.02f, | ||
| int | ir = 4, | ||
| bool | reverse = false ) |
Apply a warping effect following the downward local gradient direction (deflate/inflate effect) with a mask.
This overloaded function applies a warping effect to the input array based on the downward local gradient direction using a specified mask. The mask controls where the warp effect is applied, with values expected in the range [0, 1]. This function allows for additional customization of the warp effect.
| array | Input array to be warped. |
| p_mask | Pointer to the mask array that filters the effect, expected in [0, 1]. |
| amount | Amount of displacement (default is 0.02f). |
| ir | Pre-filtering radius to smooth the input data (default is 4). |
| reverse | Reverse the displacement direction if set to true (default is false). |
Example
Result
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| std::vector< size_t > hmap::argsort | ( | const std::vector< float > & | v | ) |
Returns the indices that would sort the vector.
| v | Input vector. |
| float hmap::compute_median | ( | std::vector< float > | values | ) |
Computes the median value of a set of floats.
| values | Input values (copied and partially reordered). |
| std::vector< size_t > hmap::find_sign_changes | ( | const std::vector< float > & | data | ) |
Returns indices where a sign change occurs in the input vector.
A sign change is detected between i-1 and i when values have opposite signs.
| data | Input vector. |
| std::vector< float > hmap::generate_random_vector | ( | size_t | size, |
| float | min_value, | ||
| float | max_value, | ||
| uint32_t | seed ) |
Generate a vector of random floating-point values within a given range.
Uses a deterministic random number generator initialized with the provided seed. The same seed will always produce the same sequence of values.
| size | Number of elements in the vector. |
| min_value | Lower bound of the range (inclusive). |
| max_value | Upper bound of the range (inclusive). |
| seed | Seed used to initialize the random number generator. |
| std::vector< int > hmap::generate_random_vector | ( | size_t | size, |
| int | min_value, | ||
| int | max_value, | ||
| uint32_t | seed ) |
Generate a vector of random integers within a given range.
Uses a deterministic random number generator initialized with the provided seed. The same seed will always produce the same sequence of values.
| size | Number of elements in the vector. |
| min_value | Lower bound of the range (inclusive). |
| max_value | Upper bound of the range (inclusive). |
| seed | Seed used to initialize the random number generator. |
| std::vector< int > hmap::generate_unique_random_vector | ( | size_t | size, |
| int | min_value, | ||
| int | max_value, | ||
| uint32_t | seed ) |
Generate a vector of unique random integers within a given range.
Values are sampled without replacement using a deterministic shuffle based on the provided seed.
| size | Number of elements to generate. |
| min_value | Lower bound (inclusive). |
| max_value | Upper bound (inclusive). |
| seed | Seed for reproducible randomness. |
| std::invalid_argumentIfsizeexceedsavailableuniquevalues. |
| std::string hmap::make_histogram | ( | const std::vector< float > & | values, |
| int | bin_count, | ||
| int | hist_height ) |
Generates an ASCII histogram representation of values.
| values | Input data. |
| bin_count | Number of bins. |
| hist_height | Height of the histogram in characters. |
| std::vector< float > hmap::moving_average | ( | const std::vector< float > & | input, |
| int | radius ) |
Smooths a vector using a centered moving average.
Each value is replaced by the average of its neighbors within a given radius.
| input | Input vector. |
| radius | Number of elements on each side to include in the average. |
| void hmap::reindex_vector | ( | std::vector< T > & | v, |
| std::vector< size_t > & | idx ) |
Reorders a vector using a given index mapping.
| T | Type of the vector elements. |
| v | Vector to reorder. |
| idx | Index mapping (typically from argsort). |
| std::vector< float > hmap::remap | ( | const std::vector< float > & | data, |
| float | new_min = 0.f, | ||
| float | new_max = 1.f ) |
Remaps values of a vector to a given range [new_min, new_max].
| data | Input vector. |
| new_min | Target minimum value. |
| new_max | Target maximum value. |
| void hmap::shuffle_vector | ( | std::vector< T > & | values, |
| std::uint32_t | seed ) |
Shuffles a vector in-place using a deterministic seed.
| T | Type of the vector elements. |
| values | Vector to shuffle. |
| seed | Seed for the random generator. |
| std::vector< T > hmap::shuffled_vector | ( | const std::vector< T > & | values, |
| std::uint32_t | seed ) |
Returns a shuffled copy of a vector.
| T | Type of the vector elements. |
| values | Input vector. |
| seed | Seed for the random generator. |
| size_t hmap::upperbound_right | ( | const std::vector< float > & | v, |
| float | value ) |
Returns the index of the first element greater than a given value.
Equivalent to std::upper_bound but returns the index instead of an iterator.
| v | Sorted input vector. |
| value | Value to compare. |
| void hmap::vector_unique_values | ( | std::vector< float > & | v | ) |
Removes duplicate values from a vector.
| v | Input vector. |
| std::string hmap::to_string | ( | StorageMode | m | ) |
| std::unique_ptr< TileStorage > hmap::make_storage | ( | glm::ivec2 | shape, |
| glm::ivec2 | tile_shape, | ||
| StorageMode | storage_mode ) |
|
inline |
| void hmap::copy_data | ( | const VirtualArray & | src, |
| VirtualArray & | dst, | ||
| const ComputeMode & | cm ) |
| void hmap::sum_per_tile | ( | const VirtualArray & | va, |
| std::vector< float > & | tile_sums, | ||
| float * | p_total_inner_sum = nullptr, | ||
| const VirtualArray * | p_exclusion_mask = nullptr, | ||
| float | exclusion_threshold = 0.f, | ||
| const ComputeMode & | cm = {} ) |
| auto hmap::unpack_impl | ( | const std::vector< T * > & | v, |
| std::index_sequence< Is... > | ) |
| auto hmap::unpack | ( | const std::vector< T * > & | v | ) |
| VirtualTexture hmap::convert_texture_channels | ( | const VirtualTexture & | src, |
| int | dst_channels, | ||
| float | fill_value, | ||
| const ComputeMode & | cm ) |
| void hmap::for_each_tile | ( | VirtualTexture & | tex, |
| Func && | func, | ||
| const ComputeMode & | cm ) |
| void hmap::for_each_tile | ( | const VirtualTexture & | tex, |
| Func && | func, | ||
| const ComputeMode & | cm ) |
| void hmap::for_each_pixel | ( | VirtualTexture & | tex, |
| Func && | func, | ||
| const ComputeMode & | cm ) |
| Forest hmap::grow_forest_competition_nn | ( | const Forest & | forest, |
| const std::vector< Species > & | species = {}, | ||
| const InteractionMatrix & | competition_matrix = {}, | ||
| const Array & | max_radius_scale = {}, | ||
| float | max_radius_scale_strength = 1.0f, | ||
| bool | prune_unviable = true, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Adjusts tree radii based on nearest-neighbor distances and species competition constraints.
For each tree $i$ with nearest neighbor $j$ at Euclidean distance $d_i = |p_i - p_j|$:
max_radius_scale (if provided, default $s = 1.0$).prune_unviable is true and raw calculated radius $r_i < \text{radius_min}(s_i)$, the tree is removed.| forest | Input forest container. |
| species | Vector of Species definitions. |
| competition_matrix | Optional pairwise S x S competition factors (alpha). |
| max_radius_scale | Optional 2D array in [0, 1] scaling maximum radius locally (0 -> rmax = rmin, 1 -> rmax = rmax). |
| max_radius_scale_strength | Blend strength for max_radius_scale in [0, 1] (0 -> no scaling/full rmax, 1 -> full scale array modulation). |
| prune_unviable | Whether to remove trees unable to reach radius_min. |
| bbox | Bounding box {xmin, xmax, ymin, ymax} for sampling max_radius_scale. |
| Forest hmap::grow_forest_competition_voronoi | ( | const Forest & | forest, |
| const std::vector< Species > & | species = {}, | ||
| const InteractionMatrix & | competition_matrix = {}, | ||
| const Array & | max_radius_scale = {}, | ||
| float | max_radius_scale_strength = 1.0f, | ||
| bool | prune_unviable = true, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Adjusts tree radii based on Voronoi cell areas and species competition constraints.
Builds a Delaunay triangulation (TerrainTriMesh) on the tree positions in the XY plane to compute the local Voronoi/dual cell territory area $A_i$ of each tree:
max_radius_scale (if provided, default $s = 1.0$).prune_unviable is true and raw calculated radius $r_{\text{est}} < \text{radius_min}(s_i)$, the tree is removed.| forest | Input forest container. |
| species | Vector of Species definitions. |
| competition_matrix | Optional pairwise S x S competition factors (alpha). |
| max_radius_scale | Optional 2D array in [0, 1] scaling maximum radius locally (0 -> rmax = rmin, 1 -> rmax = rmax). |
| max_radius_scale_strength | Blend strength for max_radius_scale in [0, 1] (0 -> no scaling/full rmax, 1 -> full scale array modulation). |
| prune_unviable | Whether to remove trees unable to reach radius_min. |
| bbox | Bounding box {xmin, xmax, ymin, ymax} for sampling max_radius_scale. |
| Forest hmap::grow_forest_iterative | ( | const Forest & | forest, |
| const std::vector< Species > & | species = {}, | ||
| size_t | iterations = 10, | ||
| float | growth_rate = 0.1f, | ||
| const InteractionMatrix & | competition_matrix = {}, | ||
| const Array & | max_radius_scale = {}, | ||
| float | max_radius_scale_strength = 1.0f, | ||
| bool | prune_unviable = true, | ||
| const BBox2D & | bbox = BBox2D{}, | ||
| const UvTile & | region = UvTile::unit() ) |
Simulates iterative plant growth with neighborhood competition and mortality.
Progressively expands plant crowns over multiple time steps according to: r_i^{t+1} = min(r_max_eff, r_i^t + G_i * max(0, 1 - C_i)) where G_i is the growth increment and C_i is the neighborhood competition factor. Suppressed plants falling below species viability or suffocated by larger crowns are pruned.
| forest | Input forest container. |
| species | Vector of Species definitions. |
| iterations | Maximum number of growth iterations. |
| growth_rate | Base growth fraction per iteration in [0, 1]. |
| competition_matrix | Optional pairwise competition matrix. |
| max_radius_scale | Optional 2D heightmap array to modulate max radius locally. |
| max_radius_scale_strength | Strength factor for max_radius_scale in [0, 1]. |
| prune_unviable | Whether to remove suppressed/non-viable plants. |
| bbox | Spatial bounding box for sampling max_radius_scale. |
| region | UvTile descriptor for tiled domain positioning. |
| Forest hmap::grow_forest_soft_core | ( | const Forest & | forest, |
| const std::vector< Species > & | species = {}, | ||
| const InteractionMatrix & | repulsion_distances = {}, | ||
| const InteractionMatrix & | repulsion_strengths = {}, | ||
| size_t | target_count = 0, | ||
| const Array & | max_radius_scale = {}, | ||
| float | max_radius_scale_strength = 1.0f, | ||
| uint32_t | seed = 0, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Performs multi-species Strauss soft-core growth and thinning on an input forest.
Repels and thins neighboring trees probabilistically based on species pairwise interaction distances and strengths, and clamps resulting crown radii according to species traits and local spatial scale.
| forest | Input candidate forest. |
| species | Vector of Species definitions. |
| repulsion_distances | Interaction distance matrix between species. |
| repulsion_strengths | Repulsion strength matrix between species in [0, 1]. |
| target_count | Optional target number of trees (0 means keep all accepted). |
| max_radius_scale | Optional 2D array scaling maximum radius locally. |
| max_radius_scale_strength | Blend strength for max_radius_scale in [0, 1]. |
| seed | Random number generator seed. |
| bbox | Bounding box {xmin, xmax, ymin, ymax}. |
| Array hmap::build_tree_density | ( | const Array & | heightmap, |
| float | min_elev = 0.0f, | ||
| float | max_elev = 0.9f, | ||
| float | elev_transition_width = 0.1f, | ||
| float | min_talus = 0.003f, | ||
| float | max_talus = 0.005f, | ||
| float | angle = 30.0f, | ||
| float | angle_width = 90.0f, | ||
| float | weight_elev = 1.0f, | ||
| float | weight_talus = 1.0f, | ||
| float | weight_angle = 0.8f, | ||
| float | weight_twi = 0.5f, | ||
| const Array & | secondary_density = {}, | ||
| float | weight_secondary = 1.0f, | ||
| const Array & | exclusion_mask = {}, | ||
| float | exclusion_threshold = 0.f ) |
Computes an environmental suitability criteria map in [0, 1] representing tree probability density based on elevation, slope talus, aspect angle, topographic wetness index (TWI), an optional secondary density map, and an optional exclusion mask.
| heightmap | Input terrain heightmap. |
| min_elev | Minimum elevation threshold. |
| max_elev | Maximum elevation threshold. |
| elev_transition_width | Elevation transition smoothing width. |
| min_talus | Slope/talus threshold for full suitability (1.0). |
| max_talus | Slope/talus threshold for zero suitability (0.0). |
| angle | Preferred slope aspect angle in degrees. |
| angle_width | Slope aspect angle tolerance half-width in degrees. |
| weight_elev | Weight for elevation criterion in [0, 1]. |
| weight_talus | Weight for talus/slope criterion in [0, 1]. |
| weight_angle | Weight for aspect angle criterion in [0, 1]. |
| weight_twi | Weight for topographic wetness index criterion in [0, 1]. |
| secondary_density | Optional secondary density or noise modulation map. |
| weight_secondary | Weight for optional secondary density map in [0, 1]. |
| exclusion_mask | Optional exclusion mask (where > exclusion_threshold, density is set to 0). |
| exclusion_threshold | Threshold above which exclusion mask excludes trees (default 0.f). |
| Forest hmap::seed_forest_clusters | ( | size_t | species_count, |
| size_t | tree_count, | ||
| const Array & | density, | ||
| const Array & | exclusion, | ||
| float | cluster_spread = 0.05f, | ||
| size_t | points_per_cluster = 8, | ||
| const ForestSeedingOptions & | options = {}, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Generates a clustered forest distribution using inverse transform sampling for cluster centers and local cluster regions.
| species_count | Number of distinct tree species. |
| tree_count | Target total number of trees. |
| density | Global density map array. |
| exclusion | Exclusion map array. |
| cluster_spread | Half-extent of the bounding box surrounding each cluster center. |
| points_per_cluster | Number of child points sampled per parent cluster. |
| options | Seeding options. |
| region | UvTile descriptor for tiled domain positioning. |
| comm | Communicator for collective density reduction. |
| Forest hmap::seed_forest_kmeans | ( | size_t | species_count, |
| size_t | tree_count, | ||
| const Array & | density, | ||
| const Array & | exclusion, | ||
| float | cluster_randomness = 0.0f, | ||
| size_t | k_neighbors = 4, | ||
| const ForestSeedingOptions & | options = {}, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Generates a multi-species forest distribution using 2D inverse transform sampling for positions and PointSampler k-means clustering to tag species.
options.species are not taken into account by this function.| species_count | Number of distinct tree species. |
| tree_count | Target total number of trees. |
| density | Global density map array. |
| exclusion | Exclusion map array. |
| cluster_randomness | Randomness factor in [0, 1] added to cluster features. |
| k_neighbors | Number of nearest spatial neighbors used to extract compactness features. |
| options | Seeding options. |
| region | UvTile descriptor for tiled domain positioning. |
| comm | Communicator for collective density reduction. |
| Graph hmap::generate_network_alpha_model | ( | const std::vector< float > & | xc, |
| const std::vector< float > & | yc, | ||
| const std::vector< float > & | size, | ||
| const BBox2D & | bbox, | ||
| const Array & | z, | ||
| std::uint32_t | seed, | ||
| float | alpha = 0.7f, | ||
| int | n_dummy_nodes = 2500, | ||
| float | dz_weight = 1.f, | ||
| const Array * | p_weight = nullptr ) |
Generate a large scale road network between "nodes" (or cities) using the alpha model.
Based on the paper of Molinero et al. [Molinero2020].
| xc | x locations of the cities. |
| yc | y locations of the cities. |
| size | City sizes (arbitrary unit). |
| bbox | Bounding box. |
| z | Heightmap. |
| seed | Random seed number. |
| alpha | "Alpha coefficient" of the model (cost difference between creating a new and using an old one). |
| n_dummy_nodes | Number of dummy nodes added for the tesselation. |
| dz_weight | Weight of the elevation difference in the cost function. |
| p_weight | Map defining the local value added to the cost function (can be used to add large penalizations to create "no go" zones). |
Example
Result
| Array hmap::build_rock_density | ( | const Array & | heightmap, |
| float | max_slope = 0.05f, | ||
| float | bulkify_amp = 0.01f, | ||
| float | weight_elev = 1.0f, | ||
| float | weight_slope = 1.0f, | ||
| float | weight_rivers = 1.0f, | ||
| float | river_talus_ref = 0.1f, | ||
| float | river_clipping_ratio = 1000.0f, | ||
| const Array & | secondary_density = {}, | ||
| float | weight_secondary = 1.0f, | ||
| const Array & | exclusion_mask = {}, | ||
| float | exclusion_threshold = 0.f, | ||
| const BBox2D & | bbox = BBox2D{} ) |
Computes a probability density map in [0, 1] for rock placement based on elevation, talus/slope, river drainage paths, an optional secondary density map, and an optional exclusion mask.
A subtle bulkify filter can be applied to the heightmap prior to computing talus and river beds, eliminating micro-depressions and guiding flow lines.
| heightmap | Input terrain heightmap. |
| max_slope | Talus value above which density smoothly falls to zero. |
| bulkify_amp | Amplitude of bulkify pulse filter applied to the terrain (0.f disables). |
| weight_elev | Weight for inverted elevation criterion. |
| weight_slope | Weight for talus/slope criterion. |
| weight_rivers | Weight for river accumulation criterion. |
| river_talus_ref | Reference talus for river flow partitioning. |
| river_clipping_ratio | Flow accumulation clipping ratio. |
| secondary_density | Optional secondary density modulation map. |
| weight_secondary | Weight for optional secondary density map. |
| exclusion_mask | Optional exclusion mask (density set to 0 where exclusion > exclusion_threshold). |
| exclusion_threshold | Threshold above which exclusion mask excludes rocks. |
| bbox | Domain bounding box for tiled bulkify synthesis. |
| RockField hmap::place_rocks_procedural | ( | size_t | rock_count, |
| const Array & | elevation, | ||
| float | min_elev = 0.f, | ||
| float | max_elev = 0.9f, | ||
| float | max_slope = 1.f, | ||
| const Array & | density = {}, | ||
| const Array & | exclusion = {}, | ||
| float | size_slope_weight = 0.f, | ||
| float | size_elevation_gain = 1.f, | ||
| float | size_elevation_exponent = 1.f, | ||
| const RockSeedingOptions & | options = {}, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Places rocks procedurally on a terrain, without physical simulation.
Positions are sampled from a density map (defaults to a flat density equal to 1 if none is provided). Rock radii are drawn from a bounded power-law (Pareto) distribution between radius_min and a local maximum radius that grows toward radius_max as the elevation decreases: high areas only hold small rocks, whereas low areas hold both small and large rocks (the size distribution broadens when lowering altitude). Steep slopes further reduce the maximum rock size.
| rock_count | Target number of rocks. |
| elevation | Terrain elevation heightmap. |
| min_elev | Elevation mapped to 0 in the normalized elevation. |
| max_elev | Elevation mapped to 1 in the normalized elevation. |
| max_slope | Talus threshold above which rock size is attenuated. |
| density | Optional user density map (if empty, defaults to uniform flat density of 1). |
| exclusion | Optional exclusion map (same shape as elevation). |
| size_slope_weight | In [0, 1], reduces the maximum rock size on steep slopes (0 = no effect). |
| size_elevation_gain | Low-elevation influence on the maximum rock size (0 = none). |
| size_elevation_exponent | Power-law exponent of the maximum size / (1 - elevation) relation. |
| options | Seeding options (bbox, seed, exclusion threshold, rock distribution). |
| region | UvTile descriptor for tiled domain positioning. |
| comm | Communicator for collective density reduction. |
| RockField hmap::seed_rock_field | ( | size_t | rock_count, |
| const Array & | density, | ||
| const Array & | exclusion = {}, | ||
| const RockSeedingOptions & | options = {}, | ||
| const UvTile & | region = UvTile::unit(), | ||
| ICommunicator & | comm = SingleArrayComm::instance() ) |
Seeds a general rock/boulder field using inverse density transform sampling and applies power-law radius distribution and collision resolution.
| rock_count | Target number of rocks. |
| density | Spatial probability density map array. |
| exclusion | Optional exclusion map array. |
| options | Seeding options. |
| region | UvTile descriptor for tiled domain positioning. |
| comm | Communicator for collective density reduction. |
| RockField hmap::simulate_rock_emission | ( | size_t | rock_count, |
| const Array & | emission_density, | ||
| const Array & | elevation, | ||
| const Array * | p_friction_map = nullptr, | ||
| const RockDistribution & | dist = {}, | ||
| const RockSimulationOptions & | options = {} ) |
Emits rocks from a spatial emission density map and simulates their trajectories downhill across terrain on GPU.
| rock_count | Target number of rocks to emit and simulate. |
| emission_density | Spatial probability density map where rocks originate. |
| elevation | Terrain elevation heightmap. |
| p_friction_map | Optional soil friction map (same dimensions as elevation). |
| dist | Rock distribution specifying radii and classes. |
| options | Simulation options. |
| RockField hmap::simulate_rock_trajectories | ( | const RockField & | rocks, |
| const Array & | elevation, | ||
| const Array * | p_friction_map = nullptr, | ||
| const RockSimulationOptions & | options = {} ) |
Simulates physical movement (sliding, rolling, bouncing, and inter-rock collision avoidance) for an existing RockField across terrain on GPU.
| rocks | Input rock field with initial positions. |
| elevation | Terrain elevation heightmap. |
| p_friction_map | Optional soil friction map. |
| options | Simulation options. |
| void hmap::convert_mat_to_array | ( | const cv::Mat & | mat, |
| Array & | array, | ||
| bool | flip_j ) |
| void hmap::square_fill_md | ( | Array & | array, |
| Mat< int > & | is_done, | ||
| int | i1, | ||
| int | i2, | ||
| int | j1, | ||
| int | j2, | ||
| float | noise_scale, | ||
| std::mt19937 | gen, | ||
| std::uniform_real_distribution< float > | dis ) |
| void hmap::square_md | ( | Array & | array, |
| Mat< int > & | is_done, | ||
| int | step, | ||
| float | noise_scale, | ||
| std::mt19937 | gen, | ||
| std::uniform_real_distribution< float > | dis ) |
| Array hmap::flatbed_carve | ( | glm::ivec2 | shape, |
| const Path & | path, | ||
| float | bottom_extent, | ||
| float | vmin, | ||
| float | depth, | ||
| float | falloff_distance, | ||
| float | outer_slope, | ||
| bool | preserve_bedshape, | ||
| RadialProfile | radial_profile, | ||
| float | radial_profile_parameter, | ||
| Array * | p_falloff_mask, | ||
| const Array * | p_noise_r, | ||
| const UvRect & | uv_rect ) |
|
inline |
|
inline |
| std::vector< glm::vec3 > hmap::helper_tov3 | ( | const std::vector< std::vector< float > > & | colors | ) |
| void hmap::thermal_schott | ( | Array & | z, |
| const Array & | talus, | ||
| Array * | p_mask, | ||
| int | iterations, | ||
| float | intensity ) |
| void hmap::thermal_schott | ( | Array & | z, |
| const float | talus, | ||
| int | iterations, | ||
| float | intensity ) |
| void hmap::thermal_schott | ( | Array & | z, |
| const float | talus, | ||
| Array * | p_mask, | ||
| int | iterations, | ||
| float | intensity ) |
| void hmap::helper_build_mesh_masked | ( | aiMesh * | p_mesh, |
| const Array & | array, | ||
| const Array & | mask, | ||
| float | elevation_scaling, | ||
| bool | fit_boundaries ) |
| void hmap::helper_build_mesh | ( | aiMesh * | p_mesh, |
| const Array & | array, | ||
| MeshType | mesh_type, | ||
| float | elevation_scaling, | ||
| float | max_error, | ||
| bool | fit_boundaries ) |
| Texture hmap::compute_splatmap | ( | const Array * | p_r, |
| const Array * | p_g, | ||
| const Array * | p_b, | ||
| const Array * | p_a ) |
| glm::ivec4 hmap::helper_compute_tile_bounds | ( | int | tile_x, |
| int | tile_y, | ||
| const glm::ivec2 & | tile_count, | ||
| const glm::ivec2 & | array_shape, | ||
| bool | overlapping_edges, | ||
| bool | reverse_tile_y_indexing ) |
| Path hmap::helper_build_path | ( | const std::vector< Point > & | points, |
| InterpolationMethodCurve | method, | ||
| Path::EdgeDivisionMode | edm, | ||
| int | edge_divisions, | ||
| int | point_count ) |
| size_t hmap::helper_estimate_count | ( | const BBox2D & | bbox, |
| float | distance ) |
| void hmap::compute_gradient | ( | const Array & | array, |
| Array & | dx, | ||
| Array & | dy, | ||
| float | x_coeff[3], | ||
| float | y_coeff[3], | ||
| float | normalize_factor ) |
| Array hmap::compute_gradient_norm | ( | const Array & | array, |
| float | x_coeff[3], | ||
| float | y_coeff[3], | ||
| float | normalize_factor, | ||
| Array * | p_dx = nullptr, | ||
| Array * | p_dy = nullptr ) |
| bool hmap::is_monotonic | ( | const std::vector< float > & | data | ) |
| int hmap::find_last_index_smaller_than | ( | const std::vector< float > & | vec, |
| float | threshold ) |
| float hmap::helper_wrap_phi | ( | float | phi | ) |
| auto hmap::helper_make_wrapped | ( | F | f | ) |
| Array hmap::helper_reconstruction_impl | ( | const Array & | marker, |
| const Array & | mask, | ||
| int | ir, | ||
| float | k_smooth, | ||
| std::function< Array(const Array &, int)> | morph_op, | ||
| std::function< Array(const Array &, const Array &, float)> | clamp_op ) |
| void hmap::helper_thinning | ( | Array & | in, |
| int | iter ) |
| void hmap::helper_flip_rot_transpose | ( | Array & | array, |
| bool | do_flip, | ||
| int | rot_steps, | ||
| bool | do_transpose ) |
| float hmap::helper_crater_radial_function | ( | float | r, |
| float | inner_depth, | ||
| float | inner_exp, | ||
| float | lip_height, | ||
| float | lip_extent, | ||
| float | lip_exp, | ||
| int | n_terraces, | ||
| float | terrace_extent, | ||
| float | terrace_exp, | ||
| float | terrace_persistence ) |
| float hmap::helper_crater_profile | ( | float | r, |
| float | dx, | ||
| float | dy, | ||
| float | alpha, | ||
| float | ap, | ||
| float | am, | ||
| float | inner_depth, | ||
| float | inner_exp, | ||
| float | lip_height, | ||
| float | lip_extent, | ||
| float | lip_exp, | ||
| float | central_peak_height, | ||
| float | central_peak_extent, | ||
| int | n_terraces, | ||
| float | terrace_extent, | ||
| float | terrace_exp, | ||
| float | terrace_persistence ) |
| Point hmap::helper_pick_lowest | ( | const Point & | pa, |
| const Point & | pb, | ||
| const Array & | z, | ||
| float | max_offset, | ||
| int | steps ) |
| int hmap::count_neighbors_to_fill | ( | int | i, |
| int | j, | ||
| Mat< int > & | is_cell_done ) |
| bool hmap::cmp_queue | ( | std::pair< int, std::pair< int, int > > & | a, |
| std::pair< int, std::pair< int, int > > & | b ) |
| void hmap::reindex_vector | ( | std::vector< int > & | v, |
| std::vector< size_t > & | idx ) |
| void hmap::reindex_vector | ( | std::vector< float > & | v, |
| std::vector< size_t > & | idx ) |
| hmap::TEST | ( | NoiseStretch | , |
| CpuIsotropicPreserved | ) |
| hmap::TEST | ( | NoiseStretch | , |
| CpuDirectionalMatchesAxisScaling | ) |
| hmap::TEST | ( | NoiseStretch | , |
| CpuOctaveDecay | ) |
| hmap::TEST | ( | NoiseStretch | , |
| GpuIsotropicAndDirectional | ) |
| hmap::TEST | ( | NoiseStretch | , |
| AllNoiseTypesCpuAndGpu | ) |