|
HighMap library (C++)
|
Header file for hydrological modeling functions and utilities. More...
Go to the source code of this file.
Namespaces | |
| namespace | hmap |
| namespace | hmap::gpu |
| namespace | hmap::va |
Functions | |
| Array | hmap::basin_id (const Array &z, bool fast_approx=false, bool remove_lakes=true) |
| Label drainage basins using a priority-flood algorithm. | |
| 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. | |
| Array | hmap::d8_compute_ndip (const Array &d8) |
| Computes the number of drainage paths for each cell based on the D8 flow direction model. | |
| 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. | |
| 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. | |
| std::vector< glm::ivec2 > | hmap::find_flow_sinks (const Array &z) |
| Find interior flow sinks in a height field. | |
| std::vector< glm::ivec2 > | hmap::find_flow_sinks_border (const Array &z) |
| Find flow sinks located on the domain border. | |
| Array | hmap::flooding_uniform_level (const Array &z, float zref) |
| Compute water depth for a uniform flooding level. | |
| 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 ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Compute flooding starting from the lowest boundary points. | |
| Array | hmap::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 | 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 ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Flood terrain starting from multiple seed points. | |
| Array | hmap::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 | hmap::flow_accumulation_d8 (const Array &z) |
| Computes the flow accumulation for each cell using the D8 flow direction model. | |
| 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. | |
| Array | hmap::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 | 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 ®ion={}, ICommunicator &comm=SingleArrayComm::instance()) |
| Computes averaged D-infinity flow accumulation with terrain perturbations. | |
| Array | hmap::flow_direction_d8 (const Array &z) |
| Computes the flow direction from each cell to its downslope neighbor using the D8 model. | |
| std::vector< Array > | hmap::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 > | hmap::flow_direction_dinf_flat (const Array &z, float talus_ref) |
| Array | hmap::flow_direction_dinf_angle (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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| Array | hmap::merge_water_depths (const Array &depth1, const Array &depth2, float k_smooth=0.f) |
| Merge two water depth fields. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| Array | hmap::water_mask (const Array &water_depth) |
| Generates a binary mask representing water presence. | |
| Array | hmap::water_mask (const Array &water_depth, const Array &z, float additional_depth) |
| Computes a gradient-based water mask using an extended water depth model. | |
| Array | hmap::gpu::coastal_fetch (const Array &z, int ndirections, const Array *p_compute_mask=nullptr) |
| Computes the omnidirectional coastal fetch for each cell. | |
| Array | hmap::gpu::coastal_fetch_directional (const Array &z, float angle, float directional_exp, int ndirections, const Array *p_compute_mask=nullptr) |
| Computes directional coastal fetch weighted by alignment with a prevailing wind or wave direction. | |
| Array | hmap::gpu::flow_accumulation_from_velocity_field (const Array &u, const Array &v, int iterations) |
| Approximates flow accumulation from a 2D velocity field. | |
| Array | hmap::gpu::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) |
| GPU (OpenCL) variant of hmap::flow_accumulation_stochastic — see the CPU declaration for the algorithm description and parameters. | |
| Array | hmap::gpu::flow_direction_d8 (const Array &z) |
| See hmap::flow_direction_d8. | |
| Array | hmap::gpu::flow_simulation (const Array &z, float water_depth, const Array &depth_map, int iterations, float dt=0.5f, bool flux_diffusion=true, float flux_diffusion_strength=0.01f, float dry_out_ratio=0.f, const Array *p_rain_map=nullptr, float rain_rate=0.f, float evap_rate=0.f, bool outflow_boundaries=false, Array *p_vel_u=nullptr, Array *p_vel_v=nullptr, int sync_interval=0, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| GPU hydraulic flow simulation using a virtual-pipes model; simulates shallow-water transport over a height field using iterative flux computation and water transport passes, with optional flux diffusion and post-simulation dry-out. The whole iteration loop runs on the device: the terrain is uploaded once, depth and fluxes ping-pong between device images, and only the final depth (and velocity, if requested) are read back. | |
| Array | hmap::gpu::flow_simulation_viscous (const Array &z, float water_depth, const Array &depth_map, int iterations, float dt=-1.f, float dry_out_ratio=0.f, float viscosity=1.f, float power=2.5f, float evap_rate=0.f, bool outflow_boundaries=false, int sync_interval=0, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| GPU viscous shallow-water flow simulation using non-linear thin-film diffusion with upwind mobility. | |
| Array | hmap::gpu::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) |
| See hmap::generate_riverbed. | |
| Array | hmap::gpu::snow_mantle (const Array &z, float strength=0.1f, float snowline=0.5f, float falloff=0.1f, int prefilter_ir=8, float talus_coverage=0.8f, float talus_threshold=0.001f, float directional=0.f, float wind_direction=0.f, float peaks=0.2f, float melt=0.f, float sun_azimuth=180.f, float sun_zenith=45.f, int thermal_iterations=15, float thermal_talus=0.15f, float coverage=0.5f, const Array *p_existing_snow=nullptr, const Array *p_mask=nullptr, const Array *p_noise=nullptr) |
| Generates fine-scale snow mantle accumulation over terrain. | |
| Array | hmap::gpu::snow_simulation (const Array &z, float snow_depth, const Array &fall_map, const Array &melting_map, const Array &talus, int iterations, float dt=0.5f, float fall_iterations_ratio=1.f, float k_snow=0.5f, float k_visc=0.1f, float k_melt_factor=0.8f, float k_depth_ratio=1.f, float k_depth_slope_ratio=1.f, float k_creep=0.1f, bool post_filter=true, float thermal_talus_ratio=0.2f, bool outflow_boundaries=true, float clamp_smin=0.f, bool rebase_snow_depth_to_zero=true, int sync_interval=0, const UvTile ®ion=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance()) |
| Simulate snow accumulation and redistribution over a terrain. | |
| void | hmap::gpu::water_depth_filter (Array &depth, const Array &z, int ir, const Array *p_water_mask=nullptr, bool smooth_contour=false, float transition_ratio=0.1f) |
| Filters water depth values using elevation data and a given radius. | |
| Array | hmap::gpu::water_frontier_curvature (const Array &water_depth, int prefilter_ir, bool extend_values_from_interface=false) |
| See hmap::water_frontier_curvature. | |
| Array | hmap::gpu::water_depth_from_mask (const Array &z, const Array &mask, float mask_threshold=0.f, int iterations_max=10000, float tolerance=1e-2f) |
| See hmap::water_depth_from_mask. | |
| std::vector< Path > | hmap::va::flow_fixing_mst_paths (const ComputeMode &cm, const VirtualArray &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) |
| Resolves flow sinks on a VirtualArray by computing an MST on a triangular mesh and distributing river path carving with trenching across tiles. | |
| VirtualArray | hmap::va::flow_fixing_mst_triangulated (const ComputeMode &cm, const VirtualArray &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 VirtualArray *p_noise_r=nullptr) |
| Path | hmap::va::flow_stream (const ComputeMode &cm, const VirtualArray &z, glm::vec2 start, std::uint32_t seed=0, size_t control_points_count=2048, 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 across a VirtualArray using an intermediate random terrain triangular mesh. | |
Header file for hydrological modeling functions and utilities.
This header file declares functions and utilities for hydrological modeling, including tools for computing flow directions, flow accumulation, and identifying flow sinks within heightmaps. It supports multiple flow direction models and the D8 model for flow direction and accumulation calculations.
Key functionalities include: