HighMap library (C++)
Loading...
Searching...
No Matches
erosion.hpp File Reference

Implements hydraulic and thermal erosion algorithms for terrain modeling, including particle-based flow, sediment transport (Musgrave, Benes, Olsen), slope-driven diffusion, and procedural ridge formation. Supports GPU-accelerated methods and generates erosion/deposition maps for geomorphic analysis. More...

Go to the source code of this file.

Namespaces

namespace  hmap
 
namespace  hmap::gpu
 

Enumerations

enum  hmap::ErosionProfile : int {
  hmap::COSINE , hmap::SAW_SHARP , hmap::SAW_SMOOTH , hmap::SHARP_VALLEYS ,
  hmap::SQUARE_SMOOTH , hmap::TRIANGLE_GRENIER , hmap::TRIANGLE_SHARP , hmap::TRIANGLE_SMOOTH
}
 Procedural erosion angular profile type. More...
 

Functions

void hmap::depression_filling (Array &z, int iterations=1000, float epsilon=1e-4f)
 Fill the depressions of the heightmap using the Planchon-Darboux algorithm.
 
void hmap::erosion_maps (Array &z_before, Array &z_after, Array &erosion_map, Array &deposition_map, float tolerance=0.f)
 
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.
 
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.
 
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.
 
void hmap::hydraulic_blur (Array &z, float radius, float vmax, float k_smoothing=0.1f)
 Apply cell-based hydraulic erosion using a nonlinear diffusion model.
 
void hmap::hydraulic_diffusion (Array &z, float c_diffusion, float talus, int iterations)
 Apply cell-based hydraulic erosion using a nonlinear diffusion model.
 
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).
 
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_particle (Array &z, Array *p_mask, int nparticles, int seed, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float c_capacity=10.f, float c_erosion=0.05f, float c_deposition=0.05f, float c_inertia=0.3f, float drag_rate=0.001f, float evap_rate=0.001f, bool post_filtering=false)
 Apply hydraulic erosion using a particle based procedure.
 
void hmap::hydraulic_particle (Array &z, int nparticles, int seed, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float c_capacity=10.f, float c_erosion=0.05f, float c_deposition=0.05f, float c_inertia=0.3f, float drag_rate=0.001f, float evap_rate=0.001f, bool post_filtering=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::hydraulic_particle_multiscale (Array &z, float particle_density, int seed, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float c_capacity=10.f, float c_erosion=0.05f, float c_deposition=0.01f, float c_inertia=0.3f, float drag_rate=0.01f, float evap_rate=0.001f, int pyramid_finest_level=0)
 Apply hydraulic erosion using a particle based procedure, using a pyramid decomposition to allow a multiscale approach.
 
void hmap::hydraulic_procedural (Array &z, uint seed, float ridge_wavelength, float ridge_scaling=0.1f, ErosionProfile erosion_profile=ErosionProfile::TRIANGLE_SMOOTH, float delta=0.02f, float noise_ratio=0.2f, int prefilter_ir=-1, float density_factor=1.f, float kernel_width_ratio=2.f, float phase_smoothing=2.f, float phase_noise_amp=M_PI, bool reverse_phase=false, bool rotate90=false, bool use_default_mask=true, float talus_mask=0.f, Array *p_mask=nullptr, Array *p_ridge_mask=nullptr, float vmin=0.f, float vmax=-1.f)
 Generates a procedurally eroded terrain using hydraulic erosion and ridge generation techniques.
 
void hmap::hydraulic_stream (Array &z, float c_erosion, float talus_ref, Array *p_bedrock=nullptr, 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 hmap::hydraulic_stream (Array &z, Array *p_mask, float c_erosion, float talus_ref, Array *p_bedrock=nullptr, 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_upscale_amplification (Array &z, float c_erosion, float talus_ref, int upscaling_levels=1, float persistence=1.f, int ir=1, float clipping_ratio=10.f)
 Applies hydraulic erosion with upscaling amplification.
 
void hmap::hydraulic_stream_upscale_amplification (Array &z, Array *p_mask, float c_erosion, float talus_ref, int upscaling_levels=1, float persistence=1.f, int ir=1, float clipping_ratio=10.f)
 Applies hydraulic erosion with upscaling amplification, with a post-processing intensity mask.
 
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, Array *p_bedrock=nullptr, 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 hmap::hydraulic_stream_log (Array &z, float c_erosion, float talus_ref, 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, Array *p_bedrock=nullptr, 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_vpipes (Array &z, Array *p_mask, int iterations, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float water_height=0.1f, float c_capacity=0.1f, float c_erosion=0.05f, float c_deposition=0.05f, float rain_rate=0.f, float evap_rate=0.01f)
 Apply hydraulic erosion using the 'virtual pipes' algorithm.
 
void hmap::hydraulic_vpipes (Array &z, int iterations, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float water_height=0.1f, float c_capacity=0.1f, float c_erosion=0.05f, float c_deposition=0.05f, float rain_rate=0.f, 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::sediment_deposition (Array &z, Array *p_mask, const Array &talus, Array *p_deposition_map=nullptr, float max_deposition=0.01, int iterations=5, int thermal_subiterations=10)
 Perform sediment deposition combined with thermal erosion.
 
void hmap::sediment_deposition (Array &z, const Array &talus, Array *p_deposition_map=nullptr, float max_deposition=0.01, int iterations=5, int thermal_subiterations=10)
 
void hmap::sediment_deposition_particle (Array &z, Array *p_mask, int nparticles, int ir, int seed=1, Array *p_spawning_map=nullptr, Array *p_deposition_map=nullptr, float particle_initial_sediment=0.1f, float deposition_velocity_limit=0.01f, float drag_rate=0.001f)
 
void hmap::sediment_deposition_particle (Array &z, int nparticles, int ir, int seed=1, Array *p_spawning_map=nullptr, Array *p_deposition_map=nullptr, float particle_initial_sediment=0.1f, float deposition_velocity_limit=0.01f, float drag_rate=0.001f)
 
void hmap::sediment_layer (Array &z, const Array &talus_layer, const Array &talus_upper_limit, int iterations, bool apply_post_filter=true, Array *p_deposition_map=nullptr)
 
void hmap::stratify (Array &z, Array *p_mask, std::vector< float > hs, std::vector< float > gamma, Array *p_noise=nullptr)
 Stratify the heightmap by creating a series of layers with elevations corrected by a gamma factor.
 
void hmap::stratify (Array &z, std::vector< float > hs, std::vector< float > gamma, 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::stratify (Array &z, std::vector< float > hs, float gamma=0.5f, 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::stratify (Array &z, Array &partition, int nstrata, float strata_noise, float gamma, float gamma_noise, int npartitions, uint seed, float mixing_gain_factor=1.f, Array *p_noise=nullptr, float vmin=1.f, float vmax=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::stratify_multiscale (Array &z, float zmin, float zmax, std::vector< int > n_strata, std::vector< float > strata_noise, std::vector< float > gamma_list, std::vector< float > gamma_noise, uint seed, Array *p_mask=nullptr, Array *p_noise=nullptr)
 Stratify the heightmap by creating a multiscale series of layers with elevations corrected by a gamma factor.
 
void hmap::stratify_oblique (Array &z, Array *p_mask, std::vector< float > hs, std::vector< float > gamma, float talus, float angle, Array *p_noise=nullptr)
 Stratify the heightmap by creating a series of oblique layers with elevations corrected by a gamma factor.
 
void hmap::stratify_oblique (Array &z, std::vector< float > hs, std::vector< float > gamma, float talus, float angle, 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::thermal (Array &z, Array *p_mask, const Array &talus, int iterations=10, Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
 Apply thermal weathering erosion.
 
void hmap::thermal (Array &z, const Array &talus, int iterations=10, Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
 
void hmap::thermal (Array &z, float talus, int iterations=10, Array *p_bedrock=nullptr, 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::thermal_auto_bedrock (Array &z, const Array &talus, int iterations=10, Array *p_deposition_map=nullptr)
 Apply thermal weathering erosion with automatic determination of the bedrock.
 
void hmap::thermal_auto_bedrock (Array &z, float talus, int iterations=10, 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::thermal_auto_bedrock (Array &z, Array *p_mask, float talus, int iterations=10, 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::thermal_flatten (Array &z, const Array &talus, const Array &bedrock, int iterations=10, int post_filter_ir=1)
 Apply modified thermal weathering of Olsen.
 
void hmap::thermal_flatten (Array &z, float talus, int iterations=10, int post_filter_ir=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::thermal_olsen (Array &z, const Array &talus, int iterations=10, Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
 Apply thermal weathering erosion.
 
void hmap::thermal_rib (Array &z, int iterations, Array *p_bedrock=nullptr)
 Apply thermal erosion using a 'rib' algorithm (taken from Geomorph).
 
void hmap::thermal_schott (Array &z, const Array &talus, int iterations=10, float intensity=0.001f)
 Applies the thermal erosion process to an array of elevation values.
 
void hmap::thermal_schott (Array &z, const Array &talus, Array *p_mask, int iterations=10, float intensity=0.001f)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void hmap::thermal_schott (Array &z, const float talus, int iterations=10, float intensity=0.001f)
 Applies the thermal erosion process with a uniform slope threshold.
 
void hmap::thermal_schott (Array &z, const float talus, Array *p_mask, int iterations=10, float intensity=0.001f)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void hmap::gpu::hydraulic_particle (Array &z, int nparticles, int seed, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float c_capacity=10.f, float c_erosion=0.05f, float c_deposition=0.05f, float c_inertia=0.3f, float drag_rate=0.001f, float evap_rate=0.001f, bool post_filtering=false)
 See hmap::hydraulic_particle.
 
void hmap::gpu::hydraulic_particle (Array &z, Array *p_mask, int nparticles, int seed, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float c_capacity=10.f, float c_erosion=0.05f, float c_deposition=0.05f, float c_inertia=0.3f, float drag_rate=0.001f, float evap_rate=0.001f, bool post_filtering=false)
 See hmap::hydraulic_particle.
 
void hmap::gpu::hydraulic_schott (Array &z, int iterations, const Array &talus, float c_erosion=1.f, float c_thermal=0.1f, float c_deposition=0.2f, float flow_acc_exponent=0.8f, float flow_acc_exponent_depo=0.8f, float flow_routing_exponent=1.3f, float thermal_weight=1.5f, float deposition_weight=2.5f, Array *p_flow=nullptr)
 Simulates hydraulic erosion and deposition on a heightmap using the Schott method.
 
void hmap::gpu::hydraulic_schott (Array &z, int iterations, const Array &talus, Array *p_mask, float c_erosion=1.f, float c_thermal=0.1f, float c_deposition=0.2f, float flow_acc_exponent=0.8f, float flow_acc_exponent_depo=0.8f, float flow_routing_exponent=1.3f, float thermal_weight=1.5f, float deposition_weight=2.5f, Array *p_flow=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::gpu::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, Array *p_bedrock=nullptr, Array *p_moisture_map=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, Array *p_flow_map=nullptr)
 See hmap::hydraulic_stream_log.
 
void hmap::gpu::hydraulic_stream_log (Array &z, float c_erosion, float talus_ref, 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, Array *p_bedrock=nullptr, 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::gpu::thermal (Array &z, const Array &talus, int iterations=10, Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
 See hmap::thermal.
 
void hmap::gpu::thermal (Array &z, Array *p_mask, const Array &talus, int iterations=10, Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
 See hmap::thermal.
 
void hmap::gpu::thermal (Array &z, float talus, int iterations=10, Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
 See hmap::thermal.
 
void hmap::gpu::thermal_auto_bedrock (Array &z, const Array &talus, int iterations=10, Array *p_deposition_map=nullptr)
 See hmap::thermal_auto_bedrock.
 
void hmap::gpu::thermal_auto_bedrock (Array &z, Array *p_mask, const Array &talus, int iterations=10, Array *p_deposition_map=nullptr)
 See hmap::thermal_auto_bedrock.
 
void hmap::gpu::thermal_auto_bedrock (Array &z, float, int iterations=10, Array *p_deposition_map=nullptr)
 See hmap::thermal_auto_bedrock.
 
void hmap::gpu::thermal_inflate (Array &z, const Array &talus, int iterations=10)
 Apply thermal weathering erosion to give a scree like effect.
 
void hmap::gpu::thermal_inflate (Array &z, const Array *p_mask, const Array &talus, int iterations=10)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void hmap::gpu::thermal_rib (Array &z, int iterations, Array *p_bedrock=nullptr)
 See hmap::thermal_rib.
 
void hmap::gpu::thermal_ridge (Array &z, const Array &talus, int iterations=10, Array *p_deposition_map=nullptr)
 Apply thermal weathering erosion to give a ridge like effect.
 
void hmap::gpu::thermal_ridge (Array &z, const Array *p_mask, const Array &talus, int iterations=10, 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::gpu::thermal_scree (Array &z, const Array &talus, const Array &zmax, int iterations=10, bool talus_constraint=true, Array *p_deposition_map=nullptr)
 Performs thermal scree erosion on a heightmap.
 
void hmap::gpu::thermal_scree (Array &z, const Array *p_mask, const Array &talus, const Array &zmax, int iterations=10, bool talus_constraint=true, 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.
 

Detailed Description

Implements hydraulic and thermal erosion algorithms for terrain modeling, including particle-based flow, sediment transport (Musgrave, Benes, Olsen), slope-driven diffusion, and procedural ridge formation. Supports GPU-accelerated methods and generates erosion/deposition maps for geomorphic analysis.

Author
Otto Link (otto..nosp@m.link.nosp@m..bv@g.nosp@m.mail.nosp@m..com)