HighMap library (C++)
Loading...
Searching...
No Matches
hmap::gpu Namespace Reference

Namespaces

namespace  detail

Classes

struct  McDonaldParams
 Parameters for McDonald particle-based hydraulic erosion solver. More...

Enumerations

enum  LocalMetrics : int {
  LM_LOCAL_ASPECT_VARIANCE , LM_LOCAL_MAX , LM_LOCAL_MEDIAN_DEVIATION , LM_LOCAL_MIN ,
  LM_LOCAL_RELIEF , LM_LOCAL_VARIANCE , LM_LOCAL_MEAN , LM_LOCAL_SKEWNESS ,
  LM_LOCAL_Z_SCORE , LM_TOPOGRAPHIC_POSITION_INDEX , LM_TOPOGRAPHIC_WETNESS_INDEX , LM_RELATIVE_ELEVATION ,
  LM_ROUGHNESS , LM_RUGGEDNESS , LM_RUGOSITY_CONCAVE , LM_RUGOSITY_CONVEX ,
  LM_TOPOGRAPHIC_RESIDUAL
}
 Types of local metrics. More...

Functions

Array blend_gradients (const Array &array1, const Array &array2, int ir=4)
 See hmap::blend_gradients.
Array blend_poisson_bf (const Array &array1, const Array &array2, const int iterations=500, const Array *p_mask=nullptr)
 Blends two arrays using Poisson blending with a brute-force solver.
Texture blend_poisson_bf (const Texture &texture1, const Texture &texture2, const int iterations=500, const Array *p_mask=nullptr)
 Blends two textures using Poisson blending with a brute-force solver.
Array transfer (const Array &source, const Array &target, int ir, float amplitude, bool target_prefiltering=false)
 See hmap::transfer.
Array level_set_curvature (const Array &array, int prefilter_ir)
 See hmap::level_set_curvature.
Array curvature_quadric (const Array &z, int ir, CurvatureType curvature_type, bool approx_algo=false)
 See hmap::curvature_quadric.
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) on GPU.
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 deposition_fill_holes (Array &z, int deposition_ir, float deposition_strength, int iterations=1)
 Fill holes using Gaussian-based deposition.
void deposition_fill_holes (Array &z, int deposition_ir, float deposition_strength, 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 hydraulic_particle (Array &z, int nparticles, std::uint32_t seed, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, const Array *p_elevation_shift=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.01f, float c_gravity=1.f, float drag_rate=0.001f, float evap_rate=0.001f, float talus_slope=2.f, float collapse_rate=0.1f, int iterations=1)
 Simulates hydraulic erosion on a heightmap using particle-based flow.
void hydraulic_particle (Array &z, const Array *p_mask, int nparticles, std::uint32_t seed, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, const Array *p_elevation_shift=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.01f, float c_gravity=1.f, float drag_rate=0.001f, float evap_rate=0.001f, float talus_slope=2.f, float collapse_rate=0.1f, int iterations=1)
void hydraulic_particle_multiscale (Array &z, std::uint32_t seed, const std::vector< int > &steps_per_level={4, 2, 1}, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, const Array *p_elevation_shift=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float particles_ratio=0.5f, float c_capacity=10.f, float c_erosion=0.05f, float c_deposition=0.05f, float c_inertia=0.01f, float c_gravity=1.f, float drag_rate=0.001f, float evap_rate=0.001f, float talus_slope=2.f, float collapse_rate=0.1f, float mix=1.f, float warp=0.35f)
 Multiscale particle-based hydraulic erosion cascade.
void hydraulic_particle_multiscale (Array &z, const Array *p_mask, std::uint32_t seed, const std::vector< int > &steps_per_level={4, 2, 1}, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, const Array *p_elevation_shift=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float particles_ratio=0.5f, float c_capacity=10.f, float c_erosion=0.05f, float c_deposition=0.05f, float c_inertia=0.01f, float c_gravity=1.f, float drag_rate=0.001f, float evap_rate=0.001f, float talus_slope=2.f, float collapse_rate=0.1f, float mix=1.f, float warp=0.35f)
void hydraulic_mcdonald (Array &z, int steps, std::uint32_t seed, const McDonaldParams &params, const Array *p_moisture_map=nullptr, Array *p_sediment_map=nullptr, Array *p_discharge_map=nullptr)
 Particle-based hydraulic erosion with flow-field coupling (McDonald's model).
void hydraulic_mcdonald (Array &z, int steps, std::uint32_t seed, const Array *p_moisture_map=nullptr, Array *p_sediment_map=nullptr, Array *p_discharge_map=nullptr, float world_extent_km=40.f, float z_scale_km=4.f, int samples=8192, int maxage=512, float lrate=0.2f, float time_step=10.f, float rainfall=1.f, float evap_rate=1e-4f, float gravity=9.81f, float viscosity=0.025f, float bed_shear=0.01f, float crit_slope=0.57f, float settle_rate=0.1f, float thermal_rate=2.5e-3f, float deposition_rate=5e-3f, float suspension_rate=2.5e-4f, float exit_slope=0.01f)
void hydraulic_mcdonald_multiscale (Array &z, std::uint32_t seed, const std::vector< int > &steps_per_level, const McDonaldParams &params, const Array *p_moisture_map=nullptr, Array *p_sediment_map=nullptr, Array *p_discharge_map=nullptr)
 Multiscale driver for hydraulic_mcdonald.
void hydraulic_mcdonald_multiscale (Array &z, std::uint32_t seed, const std::vector< int > &steps_per_level={512, 256, 128}, const Array *p_moisture_map=nullptr, Array *p_sediment_map=nullptr, Array *p_discharge_map=nullptr, float world_extent_km=40.f, float z_scale_km=4.f, int samples=8192, int maxage=512, float lrate=0.2f, float time_step=10.f, float rainfall=1.f, float evap_rate=1e-4f, float gravity=9.81f, float viscosity=0.025f, float bed_shear=0.01f, float crit_slope=0.57f, float settle_rate=0.1f, float thermal_rate=2.5e-3f, float deposition_rate=5e-3f, float suspension_rate=2.5e-4f, float exit_slope=0.01f)
void hydraulic_procedural (Array &z, float kp_global, float c_erosion, std::uint32_t seed, ErosionProfile erosion_profile=ErosionProfile::EP_TRIANGLE_GRENIER, float erosion_profile_parameter=0.01f, float angle_shift=0.f, float phase_smoothing=0.1f, float talus_ref=0.001f, float gradient_scaling_ratio=1.f, float gradient_power=0.8f, bool exclude_ridges=true, bool apply_deposition=false, float deposition_strength=1.f, bool enable_default_noise=true, float noise_amp=0.01f, const Array *p_kp_multiplier=nullptr, const Array *p_angle_shift=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_ridge_mask=nullptr, const UvRect &uv_rect=UvRect{})
 Apply phase-guided hydraulic procedural erosion to a heightmap.
void hydraulic_procedural_fbm (Array &z, float kp_global, float c_erosion, std::uint32_t seed, ErosionProfile erosion_profile=ErosionProfile::EP_TRIANGLE_GRENIER, int octaves=3, float persistence=0.5f, float lacunarity=2.f, float erosion_profile_parameter=0.01f, float angle_shift=0.f, float phase_smoothing=0.1f, float talus_ref=0.001f, float gradient_scaling_ratio=1.f, float gradient_power=0.8f, bool exclude_ridges=true, bool apply_deposition=false, float deposition_strength=1.f, bool enable_default_noise=true, float noise_amp=0.01f, const Array *p_kp_multiplier=nullptr, const Array *p_angle_shift=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_ridge_mask=nullptr, const UvRect &uv_rect=UvRect{})
 Multi-octave (fBm) variant of hydraulic_procedural().
void hydraulic_procedural_fbm (Array &z, float kp_global, float c_erosion, std::uint32_t seed, const Array *p_mask, ErosionProfile erosion_profile=ErosionProfile::EP_TRIANGLE_GRENIER, int octaves=3, float persistence=0.5f, float lacunarity=2.f, float erosion_profile_parameter=0.01f, float angle_shift=0.f, float phase_smoothing=0.1f, float talus_ref=0.001f, float gradient_scaling_ratio=1.f, float gradient_power=0.8f, bool exclude_ridges=true, bool apply_deposition=false, float deposition_strength=1.f, bool enable_default_noise=true, float noise_amp=0.01f, const Array *p_kp_multiplier=nullptr, const Array *p_angle_shift=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_ridge_mask=nullptr, const UvRect &uv_rect=UvRect{})
void 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 Schott method.
void hydraulic_schott (Array &z, const Array *p_mask, 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)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void hydraulic_schott_erosion (Array &z, int iterations, float c_erosion=1.f, float flow_acc_exponent=0.8f, float flow_routing_exponent=1.3f, const Array *p_moisture_map=nullptr, Array *p_flow=nullptr)
 See hmap::gpu::hydraulic_schott.
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)
 See hmap::hydraulic_stream_log.
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)
 See hmap::hydraulic_stream_log_multiscale.
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_vpipes (Array &z, float water_height=1e-2f, bool maintain_water_volume=true, float evap_rate=0.1f, int iterations=50, float dt=0.5f, float k_capacity=0.5f, float k_erode=0.001f, float k_depose=0.01f, float k_discharge_exp=1.f, float downcutting_max_depth_ratio=10.f, bool flux_diffusion=true, float flux_diffusion_strength=0.01f, Array *p_rain_map=nullptr, Array *p_water_depth=nullptr, Array *p_sediment=nullptr, Array *p_vel_u=nullptr, Array *p_vel_v=nullptr)
 See hmap::gpu::hydraulic_vpipes.
void mudslide (Array &z, const Array &landslide_mask, float depth, int iterations, float depth_map_exponent=0.5f, float viscosity_law_power=1.5f, Array *p_depth_end=nullptr, Array *p_depth_init=nullptr)
 Simulate a mudslide (landslide-driven material redistribution) on a height field.
void mudslide (Array &z, float talus_limit, float depth, int iterations, float depth_map_exponent=0.5f, float viscosity_law_power=1.5f, Array *p_depth_end=nullptr, Array *p_depth_init=nullptr)
 See hmap::gpu::mudslide.
void rifts (Array &z, const glm::vec2 &kw, float angle, float amplitude, std::uint32_t seed, float elevation_noise_shift=0.f, float k_smooth_bottom=0.05f, float k_smooth_top=0.05f, float radial_spread_amp=0.2f, float elevation_noise_amp=0.1f, float clamp_vmin=0.f, float remap_vmin=0.f, bool apply_mask=true, bool reverse_mask=false, float mask_gamma=1.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_mask=nullptr, const glm::vec2 &center={0.5f, 0.5f}, const UvRect &uv_rect={0.f, 1.f, 0.f, 1.f})
 Applies a "rift" deformation effect to a heightmap array.
void sediment_deposition (Array &z, const 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 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 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)
 Applies a talus-based sediment deposition layer.
void strata (Array &z, float angle, float slope, float gamma, std::uint32_t seed, bool linear_gamma=true, float kz=1.f, int octaves=4, float lacunarity=2.f, float gamma_noise_ratio=0.5f, float noise_amp=0.4f, const glm::vec2 &noise_kw={4.f, 4.f}, bool enable_ridge_noise=true, const glm::vec2 &ridge_noise_kw={4.f, 1.2f}, float ridge_angle_shift=45.f, float ridge_noise_amp=0.5f, float ridge_clamp_vmin=0.f, float ridge_remap_vmin=0.f, bool apply_elevation_mask=true, bool apply_ridge_mask=true, float mask_gamma=0.4f, const Array *p_mask=nullptr, const UvRect &uv_rect={0.f, 1.f, 0.f, 1.f})
 Applies stratification to a heightfield using directional noise and multiscale gamma transformations.
void strata_cells (Array &z, glm::vec2 kw, float amp, std::uint32_t seed, float gamma=0.5f, float gamma_lateral=0.4f, float angle=0.f, float noise_amp=0.5f, bool absolute_displacement=true, float occurence_probability=0.5f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Applies procedural stratified cell displacement to a heightmap.
void strata_cells (Array &z, glm::vec2 kw, float amp, std::uint32_t seed, const Array *p_mask, float gamma=0.5f, float gamma_lateral=0.4f, float angle=0.f, float noise_amp=0.5f, bool absolute_displacement=true, float occurence_probability=0.5f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
void strata_cells_fbm (Array &z, glm::vec2 kw, float amp, std::uint32_t seed, float gamma=0.5f, float gamma_lateral=0.4f, float angle=0.f, bool enable_default_noise=true, float default_noise_amp=0.05f, bool absolute_displacement=true, float occurence_probability=0.5f, int octaves=8, float persistence=0.4f, float lacunarity=2.2f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Applies multi-octave (fBm) stratified cell displacement.
void strata_cells_fbm (Array &z, glm::vec2 kw, float amp, std::uint32_t seed, const Array *p_mask, float gamma=0.5f, float gamma_lateral=0.4f, float angle=0.f, bool enable_default_noise=true, float default_noise_amp=0.05f, bool absolute_displacement=true, float occurence_probability=0.5f, int octaves=8, float persistence=0.4f, float lacunarity=2.2f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
void strata_plates (Array &z, const Array &talus, int direction_offset=0, int direction_count=3, bool random_directions=false, std::uint32_t seed=0, float vmin=-FLT_MAX, float skew=0.f, float mix_ratio=0.9f, const Array *p_mask=nullptr, const Array *p_dx=nullptr, const Array *p_dy=nullptr)
 Apply stratified talus projection along multiple directions.
void strata_terrace (Array &z, float gamma, std::uint32_t seed, float kz=4.f, bool linear_gamma=true, float gamma_noise_ratio=0.5f, float slope=0.f, float angle=0.f, const Array *p_noise=nullptr, const UvRect &uv_rect=UvRect::unit())
 Applies a terrace (stratification) filter to a heightmap.
void strata_terrace (Array &z, float gamma, std::uint32_t seed, const Array *p_mask, float kz=4.f, bool linear_gamma=true, float gamma_noise_ratio=0.5f, float slope=0.f, float angle=0.f, const Array *p_noise=nullptr, const UvRect &uv_rect=UvRect::unit())
void valley_fill (Array &z, const Array &talus, int iterations=100, float gamma=2.f, float ratio=0.8f, float zmin=0.f, float zmax=0.f, float elevation_max_ratio=1.f, bool preserve_elevation_range=true, const Array *p_noise=nullptr, Array *p_deposition_map=nullptr)
 Fill valleys using thermal scree deposition and height-based blending.
void valley_fill (Array &z, const Array *p_mask, const Array &talus, int iterations=100, float gamma=2.f, float ratio=0.8f, float zmin=0.f, float zmax=0.f, float elevation_max_ratio=1.f, bool preserve_elevation_range=true, const Array *p_noise=nullptr, Array *p_deposition_map=nullptr)
Array watershed_ridge (const Array &z, float amplitude=0.2f, float width=32.f, float edt_exponent=0.5f, int prefilter_ir=0, bool fast_approx=false, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_scaling=nullptr)
 Carves watershed ridges using basin-wise distance transforms.
Array watershed_ridge (const Array &z, const Array *p_mask, float amplitude=0.2f, float width=32.f, float edt_exponent=0.5f, int prefilter_ir=0, bool fast_approx=false, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_scaling=nullptr)
void thermal (Array &z, const Array &talus, int iterations=10, const Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
 Apply thermal weathering erosion.
void thermal (Array &z, const Array *p_mask, const Array &talus, int iterations=10, const 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 thermal (Array &z, float talus, int iterations=10, const 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 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 thermal_auto_bedrock (Array &z, const Array *p_mask, const Array &talus, int iterations=10, Array *p_deposition_map=nullptr)
void thermal_auto_bedrock (Array &z, float, 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 thermal_conserve (Array &z, const Array &talus, int iterations=10, float rate=0.5f, const Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
 Apply mass-preserving thermal weathering erosion.
void thermal_conserve (Array &z, const Array *p_mask, const Array &talus, int iterations=10, float rate=0.5f, const 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 thermal_conserve (Array &z, float talus, int iterations=10, float rate=0.5f, const 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 thermal_flatten (Array &z, const Array &talus, int iterations, float sigma_inf=0.5f, float sigma_sup=0.f)
 Apply iterative thermal flattening erosion on a heightmap.
void thermal_flatten (Array &z, const Array *p_mask, const Array &talus, int iterations, float sigma_inf=0.5f, float sigma_sup=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 thermal_olsen (Array &z, const Array &talus, int iterations)
 Apply thermal weathering erosion (Olsen model).
void thermal_olsen (Array &z, const Array *p_mask, const Array &talus, int iterations)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void thermal_inflate (Array &z, const Array &talus, int iterations=10)
 Apply thermal weathering erosion to give a scree like effect.
void 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 thermal_rib (Array &z, int iterations)
 Apply thermal erosion using a 'rib' algorithm.
void thermal_rib (Array &z, const Array *p_mask, int iterations)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void 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 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 thermal_schott (Array &z, const Array &talus, int iterations=10, float intensity=0.2f, Array *p_deposition_map=nullptr)
 Applies the thermal erosion process with a uniform slope threshold (Schott model).
void thermal_schott (Array &z, const Array *p_mask, const Array &talus, int iterations=10, float intensity=0.2f, 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 thermal_scree (Array &z, const Array &talus, const Array &zmax, int iterations=10, Array *p_deposition_map=nullptr)
 Performs thermal scree erosion on a heightmap.
void thermal_scree (Array &z, const Array *p_mask, const Array &talus, const Array &zmax, 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.
Array bilateral_filter (const Array &array, const Array &kernel2d, const Array &kernel1d, float kernel1d_value_scaling)
 Apply a bilateral filter to an array.
Array bilateral_filter (const Array &array, int ir, float kernel1d_value_scaling)
 Apply a bilateral filter to an array using a radius-based Gaussian kernel.
void directional_blur (Array &array, float radius, const Array &angle, int steps=32)
 Applies a directional blur to the input array.
void directional_blur (Array &array, float radius, const Array &angle, const Array *p_mask, int steps=32)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
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)
 See hmap::distance_shaper.
void expand (Array &array, int ir, int iterations=1)
 See hmap::expand.
void expand (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 expand (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 expand (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 gamma_correction_local (Array &array, float gamma, int ir, float k=0.1f, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::gamma_correction_local.
void gamma_correction_local (Array &array, float gamma, int ir, const Array *p_mask, float k=0.1f, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array jagged (const Array &array, glm::vec2 kw, float amp=0.1f, std::uint32_t seed=0, glm::vec2 jitter={0.5f, 0.5f}, float gamma=1.f, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Apply a Voronoi-based jagged bubble dome filter to an array.
Array jagged (const Array &array, float kw, float amp=0.1f, std::uint32_t seed=0, glm::vec2 jitter={0.5f, 0.5f}, float gamma=1.f, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Apply a Voronoi-based jagged bubble dome filter using an isotropic frequency.
Array jagged_fbm (const Array &array, glm::vec2 kw, float amp=0.1f, std::uint32_t seed=0, int octaves=8, float persistence=0.5f, float lacunarity=2.f, bool switch_kx_ky=false, glm::vec2 jitter={0.5f, 0.5f}, float gamma=1.f, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Apply a fractal Brownian motion (fBm) version of the Voronoi-based jagged bubble dome filter to an array.
Array jagged_fbm (const Array &array, float kw, float amp=0.1f, std::uint32_t seed=0, int octaves=8, float persistence=0.5f, float lacunarity=2.f, bool switch_kx_ky=false, glm::vec2 jitter={0.5f, 0.5f}, float gamma=1.f, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Apply a fractal Brownian motion (fBm) version of the Voronoi-based jagged bubble dome filter using an isotropic frequency.
void laplace (Array &array, float sigma=0.2f, int iterations=3)
 See hmap::laplace.
void laplace (Array &array, const Array *p_mask, float sigma=0.2f, int iterations=3)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array mean_shift (const Array &array, int ir, float talus, int iterations=1, bool talus_weighted=true)
 See hmap::mean_shift.
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)
 See hmap::median_3x3.
void median_3x3 (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.
Array median_pseudo (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::median_pseudo.
void normal_displacement (Array &array, float amount=0.1f, int ir=0, bool reverse=false)
 See hmap::normal_displacement.
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, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::plateau.
void plateau (Array &array, int ir, float factor, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array project_talus_along_direction (const Array &array, const Array &talus, int direction=0, float vmin=-FLT_MAX)
 Projects array values along a given direction using talus attenuation.
Array project_talus_along_direction (const Array &array, const Array &talus, const Array *p_mask, int direction=0, float vmin=-FLT_MAX)
void recast_cliff (Array &array, float talus, int ir, float amplitude, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 Transform heightmap to add cliffs where gradients are steep enough using Poisson gradient amplification.
void recast_cliff (Array &array, float talus, int ir, float amplitude, const Array *p_mask, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void recast_cliff_directional (Array &array, float talus, int ir, float amplitude, float angle, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 Transform heightmap to add directional cliffs where gradients are steep enough using Poisson gradient amplification.
void recast_cliff_directional (Array &array, float talus, int ir, float amplitude, float angle, const Array *p_mask, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void recast_cliff_directional (Array &array, float talus, int ir, float amplitude, const Array &angle, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void recast_cliff_directional (Array &array, float talus, int ir, float amplitude, const Array &angle, const Array *p_mask, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 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)
 See hmap::ridge_accentuate.
void ridge_accentuate (Array &array, const Array *p_mask, float strength=0.1f, int ir=0, bool reverse=false)
 See hmap::ridge_accentuate.
void shrink (Array &array, int ir, int iterations=1)
 See hmap::shrink.
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 smooth_cpulse (Array &array, int ir, const Array *p_mask=nullptr, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 See hmap::smooth_cpulse.
void smooth_cpulse_edge_removing (Array &array, float talus, float talus_width, int ir)
 See hmap::smooth_cpulse_edge_removing.
void smooth_fill (Array &array, int ir, float k=0.1f, Array *p_deposition_map=nullptr)
 See hmap::smooth_fill.
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)
 See hmap::smooth_fill_holes.
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)
 See hmap::smooth_fill_smear_peaks.
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.
Array spectral_equalizer (const Array &array, const std::vector< float > &weights, int ir_min, int ir_max)
 Spectral equalizer for 2D fields using a multiscale Gaussian pyramid.
Array spectral_equalizer (const Array &array, const std::vector< float > &weights, int ir_min, int ir_max, 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.
Array voronoi_shrink (const Array &array, glm::vec2 kw, float shrink_factor=0.8f, float fill_value=0.f, std::uint32_t seed=0, glm::vec2 jitter={0.5f, 0.5f}, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Apply a Voronoi shrinker filter to an input heightmap.
Array voronoi_shrink (const Array &array, float kw, float shrink_factor=0.8f, float fill_value=0.f, std::uint32_t seed=0, glm::vec2 jitter={0.5f, 0.5f}, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Apply a Voronoi shrinker filter using an isotropic frequency.
Array voronoi_shrink (const Array &array, const Cloud &cloud, float shrink_factor=0.8f, float fill_value=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Apply a Voronoi shrinker filter using a custom cloud of points.
Array voronoi_shrink (const Array &array, const std::vector< Point > &points, float shrink_factor=0.8f, float fill_value=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Apply a Voronoi shrinker filter using a list of Point objects.
Array voronoi_shrink (const Array &array, const std::vector< glm::vec2 > &points, float shrink_factor=0.8f, float fill_value=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Apply a Voronoi shrinker filter using a list of glm::vec2 coordinates.
Array path_sdf_bezier_to_array (const Path &path, glm::ivec2 shape, const UvRect &uv_rect_array=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr)
 See hmap::path_sdf_bezier_to_array.
Array path_sdf_to_array (const Path &path, glm::ivec2 shape, const UvRect &uv_rect_array=UvRect::unit(), const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr)
 See hmap::path_sdf_to_array.
Array gradient_angle_circular_smoothing (const Array &array, int ir, bool downward=false)
 See hmap::gradient_angle_circular_smoothing.
Array laplacian_fract (const Array &array, float s, int ir)
 Compute the fractional Laplacian of an array.
void phase_averaging (Array &field_real, Array &field_imag, int ir)
 Apply phase averaging on real and imaginary fields using a GPU kernel.
Array phase_field (const Array &array, const glm::vec2 &kw, std::uint32_t seed, float kp, bool rotate90=false, float normalization=1.f, const glm::vec2 &jitter={0.5f, 0.5f}, int angle_filter_ir=8, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_modulus=nullptr, Array *p_angle_jump_mask=nullptr, const UvRect &uv_rect=UvRect::unit())
 Compute a phase field from an input array using local orientation and noise.
Array phase_field (const Array &array, std::uint32_t seed, float kp_global, bool rotate90=false, float normalization=1.f, const glm::vec2 &jitter={0.5f, 0.5f}, int angle_filter_ir=8, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_modulus=nullptr, Array *p_angle_jump_mask=nullptr, const UvRect &uv_rect=UvRect::unit())
 Compute a phase field using a global isotropic kp value.
Array phase_field_angle (const Array &angle, const glm::vec2 &kw, std::uint32_t seed, float kp, float normalization=1.f, const glm::vec2 &jitter={0.5f, 0.5f}, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_modulus=nullptr, Array *p_angle_jump_mask=nullptr, const UvRect &uv_rect=UvRect::unit())
Array coastal_fetch (const Array &z, int ndirections, const Array *p_compute_mask=nullptr)
 Computes the omnidirectional coastal fetch for each cell.
Array 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 flow_accumulation_from_velocity_field (const Array &u, const Array &v, int iterations)
 Approximates flow accumulation from a 2D velocity field.
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)
 GPU (OpenCL) variant of hmap::flow_accumulation_stochastic — see the CPU declaration for the algorithm description and parameters.
Array flow_direction_d8 (const Array &z)
 See hmap::flow_direction_d8.
Array 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 &region=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 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 &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 GPU viscous shallow-water flow simulation using non-linear thin-film diffusion with upwind mobility.
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)
 See hmap::generate_riverbed.
Array 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 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 &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 Simulate snow accumulation and redistribution over a terrain.
void 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 water_frontier_curvature (const Array &water_depth, int prefilter_ir, bool extend_values_from_interface=false)
 See hmap::water_frontier_curvature.
Array 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.
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 &region=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance(), const Array *p_rhs=nullptr, bool fix_domain_borders=true)
 Perform harmonic interpolation on GPU using Red-Black Successive Over-Relaxation (RB-SOR).
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 &region=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance())
 Perform harmonic interpolation on GPU with 2D variable diffusion coefficients (Dx, Dy) using Red-Black SOR.
Array biharmonic_interpolation (const Array &array, const Array &mask_fixed_values, int iterations_max=1000, float tolerance=1e-5f, float omega=0.5f, int sync_interval=0, const UvTile &region=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance())
void interpolate_array_bicubic (const Array &source, Array &target)
void interpolate_array_bicubic (const Array &source, Array &target, const UvRect &uv_rect_source, const UvRect &uv_rect_target)
void interpolate_array_bilinear (const Array &source, Array &target)
void interpolate_array_bilinear (const Array &source, Array &target, const UvRect &uv_rect_source, const UvRect &uv_rect_target)
void interpolate_array_lagrange (const Array &source, Array &target, int order)
void interpolate_array_nearest (const Array &source, Array &target)
void interpolate_array_nearest (const Array &source, Array &target, const UvRect &uv_rect_source, const UvRect &uv_rect_target)
Array local_aspect_variance (const Array &array, int ir)
 Compute the average local aspect variance of an array.
Array local_max (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 Compute the local maximum using the specified kernel footprint.
Array local_max_disk (const Array &array, int ir)
 Compute the local maximum using a disk kernel.
Array local_max_octagon (const Array &array, int ir)
 Compute the local maximum using an octagonal kernel approximation via 4 separable 1D passes (horizontal, vertical, and two diagonals).
Array local_max_square (const Array &array, int ir)
 Compute the local maximum using a square kernel with a 2-pass separable implementation.
Array local_median_deviation (const Array &array, int ir)
 See hmap::local_median_deviation.
Array local_min (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 Compute the local minimum using the specified kernel footprint.
Array local_min_disk (const Array &array, int ir)
 Compute the local minimum using a disk kernel.
Array local_min_octagon (const Array &array, int ir)
 Compute the local minimum using an octagonal kernel approximation via 4 separable 1D passes (horizontal, vertical, and two diagonals).
Array local_min_square (const Array &array, int ir)
 Compute the local minimum using a square kernel with a 2-pass separable implementation.
Array local_relief (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 Compute the local relief of an array.
Array local_variance (const Array &array, int ir)
 Compute the average local variance of an array.
Array local_mean (const Array &array, int ir)
 See hmap::local_mean.
Array local_skewness (const Array &array, int ir)
Array local_z_score (const Array &array, int ir)
 Compute the local z-score of an array.
Array topographic_position_index (const Array &array, int ir)
 Compute the Topographic Position Index (TPI).
Array relative_elevation (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::relative_elevation.
Array relative_elevation_square_kernel (const Array &array, int ir)
 See hmap::relative_elevation.
Array roughness (const Array &array, int ir)
 See hmap::roughness.
Array ruggedness (const Array &array, int ir)
 See hmap::ruggedness.
Array rugosity (const Array &z, int ir, bool convex=true)
 See hmap::rugosity.
Array topographic_residual (const Array &z, int ir, bool normalize_output=false)
 See hmap::topographic_residual.
Array valley_width (const Array &z, int ir=0, bool ridge_select=false)
 See hmap::valley_width.
Array local_metrics (const Array &array, int ir, LocalMetrics metric, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 Compute a local metric on the input array using a square neighborhood.
Array sparse_max_convolution (const Array &array, const Array &kernel, bool scale_kernel_with_value=true, float k_smoothmax=0.f)
 Apply a sparse max-convolution.
Array sparse_max_convolution (const Array &array_values, const Array &array_sizes, const Array &kernel, float k_smoothmax=0.f)
Array border (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::border.
Array closing (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::closing.
Array closing_by_reconstruction (const Array &array, int ir, float k_smooth_max=0.f, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::closing_by_reconstruction.
Array contour_smoothing (const Array &array, int ir, float transition_ratio=0.1f)
 See hmap::contour_smoothing.
Array dilation (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::dilation.
Array dilation_expand_border_only (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::dilation_expand_border_only.
Array distance_transform_jfa (const Array &array, bool return_squared_distance=false)
 Return the Euclidean distance transform.
Array erosion (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::erosion.
Array morphological_black_hat (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::morphological_black_hat.
Array morphological_gradient (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::morphological_gradient.
Array morphological_laplacian (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::morphological_laplacian.
Array morphological_top_hat (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::morphological_top_hat.
Array opening (const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::opening.
Array opening_by_reconstruction (const Array &array, int ir, float k_smooth_min=0.f, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::opening_by_reconstruction.
Array reconstruction_by_dilation (const Array &marker, const Array &mask, int ir, float k_smooth_min=0.f, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::reconstruction_by_dilation.
Array reconstruction_by_erosion (const Array &marker, const Array &mask, int ir, float k_smooth_max=0.f, MinMaxKernel kernel_type=MinMaxKernel::DISK)
 See hmap::reconstruction_by_erosion.
Array relative_distance_from_skeleton (const Array &array, int ir_search, bool zero_at_borders=true, int ir_erosion=1)
 See hmap::relative_distance_from_skeleton.
Array relative_distance_from_skeleton (const Array &array, const Array &skeleton, int ir_search, int ir_erosion=1)
 See hmap::relative_distance_from_skeleton.
Array signed_curvature_from_distance (const Array &array, int prefilter_ir=0)
 See hmap::signed_curvature_from_distance.
Array signed_distance_transform (const Array &array, int prefilter_ir=0)
 See hmap::signed_distance_transform.
Array skeleton (const Array &array, bool zero_at_borders=true)
 See hmap::skeleton.
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.
void helper_bind_optional_buffer (clwrapper::Run &run, const std::string &id, const Array *p_array)
bool init_opencl ()
Array gabor_wave (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, const Array &angle, float angle_spread_ratio=1.f, const UvRect &uv_rect=UvRect::unit())
 Return an array filled with coherence Gabor noise.
Array gabor_wave (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float angle=0.f, float angle_spread_ratio=1.f, const UvRect &uv_rect=UvRect::unit())
Array gabor_wave_fbm (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, const Array &angle, float angle_spread_ratio=1.f, 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())
 Return an array filled with coherence Gabor noise.
Array gabor_wave_fbm (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float angle=0.f, float angle_spread_ratio=1.f, 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())
Array gavoronoise (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, const Array &angle, float amplitude=0.05f, float angle_spread_ratio=1.f, glm::vec2 kw_multiplier={4.f, 4.f}, float slope_strength=1.f, float branch_strength=2.f, float z_cut_min=0.2f, float z_cut_max=1.f, int octaves=8, float persistence=0.4f, 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())
 Generates a 2D array using the GavoroNoise algorithm, which is a procedural noise technique for terrain generation and other applications.
Array gavoronoise (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float angle=0.f, float amplitude=0.05f, float angle_spread_ratio=1.f, glm::vec2 kw_multiplier={4.f, 4.f}, float slope_strength=1.f, float branch_strength=2.f, float z_cut_min=0.2f, float z_cut_max=1.f, int octaves=8, float persistence=0.4f, 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())
Array gavoronoise (const Array &base, glm::vec2 kw, std::uint32_t seed, float amplitude=0.05f, glm::vec2 kw_multiplier={4.f, 4.f}, float slope_strength=1.f, float branch_strength=2.f, float z_cut_min=0.2f, float z_cut_max=1.f, int octaves=8, float persistence=0.4f, 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())
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(), glm::ivec2 period={0, 0}, float angle=0.f, float stretch=1.f)
 See hmap::noise. period sets the tiling period in lattice cells. For the heightmap to be periodic with respect to the full domain, period must be equal to the wavenumber kw, i.e. period = {round(kw.x), round(kw.y)}; a smaller period makes the pattern repeat within the domain. A component <= 0 disables wrapping on that axis (default {0, 0}: non-periodic). Tiling is exact only for lattice noise types with integer kw; simplex is never wrapped.
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(), glm::ivec2 period={0, 0}, float angle=0.f, float stretch=1.f, float stretch_decay=0.f)
 See hmap::noise_fbm. period sets the tiling period in lattice cells for the base octave. For the heightmap to be periodic with respect to the full domain, period must be equal to the wavenumber kw, i.e. period = {round(kw.x), round(kw.y)}; a smaller period makes the pattern repeat within the domain. A component <= 0 disables wrapping on that axis (default {0, 0}: non-periodic). Seamless tiling additionally requires an integer lacunarity (the default 2); simplex is never wrapped.
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(), glm::ivec2 period={0, 0}, float angle=0.f, float stretch=1.f, float stretch_decay=0.f)
 See hmap::noise_slope. period sets the tiling period in lattice cells for the base octave.
Array phasor (PhasorProfile phasor_profile, glm::ivec2 shape, float kp_global, std::uint32_t seed, float angle_shift=0.f, float normalization=1.f, const glm::vec2 jitter={1.f, 1.f}, float delta=0.01f, float phase_smoothing=10.f, const Array *p_angle=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a procedural phasor-based pattern.
Array phasor_fbm (PhasorProfile phasor_profile, glm::ivec2 shape, float kp_global, std::uint32_t seed, float angle_shift=0.f, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, float normalization=1.f, const glm::vec2 jitter={1.f, 1.f}, float delta=0.01f, float phase_smoothing=10.f, const Array *p_angle=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a multi-octave (fBm) phasor-based pattern.
Array vorolines (glm::ivec2 shape, float density, std::uint32_t seed, float k_smoothing=0.f, float exp_sigma=0.f, float alpha=0.f, float alpha_span=cte::pi, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), const UvRect &uv_rect_points=UvRect::unit())
 Generates a Voronoi-based pattern where cells are defined by proximity to random lines.
Array vorolines_fbm (glm::ivec2 shape, float density, std::uint32_t seed, float k_smoothing=0.f, float exp_sigma=0.f, float alpha=0.f, float alpha_span=cte::pi, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), const UvRect &uv_rect_points=UvRect::unit())
 Generates a Voronoi-based pattern using distances to lines defined by random points and angles, with additional fractal Brownian motion (fBm) noise modulation.
Array voronoi (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, glm::vec2 jitter={0.5f, 0.5f}, float bias=0.f, float k_smoothing=0.f, float exp_sigma=0.f, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, 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 Voronoi diagram in a 2D array with configurable properties.
Array voronoi_fbm (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, glm::vec2 jitter={0.5f, 0.5f}, float bias=0.f, float k_smoothing=0.f, float exp_sigma=0.f, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, 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())
 Generates a Voronoi diagram in a 2D array with configurable properties.
Array voronoi_edge_distance (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, glm::vec2 jitter={0.5f, 0.5f}, float bias=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())
 Computes the Voronoi edge distance.
Array voronoise (glm::ivec2 shape, glm::vec2 kw, float u_param, float v_param, std::uint32_t seed, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a 2D Voronoi noise array.
Array voronoise_fbm (glm::ivec2 shape, glm::vec2 kw, float u_param, float v_param, 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())
 Return an array filled with coherence Voronoise.
Array vororand (glm::ivec2 shape, float density, float variability, std::uint32_t seed, float k_smoothing=0.f, float exp_sigma=0.f, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), const UvRect &uv_rect_points=UvRect::unit())
 Generates a 2D Voronoi-based scalar field using OpenCL.
Array vororand (glm::ivec2 shape, const std::vector< float > &xp, const std::vector< float > &yp, float k_smoothing=0.f, float exp_sigma=0.f, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Array wavelet_noise (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float kw_multiplier=2.f, float vorticity=0.f, float density=1.f, 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())
 Generates 2D wavelet noise using an OpenCL kernel.
Array hemisphere_field (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float rmin=0.05f, float rmax=0.8f, float amplitude_random_ratio=1.f, float density=0.1f, glm::vec2 jitter={1.f, 1.f}, float shift=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_noise_distance=nullptr, const Array *p_density_multiplier=nullptr, const Array *p_size_multiplier=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a scalar field representing the signed distance to randomly generated hemispheres.
Array hemisphere_field_fbm (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float rmin=0.05f, float rmax=0.8f, float amplitude_random_ratio=1.f, float density=0.1f, glm::vec2 jitter={0.5f, 0.5f}, float shift=0.1f, int octaves=8, float persistence=0.5f, float lacunarity=2.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_noise_distance=nullptr, const Array *p_density_multiplier=nullptr, const Array *p_size_multiplier=nullptr, const UvRect &uv_rect=UvRect::unit())
 See hmap::hemisphere_field.
Array multisteps (glm::ivec2 shape, float angle, std::uint32_t seed, glm::vec2 kw={2.f, 2.f}, float noise_amp=0.1f, float noise_rugosity=0.f, bool noise_inflate=true, 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 glm::vec2 &center={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit())
 GPU-accelerated multi-step height generation with procedural noise.
Array polygon_field (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float rmin=0.05f, float rmax=0.8f, float clamping_dist=0.1f, float clamping_k=0.1f, int n_vertices_min=3, int n_vertices_max=16, float density=0.5f, glm::vec2 jitter={0.5f, 0.5f}, float shift=0.1f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_noise_distance=nullptr, const Array *p_density_multiplier=nullptr, const Array *p_size_multiplier=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a scalar field representing the signed distance to randomly generated polygons.
Array polygon_field_fbm (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float rmin=0.05f, float rmax=0.8f, float clamping_dist=0.1f, float clamping_k=0.1f, int n_vertices_min=3, int n_vertices_max=16, float density=0.1f, glm::vec2 jitter={0.5f, 0.5f}, float shift=0.1f, int octaves=8, float persistence=0.5f, float lacunarity=2.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_noise_distance=nullptr, const Array *p_density_multiplier=nullptr, const Array *p_size_multiplier=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a scalar field representing the signed distance to randomly generated polygons combined with fractal Brownian motion (fBm) noise modulation.
Array badlands (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, int octaves=8, float rugosity=0.2f, float angle=30.f, float bias=0.f, float k_smoothing=0.1f, float base_noise_amp=0.2f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a synthetic "badlands" terrain heightmap.
Array basalt_field (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float warp_kw=4.f, float large_scale_warp_amp=0.2f, float large_scale_gain=6.f, float large_scale_amp=0.2f, float medium_scale_kw_ratio=3.f, float medium_scale_warp_amp=1.f, float medium_scale_gain=7.f, float medium_scale_amp=0.08f, float small_scale_kw_ratio=10.f, float small_scale_amp=0.1f, float small_scale_overlay_amp=0.002f, float rugosity_kw_ratio=1.f, float rugosity_amp=1.f, bool flatten_activate=true, float flatten_kw_ratio=1.f, float flatten_amp=0.f, float bias=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a synthetic procedural terrain resembling basaltic landforms.
Array island (const Array &land_mask, const Array *p_noise_r=nullptr, float apex_elevation=1.f, bool filter_distance=true, int filter_ir=32, float slope_min=0.1f, float slope_max=8.f, float slope_start=0.5f, float slope_end=1.f, float slope_noise_intensity=0.5f, float k_smooth=0.05f, float radial_noise_intensity=0.3f, float radial_profile_gain=2.f, float water_decay=0.05f, float water_depth=0.3f, float lee_angle=30.f, float lee_amp=0.f, float uplift_amp=0.f, Array *p_water_depth=nullptr, Array *p_inland_mask=nullptr)
 Generates an island heightmap from a land mask using radial profiles, slope shaping, optional noise, and water attenuation.
Array island (const Array &land_mask, std::uint32_t seed, float noise_amp=0.07f, glm::vec2 noise_kw={4.f, 4.f}, int noise_octaves=8, float noise_rugosity=0.7f, float noise_angle=45.f, float noise_k_smoothing=0.05f, float apex_elevation=1.f, bool filter_distance=true, int filter_ir=32, float slope_min=0.1f, float slope_max=8.f, float slope_start=0.5f, float slope_end=1.f, float slope_noise_intensity=0.5f, float k_smooth=0.05f, float radial_noise_intensity=0.3f, float radial_profile_gain=2.f, float water_decay=0.05f, float water_depth=0.3f, float lee_angle=30.f, float lee_amp=0.f, float uplift_amp=0.f, Array *p_water_depth=nullptr, Array *p_inland_mask=nullptr)
 Generates an island heightmap from a land mask using internally generated FBM noise for radial perturbation and slope modulation.
Array mountain_cone (glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=4.f, float rugosity=0.f, float angle=45.f, float bias=0.f, float k_smoothing=0.f, float gamma=0.5f, float cone_alpha=1.f, float ridge_amp=0.4f, float base_noise_amp=0.05f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a procedural "mountain cone" heightmap using fractal noise and Voronoi patterns.
Array mountain_inselberg (glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float rugosity=0.2f, float angle=45.f, float gamma=1.1f, bool round_shape=false, bool add_deposition=true, float bulk_amp=0.2f, float base_noise_amp=0.2f, float bias=0.f, float k_smoothing=0.1f, 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 mountain-like inselberg (isolated hill) heightmap.
Array mountain_range_radial (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float half_width=0.2f, float angle_spread_ratio=0.5f, float core_size_ratio=1.f, glm::vec2 center={0.5f, 0.5f}, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_angle=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a heightmap representing a radial mountain range.
Array mountain_stump (glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=6.f, float rugosity=0.f, float angle=45.f, float k_smoothing=0.f, float gamma=0.25f, bool add_deposition=true, float ridge_amp=0.75f, float base_noise_amp=0.1f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a mountain-like heightmap with a flattened (stump-shaped) peak.
Array mountain_tibesti (glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=20.f, float rugosity=0.f, float angle=30.f, float angle_spread_ratio=0.25f, float gamma=1.f, bool add_deposition=true, float bulk_amp=1.f, float base_noise_amp=0.1f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
 Generates a synthetic "Tibesti" mountain heightmap.
Array plates (glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float talus, int direction=0, float mix_ratio=0.9f, float bias=0.f, float base_noise_amp=0.05f, float kw_multiplier=2.f, int octaves=8, float rugosity=0.f, const UvRect &uv_rect=UvRect::unit())
 Generate a tectonic plate–like heightfield using Voronoi FBM and directional talus projection.
Array shattered_peak (glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=4.f, float rugosity=0.f, float angle=30.f, float gamma=1.f, bool add_deposition=true, float bulk_amp=0.3f, float base_noise_amp=0.1f, float bias=0.f, float k_smoothing=0.f, 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 "shattered peak" terrain heightmap.
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)
 See hmap::sdf_2d_polyline.
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)
 See hmap::sdf_2d_polyline_bezier.
Array select_cavities (const Array &array, int ir, bool concave=true, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
 See hmap::select_cavities.
Array select_soil_flow (const Array &z, int ir_gradient=1, float gradient_weight=1.f, float gradient_scaling_factor=0.f, float flow_weight=0.05f, float talus_ref=0.f, float clipping_ratio=50.f, float flow_gamma=1.f, float k_smooth=0.01f, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
 Computes a soil–flow selection map based on terrain gradient, river mask, and smoothing parameters.
Array select_soil_rocks (const Array &z, int ir_max=64, int ir_min=0, int steps=4, float smaller_scales_weight=1.f, ClampMode curvature_clamp_mode=ClampMode::POSITIVE_ONLY, float curvature_clamping=1.f, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
 Computes a multi-scale soil/rock selector using curvature analysis.
Array select_soil_weathered (const Array &z, int ir_curvature=0, int ir_gradient=4, ClampMode curvature_clamp_mode=ClampMode::POSITIVE_ONLY, float curvature_clamping=10.f, float curvature_weight=1.f, float gradient_weight=1.f, float gradient_scaling_factor=0.f, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
 Computes a soil weathering selection map based on curvature and gradient analysis.
Array select_soil_weathered (const Array &z, const Array &gradient_norm, int ir_curvature, ClampMode curvature_clamp_mode, float curvature_clamping, float curvature_weight, float gradient_weight, float gradient_scaling_factor, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Array select_slope (const Array &z, int ir=0, bool normalize=false, MinMaxKernel kernel_type=MinMaxKernel::OCTAGON, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
 Selects terrain slope.
Array select_valley (const Array &z, int ir, bool ridge_select=false, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
 See hmap::select_valley.
void fill_masked_holes (Array &z, const Array &mask, int iterations_max=500, float tolerance=1e-5f, float omega=0.f, float detail_amplitude=1.f, int patch_size=16, std::uint32_t seed=0, int sync_interval=1, const UvTile &region=UvTile::unit(), ICommunicator &comm=SingleArrayComm::instance())
 Fill masked holes in a heightmap by reconstructing the masked regions from the surrounding terrain using GPU biharmonic interpolation.
Array advection_particle (const Array &z, const Array &advected_field, int iterations, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 Performs particle-based advection on a scalar field.
std::vector< Array > advection_particle (const Array &z, const std::vector< const Array * > &advected_fields, int iterations, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::vector< Array > advection_particle (const Array &z, const std::vector< Array > &advected_fields, int iterations, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array advection_particle (const Array &z, const Array &advected_field, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::vector< Array > advection_particle (const Array &z, const std::vector< const Array * > &advected_fields, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::vector< Array > advection_particle (const Array &z, const std::vector< Array > &advected_fields, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array advection_particle (const Array &dx, const Array &dy, const Array &advected_field, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::vector< Array > advection_particle (const Array &dx, const Array &dy, const std::vector< const Array * > &advected_fields, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::vector< Array > advection_particle (const Array &dx, const Array &dy, const std::vector< Array > &advected_fields, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Texture advection_particle (const Array &z, const Texture &texture, int iterations, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Texture advection_particle (const Array &z, const Texture &texture, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Array advection_particle_multiscale (const Array &z, const Array &advected_field, std::uint32_t seed, const std::vector< int > &steps_per_level={4, 2, 1}, float particles_ratio=0.5f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, float mix=1.f, float warp=0.f, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 Performs multiscale particle-based advection on a scalar field.
std::vector< Array > advection_particle_multiscale (const Array &z, const std::vector< const Array * > &advected_fields, std::uint32_t seed, const std::vector< int > &steps_per_level={4, 2, 1}, float particles_ratio=0.5f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, float mix=1.f, float warp=0.f, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
std::vector< Array > advection_particle_multiscale (const Array &z, const std::vector< Array > &advected_fields, std::uint32_t seed, const std::vector< int > &steps_per_level={4, 2, 1}, float particles_ratio=0.5f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, float mix=1.f, float warp=0.f, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Texture advection_particle_multiscale (const Array &z, const Texture &texture, std::uint32_t seed, const std::vector< int > &steps_per_level={4, 2, 1}, float particles_ratio=0.5f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, float mix=1.f, float warp=0.f, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void rotate (Array &array, float angle, bool zoom_in=true)
 See hmap::rotate.
void warp (Array &array, const Array *p_dx, const Array *p_dy)
 See hmap::warp.
float helper_vflow_compute_adaptive_dt (const Array &h, float viscosity, float power)
glm::vec4 helper_transform_bbox (const UvRect &uv_rect_source, const UvRect &uv_rect_target)
void helper_bind_optional_buffers (clwrapper::Run &run, const Array *p_noise_x, const Array *p_noise_y)
float helper_radial_profile (float r, float slope_start, float slope_end, float apex_elevation, float k_smooth, float radial_gain)
float helper_apply_leeward (float h, float r, float hs, float slope_max, float k_smooth, float lee_amp, float alpha, float lee_alpha)
float helper_apply_uplift (float h, float r, float slope_max, float uplift_amp, float k_smooth)

Enumeration Type Documentation

◆ LocalMetrics

Types of local metrics.

Enumerator
LM_LOCAL_ASPECT_VARIANCE 

Variance of local slope directions.

LM_LOCAL_MAX 

Local maximum value.

LM_LOCAL_MEDIAN_DEVIATION 

Deviation from local median.

LM_LOCAL_MIN 

Local minimum value.

LM_LOCAL_RELIEF 

Diff. between local max & min.

LM_LOCAL_VARIANCE 

Variance of local values.

LM_LOCAL_MEAN 

Mean of local values.

LM_LOCAL_SKEWNESS 

Skewness.

LM_LOCAL_Z_SCORE 

Standardized value.

LM_TOPOGRAPHIC_POSITION_INDEX 

Topographic index.

LM_TOPOGRAPHIC_WETNESS_INDEX 

Topographic wetness index.

LM_RELATIVE_ELEVATION 

Normalized elevation.

LM_ROUGHNESS 

Local terrain roughness.

LM_RUGGEDNESS 

Measure of terrain roughness.

LM_RUGOSITY_CONCAVE 

Roughness of concave features.

LM_RUGOSITY_CONVEX 

Roughness of convex features.

LM_TOPOGRAPHIC_RESIDUAL 

Deviation from smoothed surface.

Function Documentation

◆ blend_gradients()

Array hmap::gpu::blend_gradients ( const Array & array1,
const Array & array2,
int ir = 4 )

◆ blend_poisson_bf() [1/2]

Array hmap::gpu::blend_poisson_bf ( const Array & array1,
const Array & array2,
const int iterations = 500,
const Array * p_mask = nullptr )

Blends two arrays using Poisson blending with a brute-force solver.

This function performs Poisson blending between array1 and array2 over a specified number of iterations. Optionally, a mask can be provided to control the blending regions.

Parameters
array1The first input array.
array2The second input array.
iterationsThe number of iterations for the blending process (default: 500).
p_maskOptional pointer to an array defining the blending mask. If null, blending is applied globally.
Returns
The blended array resulting from the Poisson blending operation.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 2;
shape,
2.f * kw,
++seed);
int iterations = 5000;
hmap::Array z3 = hmap::gpu::blend_poisson_bf(z1, z2, iterations);
hmap::export_banner_png("ex_blend_poisson_bf.png",
{z1, z2, z3},
}
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:31
int main(int argc, char **argv)
Definition main.cpp:12
Array blend_poisson_bf(const Array &array1, const Array &array2, const int iterations=500, const Array *p_mask=nullptr)
Blends two arrays using Poisson blending with a brute-force solver.
Definition blending_gpu.cpp:41
bool init_opencl()
Definition gpu_opencl.cpp:33
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.
Definition noise.cpp:78
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.
Definition range.cpp:434
@ WORLEY
Worley.
Definition functions.hpp:78
@ PERLIN
Perlin.
Definition functions.hpp:69
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.
Definition export_banner_png.cpp:18
@ JET
Definition colormaps.hpp:88

Result

◆ blend_poisson_bf() [2/2]

Texture hmap::gpu::blend_poisson_bf ( const Texture & texture1,
const Texture & texture2,
const int iterations = 500,
const Array * p_mask = nullptr )

Blends two textures using Poisson blending with a brute-force solver.

This function performs Poisson blending between texture1 and texture2 channel by channel over a specified number of iterations. Optionally, a mask can be provided to control the blending regions.

Parameters
texture1The first input texture.
texture2The second input texture.
iterationsThe number of iterations for the blending process (default: 500).
p_maskOptional pointer to an array defining the blending mask. If null, blending is applied globally.
Returns
The blended texture resulting from the Poisson blending operation.

◆ transfer()

Array hmap::gpu::transfer ( const Array & source,
const Array & target,
int ir,
float amplitude,
bool target_prefiltering = false )

◆ level_set_curvature()

Array hmap::gpu::level_set_curvature ( const Array & array,
int prefilter_ir )

◆ curvature_quadric()

Array hmap::gpu::curvature_quadric ( const Array & z,
int ir,
CurvatureType curvature_type,
bool approx_algo = false )

◆ hydraulic_musgrave() [1/2]

void hmap::gpu::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) on GPU.

Example

#include "highmap.hpp"
int main(void)
{
"hydraulic_musgrave is deprecated and will be removed at some point.");
glm::ivec2 shape = {256, 256};
glm::vec2 res = {4.f, 4.f};
int seed = 1;
auto z0 = z;
hmap::export_banner_png("ex_hydraulic_musgrave.png",
{z0, z},
true);
}
void warn(Args &&...args)
Definition logger.hpp:48
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).
Definition hydraulic_musgrave.cpp:21
@ TERRAIN
Definition colormaps.hpp:93

Result

◆ hydraulic_musgrave() [2/2]

void hmap::gpu::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.

◆ deposition_fill_holes() [1/2]

void hmap::gpu::deposition_fill_holes ( Array & z,
int deposition_ir,
float deposition_strength,
int iterations = 1 )

Fill holes using Gaussian-based deposition.

Applies a smoothing/deposition pass that fills local depressions while preserving overall terrain shape through gradient-aware blending.

Parameters
zHeightmap to modify (in-place).
deposition_irInfluence radius of the Gaussian filter.
deposition_strengthBlending factor controlling deposition intensity.
iterationsNumber of successive deposition passes.

◆ deposition_fill_holes() [2/2]

void hmap::gpu::deposition_fill_holes ( Array & z,
int deposition_ir,
float deposition_strength,
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.

◆ hydraulic_particle() [1/2]

void hmap::gpu::hydraulic_particle ( Array & z,
int nparticles,
std::uint32_t seed,
const Array * p_bedrock = nullptr,
const Array * p_erodibility = nullptr,
const Array * p_moisture_map = nullptr,
const Array * p_elevation_shift = 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.01f,
float c_gravity = 1.f,
float drag_rate = 0.001f,
float evap_rate = 0.001f,
float talus_slope = 2.f,
float collapse_rate = 0.1f,
int iterations = 1 )

Simulates hydraulic erosion on a heightmap using particle-based flow.

Particles traverse the heightmap z, eroding and depositing material according to local slope, capacity, inertia, and optional directional bias.

Parameters
zHeightmap array to modify.
nparticlesNumber of erosion particles to simulate.
seedRandom seed for particle initialization.
p_bedrockOptional bedrock array to limit erosion.
p_erodibilityOptional spatial erodibility multiplier array.
p_moisture_mapOptional moisture map affecting erosion/deposition.
p_elevation_shiftOptional elevation shift map.
p_erosion_mapOptional output array recording total erosion.
p_deposition_mapOptional output array recording deposition.
c_capacitySediment capacity of each particle.
c_erosionErosion rate coefficient.
c_depositionDeposition rate coefficient.
c_inertiaParticle inertia factor.
c_gravityGravity effect on particle movement.
drag_rateParticle velocity damping per step.
evap_rateSediment evaporation rate.
talus_slopeTalus slope angle.
collapse_rateCollapse rate.
iterationsNumber of multi-pass iterations.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {1024, 1024};
glm::vec2 kw = {4.f, 4.f};
int seed = 0;
shape,
kw,
seed,
8,
0.f);
int nparticles = int(0.5f * shape.x * shape.y);
auto z1 = z0;
nparticles,
seed,
/* p_bedrock */ nullptr,
/* p_erodibility */ nullptr,
/* p_moisture_map */ nullptr,
/* p_elevation_shift */ nullptr,
/* p_erosion_map */ nullptr,
/* p_deposition_map */ nullptr,
/* c_capacity */ 10.f,
/* c_erosion */ 0.1f,
/* c_deposition */ 0.1f,
/* c_gravity */ 1.f,
/* drag_rate */ 0.001f,
/* evap_rate */ 0.001f,
/* talus_slope */ 2.f,
/* collapse_rate */ 0.25f,
/* iterations */ 1);
z1.dump();
auto z2 = z0;
auto zb2 = hmap::generate_bedrock(z2,
/* elevation_strength */ 0.05f,
/* slope_strength */ 0.f,
/* slope_limit */ 0.f);
hmap::gpu::hydraulic_particle(z2, nparticles, seed, &zb2);
auto z3 = z0;
auto zb3 = hmap::generate_bedrock(z3,
/* elevation_strength */ 0.f,
/* slope_strength */ 0.1f,
/* slope_limit */ 2.f / shape.x);
hmap::gpu::hydraulic_particle(z3, nparticles, seed, &zb3);
auto z4 = z0;
z4,
seed,
/* steps_per_level */ {16, 8, 4, 2, 1},
/* p_bedrock */ nullptr,
/* p_erodibility */ nullptr,
/* p_moisture_map */ nullptr,
/* p_elevation_shift */ nullptr,
/* p_erosion_map */ nullptr,
/* p_deposition_map */ nullptr,
/* particles_ratio */ 0.5f,
/* c_capacity */ 10.f,
/* c_erosion */ 0.05f,
/* c_deposition */ 0.05f,
/* c_inertia */ 0.0f,
/* c_gravity */ 1.f,
/* drag_rate */ 0.001f,
/* evap_rate */ 0.001f,
/* talus_slope */ 2.f,
/* collapse_rate */ 0.25f,
/* mix */ 0.8f);
// --- output
z0.dump("out0.png");
z1.dump("out1.png");
z2.dump("out2.png");
z3.dump("out3.png");
z4.dump("out4.png");
hmap::export_banner_png("ex_hydraulic_particle.png",
{z0, z1, z2, z3, z4},
true);
}
void dump(const std::string &fname="out.png") const
Debug tool, dump some infos and generate an output file (16bits grayscale).
Definition methods.cpp:109
void hydraulic_particle_multiscale(Array &z, std::uint32_t seed, const std::vector< int > &steps_per_level={4, 2, 1}, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, const Array *p_elevation_shift=nullptr, Array *p_erosion_map=nullptr, Array *p_deposition_map=nullptr, float particles_ratio=0.5f, float c_capacity=10.f, float c_erosion=0.05f, float c_deposition=0.05f, float c_inertia=0.01f, float c_gravity=1.f, float drag_rate=0.001f, float evap_rate=0.001f, float talus_slope=2.f, float collapse_rate=0.1f, float mix=1.f, float warp=0.35f)
Multiscale particle-based hydraulic erosion cascade.
Definition hydraulic_particle.cpp:170
void hydraulic_particle(Array &z, int nparticles, std::uint32_t seed, const Array *p_bedrock=nullptr, const Array *p_erodibility=nullptr, const Array *p_moisture_map=nullptr, const Array *p_elevation_shift=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.01f, float c_gravity=1.f, float drag_rate=0.001f, float evap_rate=0.001f, float talus_slope=2.f, float collapse_rate=0.1f, int iterations=1)
Simulates hydraulic erosion on a heightmap using particle-based flow.
Definition hydraulic_particle.cpp:23
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.
Definition bulkify.cpp:11
@ PRIM_CONE_SMOOTH
Definition functions.hpp:27
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.
Definition generate_bedrock.cpp:12

Result

◆ hydraulic_particle() [2/2]

void hmap::gpu::hydraulic_particle ( Array & z,
const Array * p_mask,
int nparticles,
std::uint32_t seed,
const Array * p_bedrock = nullptr,
const Array * p_erodibility = nullptr,
const Array * p_moisture_map = nullptr,
const Array * p_elevation_shift = 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.01f,
float c_gravity = 1.f,
float drag_rate = 0.001f,
float evap_rate = 0.001f,
float talus_slope = 2.f,
float collapse_rate = 0.1f,
int iterations = 1 )

◆ hydraulic_particle_multiscale() [1/2]

void hmap::gpu::hydraulic_particle_multiscale ( Array & z,
std::uint32_t seed,
const std::vector< int > & steps_per_level = {4, 2, 1},
const Array * p_bedrock = nullptr,
const Array * p_erodibility = nullptr,
const Array * p_moisture_map = nullptr,
const Array * p_elevation_shift = nullptr,
Array * p_erosion_map = nullptr,
Array * p_deposition_map = nullptr,
float particles_ratio = 0.5f,
float c_capacity = 10.f,
float c_erosion = 0.05f,
float c_deposition = 0.05f,
float c_inertia = 0.01f,
float c_gravity = 1.f,
float drag_rate = 0.001f,
float evap_rate = 0.001f,
float talus_slope = 2.f,
float collapse_rate = 0.1f,
float mix = 1.f,
float warp = 0.35f )

Multiscale particle-based hydraulic erosion cascade.

Runs particle erosion over a geometric resolution ladder (coarsest first, up to z.shape). Coarse levels carve broad continental valleys and major river corridors, while fine levels carve detailed tributaries and gullies.

Parameters
zHeightmap array to modify.
seedRandom seed.
steps_per_levelNumber of iteration steps per level.
p_bedrockOptional bedrock array.
p_erodibilityOptional spatial erodibility multiplier array.
p_moisture_mapOptional moisture map.
p_elevation_shiftOptional elevation shift map.
p_erosion_mapOptional output erosion map.
p_deposition_mapOptional output deposition map.
particles_ratioParticles per level as a multiple of resolution.
c_capacitySediment capacity factor.
c_erosionErosion rate coefficient.
c_depositionDeposition rate coefficient.
c_inertiaInertia factor.
c_gravityGravity factor.
drag_rateVelocity damping.
evap_rateEvaporation rate.
talus_slopeDomain-normalized talus slope threshold.
collapse_rateBank collapse rate.
mixInterpolation blend factor.
warpDomain warp amplitude during upsampling.

◆ hydraulic_particle_multiscale() [2/2]

void hmap::gpu::hydraulic_particle_multiscale ( Array & z,
const Array * p_mask,
std::uint32_t seed,
const std::vector< int > & steps_per_level = {4, 2, 1},
const Array * p_bedrock = nullptr,
const Array * p_erodibility = nullptr,
const Array * p_moisture_map = nullptr,
const Array * p_elevation_shift = nullptr,
Array * p_erosion_map = nullptr,
Array * p_deposition_map = nullptr,
float particles_ratio = 0.5f,
float c_capacity = 10.f,
float c_erosion = 0.05f,
float c_deposition = 0.05f,
float c_inertia = 0.01f,
float c_gravity = 1.f,
float drag_rate = 0.001f,
float evap_rate = 0.001f,
float talus_slope = 2.f,
float collapse_rate = 0.1f,
float mix = 1.f,
float warp = 0.35f )

◆ hydraulic_mcdonald() [1/2]

void hmap::gpu::hydraulic_mcdonald ( Array & z,
int steps,
std::uint32_t seed,
const McDonaldParams & params,
const Array * p_moisture_map = nullptr,
Array * p_sediment_map = nullptr,
Array * p_discharge_map = nullptr )

Particle-based hydraulic erosion with flow-field coupling (McDonald's model).

Parameters
zInput/output heightmap.
stepsNumber of erosion iterations.
seedRandom seed number.
paramsParameters structure.
p_moisture_mapOptional moisture map.
p_sediment_mapOptional output: final sediment layer.
p_discharge_mapOptional output: water discharge field.

Example

#include <iostream>
#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
// shape = {1024, 1024};
glm::vec2 res = {3.f, 3.f};
int seed = 1;
int steps = 64;
hmap::Array z0 = z;
hmap::Array sediment, discharge;
hmap::gpu::McDonaldParams params = {.strength = 0.5f,
.deposition = 0.5f,
.crit_slope = 0.4f,
.meandering = 1.f,
.scale = 1.f,
.relief_scale = 1.f};
steps,
seed,
params,
nullptr,
&sediment,
&discharge);
// output
{
std::cout << "z min/max: " << z.min() << " " << z.max() << "\n";
std::cout << "discharge min/max: " << discharge.min() << " "
<< discharge.max() << "\n";
z0.to_png("ex_hydraulic_mcdonald0.png", hmap::Cmap::TERRAIN, true);
z.to_png("ex_hydraulic_mcdonald1.png", hmap::Cmap::TERRAIN, true);
}
// log-scale the discharge for visibility (spans orders of magnitude)
{
hmap::Array dlog = discharge;
for (auto &v : dlog.vector)
v = std::log10(1.f + v);
dlog.to_png("ex_hydraulic_mcdonald2.png", hmap::Cmap::HOT);
}
hmap::Array sediment_m, discharge_m;
std::vector<int> steps_per_level = {steps / 4, steps / 2, steps};
seed,
steps_per_level,
params,
nullptr,
&sediment_m,
&discharge_m);
std::cout << "multiscale z min/max: " << zm.min() << " " << zm.max() << "\n";
zm.to_png("ex_hydraulic_mcdonald3.png", hmap::Cmap::TERRAIN, true);
}
void to_png(const std::string &fname, int cmap, bool hillshading=false, int depth=0) const
Export the array as a PNG image file with a specified colormap and hillshading.
Definition io.cpp:132
float min(ICommunicator &comm=SingleArrayComm::instance()) const
Return the value of the smallest element in the array.
Definition methods.cpp:321
std::vector< float > vector
The underlying data storage, a vector of size shape.x * shape.y.
Definition array.hpp:43
float max(ICommunicator &comm=SingleArrayComm::instance()) const
Return the value of the greatest element in the array.
Definition methods.cpp:293
void hydraulic_mcdonald_multiscale(Array &z, std::uint32_t seed, const std::vector< int > &steps_per_level, const McDonaldParams &params, const Array *p_moisture_map=nullptr, Array *p_sediment_map=nullptr, Array *p_discharge_map=nullptr)
Multiscale driver for hydraulic_mcdonald.
Definition hydraulic_mcdonald_gpu.cpp:265
void hydraulic_mcdonald(Array &z, int steps, std::uint32_t seed, const McDonaldParams &params, const Array *p_moisture_map=nullptr, Array *p_sediment_map=nullptr, Array *p_discharge_map=nullptr)
Particle-based hydraulic erosion with flow-field coupling (McDonald's model).
Definition hydraulic_mcdonald_gpu.cpp:168
@ HOT
Definition colormaps.hpp:86
Parameters for McDonald particle-based hydraulic erosion solver.
Definition erosion_parameters.hpp:82

Result

◆ hydraulic_mcdonald() [2/2]

void hmap::gpu::hydraulic_mcdonald ( Array & z,
int steps,
std::uint32_t seed,
const Array * p_moisture_map = nullptr,
Array * p_sediment_map = nullptr,
Array * p_discharge_map = nullptr,
float world_extent_km = 40.f,
float z_scale_km = 4.f,
int samples = 8192,
int maxage = 512,
float lrate = 0.2f,
float time_step = 10.f,
float rainfall = 1.f,
float evap_rate = 1e-4f,
float gravity = 9.81f,
float viscosity = 0.025f,
float bed_shear = 0.01f,
float crit_slope = 0.57f,
float settle_rate = 0.1f,
float thermal_rate = 2.5e-3f,
float deposition_rate = 5e-3f,
float suspension_rate = 2.5e-4f,
float exit_slope = 0.01f )

◆ hydraulic_mcdonald_multiscale() [1/2]

void hmap::gpu::hydraulic_mcdonald_multiscale ( Array & z,
std::uint32_t seed,
const std::vector< int > & steps_per_level,
const McDonaldParams & params,
const Array * p_moisture_map = nullptr,
Array * p_sediment_map = nullptr,
Array * p_discharge_map = nullptr )

Multiscale driver for hydraulic_mcdonald.

Example

#include <iostream>
#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
// shape = {1024, 1024};
glm::vec2 res = {3.f, 3.f};
int seed = 1;
int steps = 64;
hmap::Array z0 = z;
hmap::Array sediment, discharge;
hmap::gpu::McDonaldParams params = {.strength = 0.5f,
.deposition = 0.5f,
.crit_slope = 0.4f,
.meandering = 1.f,
.scale = 1.f,
.relief_scale = 1.f};
steps,
seed,
params,
nullptr,
&sediment,
&discharge);
// output
{
std::cout << "z min/max: " << z.min() << " " << z.max() << "\n";
std::cout << "discharge min/max: " << discharge.min() << " "
<< discharge.max() << "\n";
z0.to_png("ex_hydraulic_mcdonald0.png", hmap::Cmap::TERRAIN, true);
z.to_png("ex_hydraulic_mcdonald1.png", hmap::Cmap::TERRAIN, true);
}
// log-scale the discharge for visibility (spans orders of magnitude)
{
hmap::Array dlog = discharge;
for (auto &v : dlog.vector)
v = std::log10(1.f + v);
dlog.to_png("ex_hydraulic_mcdonald2.png", hmap::Cmap::HOT);
}
hmap::Array sediment_m, discharge_m;
std::vector<int> steps_per_level = {steps / 4, steps / 2, steps};
seed,
steps_per_level,
params,
nullptr,
&sediment_m,
&discharge_m);
std::cout << "multiscale z min/max: " << zm.min() << " " << zm.max() << "\n";
zm.to_png("ex_hydraulic_mcdonald3.png", hmap::Cmap::TERRAIN, true);
}

Result

◆ hydraulic_mcdonald_multiscale() [2/2]

void hmap::gpu::hydraulic_mcdonald_multiscale ( Array & z,
std::uint32_t seed,
const std::vector< int > & steps_per_level = {512, 256, 128},
const Array * p_moisture_map = nullptr,
Array * p_sediment_map = nullptr,
Array * p_discharge_map = nullptr,
float world_extent_km = 40.f,
float z_scale_km = 4.f,
int samples = 8192,
int maxage = 512,
float lrate = 0.2f,
float time_step = 10.f,
float rainfall = 1.f,
float evap_rate = 1e-4f,
float gravity = 9.81f,
float viscosity = 0.025f,
float bed_shear = 0.01f,
float crit_slope = 0.57f,
float settle_rate = 0.1f,
float thermal_rate = 2.5e-3f,
float deposition_rate = 5e-3f,
float suspension_rate = 2.5e-4f,
float exit_slope = 0.01f )

◆ hydraulic_procedural()

void hmap::gpu::hydraulic_procedural ( Array & z,
float kp_global,
float c_erosion,
std::uint32_t seed,
ErosionProfile erosion_profile = ErosionProfile::EP_TRIANGLE_GRENIER,
float erosion_profile_parameter = 0.01f,
float angle_shift = 0.f,
float phase_smoothing = 0.1f,
float talus_ref = 0.001f,
float gradient_scaling_ratio = 1.f,
float gradient_power = 0.8f,
bool exclude_ridges = true,
bool apply_deposition = false,
float deposition_strength = 1.f,
bool enable_default_noise = true,
float noise_amp = 0.01f,
const Array * p_kp_multiplier = nullptr,
const Array * p_angle_shift = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
Array * p_ridge_mask = nullptr,
const UvRect & uv_rect = UvRect{} )

Apply phase-guided hydraulic procedural erosion to a heightmap.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
// shape = {1024, 1024};
glm::vec2 kw = {2.f, 2.f};
int seed = 0;
// z0 = hmap::bulkify(z0, hmap::PrimitiveType::PRIM_CONE_SMOOTH, 1.f);
auto z1 = z0;
float kp_global = 24.f;
float c_erosion = 0.2f;
kp_global,
c_erosion,
seed,
erosion_profile);
auto z2 = z0;
hmap::gpu::hydraulic_procedural(z2, kp_global, c_erosion, seed);
z0.dump("out0.png");
z1.dump("out1.png");
z2.dump("out2.png");
hmap::export_banner_png("ex_hydraulic_procedural0.png",
{z0, z1, z2},
true);
return 0;
// --- all profiles
std::vector<hmap::ErosionProfile> profiles = {
std::vector<hmap::Array> stack = {z0};
for (auto ep : profiles)
{
hmap::Array ze = z0;
hmap::gpu::hydraulic_procedural(ze, kp_global, c_erosion, seed, ep);
stack.push_back(ze);
}
hmap::export_banner_png("ex_hydraulic_procedural1.png",
stack,
true);
}
void hydraulic_procedural(Array &z, float kp_global, float c_erosion, std::uint32_t seed, ErosionProfile erosion_profile=ErosionProfile::EP_TRIANGLE_GRENIER, float erosion_profile_parameter=0.01f, float angle_shift=0.f, float phase_smoothing=0.1f, float talus_ref=0.001f, float gradient_scaling_ratio=1.f, float gradient_power=0.8f, bool exclude_ridges=true, bool apply_deposition=false, float deposition_strength=1.f, bool enable_default_noise=true, float noise_amp=0.01f, const Array *p_kp_multiplier=nullptr, const Array *p_angle_shift=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_ridge_mask=nullptr, const UvRect &uv_rect=UvRect{})
Apply phase-guided hydraulic procedural erosion to a heightmap.
Definition hydraulic_procedural.cpp:26
void hydraulic_procedural_fbm(Array &z, float kp_global, float c_erosion, std::uint32_t seed, ErosionProfile erosion_profile=ErosionProfile::EP_TRIANGLE_GRENIER, int octaves=3, float persistence=0.5f, float lacunarity=2.f, float erosion_profile_parameter=0.01f, float angle_shift=0.f, float phase_smoothing=0.1f, float talus_ref=0.001f, float gradient_scaling_ratio=1.f, float gradient_power=0.8f, bool exclude_ridges=true, bool apply_deposition=false, float deposition_strength=1.f, bool enable_default_noise=true, float noise_amp=0.01f, const Array *p_kp_multiplier=nullptr, const Array *p_angle_shift=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, Array *p_ridge_mask=nullptr, const UvRect &uv_rect=UvRect{})
Multi-octave (fBm) variant of hydraulic_procedural().
Definition hydraulic_procedural.cpp:201
@ EP_COSINE
Definition profiles.hpp:21
@ EP_PARABOL
Definition profiles.hpp:24
@ EP_TRIANGLE_SMOOTH
Definition profiles.hpp:31
@ EP_TRIANGLE_GRENIER
Definition profiles.hpp:29
@ EP_COSINE_BULK
Definition profiles.hpp:22
@ EP_SHARP_VALLEYS
Definition profiles.hpp:27
@ EP_SAW_SMOOTH
Definition profiles.hpp:26
@ EP_SAW_SHARP
Definition profiles.hpp:25
@ EP_COSINE_PEAK
Definition profiles.hpp:23
@ EP_TRIANGLE_SHARP
Definition profiles.hpp:30
@ EP_SQRT
Definition profiles.hpp:28
@ SIMPLEX2
OpenSimplex2.
Definition functions.hpp:72

Result

◆ hydraulic_procedural_fbm() [1/2]

void hmap::gpu::hydraulic_procedural_fbm ( Array & z,
float kp_global,
float c_erosion,
std::uint32_t seed,
ErosionProfile erosion_profile = ErosionProfile::EP_TRIANGLE_GRENIER,
int octaves = 3,
float persistence = 0.5f,
float lacunarity = 2.f,
float erosion_profile_parameter = 0.01f,
float angle_shift = 0.f,
float phase_smoothing = 0.1f,
float talus_ref = 0.001f,
float gradient_scaling_ratio = 1.f,
float gradient_power = 0.8f,
bool exclude_ridges = true,
bool apply_deposition = false,
float deposition_strength = 1.f,
bool enable_default_noise = true,
float noise_amp = 0.01f,
const Array * p_kp_multiplier = nullptr,
const Array * p_angle_shift = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
Array * p_ridge_mask = nullptr,
const UvRect & uv_rect = UvRect{} )

Multi-octave (fBm) variant of hydraulic_procedural().

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
// shape = {1024, 1024};
glm::vec2 kw = {2.f, 2.f};
int seed = 0;
// z0 = hmap::bulkify(z0, hmap::PrimitiveType::PRIM_CONE_SMOOTH, 1.f);
auto z1 = z0;
float kp_global = 24.f;
float c_erosion = 0.2f;
kp_global,
c_erosion,
seed,
erosion_profile);
auto z2 = z0;
hmap::gpu::hydraulic_procedural(z2, kp_global, c_erosion, seed);
z0.dump("out0.png");
z1.dump("out1.png");
z2.dump("out2.png");
hmap::export_banner_png("ex_hydraulic_procedural0.png",
{z0, z1, z2},
true);
return 0;
// --- all profiles
std::vector<hmap::ErosionProfile> profiles = {
std::vector<hmap::Array> stack = {z0};
for (auto ep : profiles)
{
hmap::Array ze = z0;
hmap::gpu::hydraulic_procedural(ze, kp_global, c_erosion, seed, ep);
stack.push_back(ze);
}
hmap::export_banner_png("ex_hydraulic_procedural1.png",
stack,
true);
}

Result

◆ hydraulic_procedural_fbm() [2/2]

void hmap::gpu::hydraulic_procedural_fbm ( Array & z,
float kp_global,
float c_erosion,
std::uint32_t seed,
const Array * p_mask,
ErosionProfile erosion_profile = ErosionProfile::EP_TRIANGLE_GRENIER,
int octaves = 3,
float persistence = 0.5f,
float lacunarity = 2.f,
float erosion_profile_parameter = 0.01f,
float angle_shift = 0.f,
float phase_smoothing = 0.1f,
float talus_ref = 0.001f,
float gradient_scaling_ratio = 1.f,
float gradient_power = 0.8f,
bool exclude_ridges = true,
bool apply_deposition = false,
float deposition_strength = 1.f,
bool enable_default_noise = true,
float noise_amp = 0.01f,
const Array * p_kp_multiplier = nullptr,
const Array * p_angle_shift = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
Array * p_ridge_mask = nullptr,
const UvRect & uv_rect = UvRect{} )

◆ hydraulic_schott() [1/2]

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 Schott method.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 2;
auto z1 = z0;
int iterations = 500;
hmap::Array talus(shape, 4.f / (float)shape.x); // for thermal
iterations,
talus,
0.5f,
0.1f,
0.05f,
0.8f,
0.8f,
1.3f,
1.f,
1.f);
// erosion only
auto z2 = z0;
hmap::export_banner_png("ex_hydraulic_schott.png",
{z0, z1, z2},
true);
}
void 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 Schott method.
Definition hydraulic_schott_gpu.cpp:19
void hydraulic_schott_erosion(Array &z, int iterations, float c_erosion=1.f, float flow_acc_exponent=0.8f, float flow_routing_exponent=1.3f, const Array *p_moisture_map=nullptr, Array *p_flow=nullptr)
See hmap::gpu::hydraulic_schott.
Definition hydraulic_schott_gpu.cpp:181

Result

◆ hydraulic_schott() [2/2]

void hmap::gpu::hydraulic_schott ( Array & z,
const Array * p_mask,
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 )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ hydraulic_schott_erosion()

void hmap::gpu::hydraulic_schott_erosion ( Array & z,
int iterations,
float c_erosion = 1.f,
float flow_acc_exponent = 0.8f,
float flow_routing_exponent = 1.3f,
const Array * p_moisture_map = nullptr,
Array * p_flow = nullptr )

◆ hydraulic_stream_log() [1/2]

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,
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 )

◆ hydraulic_stream_log() [2/2]

void hmap::gpu::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.

◆ hydraulic_stream_log_multiscale() [1/2]

void hmap::gpu::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 )

◆ hydraulic_stream_log_multiscale() [2/2]

void hmap::gpu::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.

◆ hydraulic_vpipes()

void hmap::gpu::hydraulic_vpipes ( Array & z,
float water_height = 1e-2f,
bool maintain_water_volume = true,
float evap_rate = 0.1f,
int iterations = 50,
float dt = 0.5f,
float k_capacity = 0.5f,
float k_erode = 0.001f,
float k_depose = 0.01f,
float k_discharge_exp = 1.f,
float downcutting_max_depth_ratio = 10.f,
bool flux_diffusion = true,
float flux_diffusion_strength = 0.01f,
Array * p_rain_map = nullptr,
Array * p_water_depth = nullptr,
Array * p_sediment = nullptr,
Array * p_vel_u = nullptr,
Array * p_vel_v = nullptr )

◆ mudslide() [1/2]

void hmap::gpu::mudslide ( Array & z,
const Array & landslide_mask,
float depth,
int iterations,
float depth_map_exponent = 0.5f,
float viscosity_law_power = 1.5f,
Array * p_depth_end = nullptr,
Array * p_depth_init = nullptr )

Simulate a mudslide (landslide-driven material redistribution) on a height field.

Parameters
[in,out]zInput/output height field modified in place.
[in]landslide_maskMask defining affected areas (non-zero = active).
[in]depthMaximum erosion/deposition depth.
[in]iterationsNumber of simulation iterations.
[in]depth_map_exponentExponent applied to depth influence (default 0.5f).
[in]viscosity_law_powerPower exponent controlling viscosity response (default 1.5f).
[out]p_depth_endOptional pointer to store resulting depth map.
[out]p_depth_initOptional pointer to store initial depth map.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 0;
auto dx = 0.2f *
hmap::noise_fbm(hmap::NoiseType::PERLIN, shape, kw, seed, 8, 0.f);
auto z0 = step(shape, 0.f, 3.f, nullptr, &dx);
auto z1 = z0;
float depth = 0.2f;
int iterations = 2500;
hmap::gpu::mudslide(z1, 1.f / shape.x, depth, iterations);
auto mask = hmap::noise_fbm(hmap::NoiseType::PERLIN, shape, kw, seed + 1);
make_binary(mask, 0.f);
auto z2 = z0;
hmap::gpu::mudslide(z2, mask, depth, iterations);
hmap::export_banner_png("ex_mudslide.png",
{z0, z1, mask, z2},
true);
}
void mudslide(Array &z, const Array &landslide_mask, float depth, int iterations, float depth_map_exponent=0.5f, float viscosity_law_power=1.5f, Array *p_depth_end=nullptr, Array *p_depth_init=nullptr)
Simulate a mudslide (landslide-driven material redistribution) on a height field.
Definition mudslide.cpp:19

Result

◆ mudslide() [2/2]

void hmap::gpu::mudslide ( Array & z,
float talus_limit,
float depth,
int iterations,
float depth_map_exponent = 0.5f,
float viscosity_law_power = 1.5f,
Array * p_depth_end = nullptr,
Array * p_depth_init = nullptr )

◆ rifts()

void hmap::gpu::rifts ( Array & z,
const glm::vec2 & kw,
float angle,
float amplitude,
std::uint32_t seed,
float elevation_noise_shift = 0.f,
float k_smooth_bottom = 0.05f,
float k_smooth_top = 0.05f,
float radial_spread_amp = 0.2f,
float elevation_noise_amp = 0.1f,
float clamp_vmin = 0.f,
float remap_vmin = 0.f,
bool apply_mask = true,
bool reverse_mask = false,
float mask_gamma = 1.f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const Array * p_mask = nullptr,
const glm::vec2 & center = {0.5f, 0.5f},
const UvRect & uv_rect = {0.f, 1.f, 0.f, 1.f} )

Applies a "rift" deformation effect to a heightmap array.

Parameters
zReference to the heightmap array to be modified in-place.
kwFrequency vector (kx, ky) scaling deformation.
angleOrientation of rift in degrees.
amplitudeStrength of rift deformation.
seedRandom seed.
elevation_noise_shiftVertical offset applied to base noise.
k_smooth_bottomLower smoothing factor for Voronoi noise.
k_smooth_topUpper smoothing factor for Voronoi noise.
radial_spread_ampAmplitude controlling radial spreading.
elevation_noise_ampAmplitude scaling elevation influence.
clamp_vminMinimum clamp value.
remap_vminMinimum remap value.
apply_maskIf true, applies power-based blending mask.
reverse_maskReverse mask blending.
mask_gammaGamma exponent for blending mask.
p_noise_xOptional X noise array.
p_noise_yOptional Y noise array.
p_maskOptional mask array.
center2D center point.
bboxBounding box (xmin, xmax, ymin, ymax).

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 0;
hmap::Array z1 = 1.f +
hmap::Array z2 = z1;
glm::vec2 kw_r = {8.f, 1.5f};
float angle = 30.f;
float intensity = 0.1f;
hmap::gpu::rifts(z2, kw_r, angle, intensity, ++seed);
hmap::export_banner_png("ex_rifts.png", {z1, z2}, hmap::Cmap::TERRAIN, true);
}
void rifts(Array &z, const glm::vec2 &kw, float angle, float amplitude, std::uint32_t seed, float elevation_noise_shift=0.f, float k_smooth_bottom=0.05f, float k_smooth_top=0.05f, float radial_spread_amp=0.2f, float elevation_noise_amp=0.1f, float clamp_vmin=0.f, float remap_vmin=0.f, bool apply_mask=true, bool reverse_mask=false, float mask_gamma=1.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_mask=nullptr, const glm::vec2 &center={0.5f, 0.5f}, const UvRect &uv_rect={0.f, 1.f, 0.f, 1.f})
Applies a "rift" deformation effect to a heightmap array.
Definition rifts_gpu.cpp:17
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.
Definition zeroed_edges.cpp:18
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:65

Result

◆ sediment_deposition() [1/2]

void hmap::gpu::sediment_deposition ( Array & z,
const 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.

Parameters
zInput array.
p_maskIntensity mask, expected in [0, 1].
talusTalus limit.
p_deposition_mapReference to deposition map output.
max_depositionMaximum height of sediment deposition.
iterationsNumber of iterations.
thermal_subiterationsNumber of thermal erosion iterations per pass.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
auto z0 = z;
// talus limit defined locally
auto talus = hmap::Array(shape, 2.f / (float)shape.x);
hmap::gpu::sediment_deposition(z, talus, nullptr, 0.01f, 10, 50);
hmap::export_banner_png("ex_sediment_deposition.png",
{z0, z},
true);
}
void sediment_deposition(Array &z, const 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.
Definition deposition.cpp:46

Result

◆ sediment_deposition() [2/2]

void hmap::gpu::sediment_deposition ( Array & z,
const Array & talus,
Array * p_deposition_map = nullptr,
float max_deposition = 0.01,
int iterations = 5,
int thermal_subiterations = 10 )

◆ sediment_layer()

void hmap::gpu::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 )

Applies a talus-based sediment deposition layer.

Parameters
[in,out]zHeightmap to modify.
[in]talus_layerBase talus values for erosion.
[in]talus_upper_limitUpper talus threshold used for masking.
[in]iterationsNumber of erosion iterations.
[in]apply_post_filterEnable post smoothing and blending.
[out]p_deposition_mapOptional output deposition map.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
float talus_layer = 0.5f / shape.x;
float talus_depo = 5.f / shape.x;
// exclusion limit
int iterations = 500;
bool apply_post_filter = true;
auto z1 = z0;
hmap::Array(shape, talus_layer),
hmap::Array(shape, talus_depo),
iterations,
apply_post_filter);
z1.to_png_grayscale("out.png", CV_16U);
hmap::export_banner_png("ex_sediment_layer.png",
{z0, z1},
true);
}
void 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)
Applies a talus-based sediment deposition layer.
Definition deposition.cpp:77
@ PRIM_CUBIC_PULSE
Definition functions.hpp:28

Result

◆ strata()

void hmap::gpu::strata ( Array & z,
float angle,
float slope,
float gamma,
std::uint32_t seed,
bool linear_gamma = true,
float kz = 1.f,
int octaves = 4,
float lacunarity = 2.f,
float gamma_noise_ratio = 0.5f,
float noise_amp = 0.4f,
const glm::vec2 & noise_kw = {4.f, 4.f},
bool enable_ridge_noise = true,
const glm::vec2 & ridge_noise_kw = {4.f, 1.2f},
float ridge_angle_shift = 45.f,
float ridge_noise_amp = 0.5f,
float ridge_clamp_vmin = 0.f,
float ridge_remap_vmin = 0.f,
bool apply_elevation_mask = true,
bool apply_ridge_mask = true,
float mask_gamma = 0.4f,
const Array * p_mask = nullptr,
const UvRect & uv_rect = {0.f, 1.f, 0.f, 1.f} )

Applies stratification to a heightfield using directional noise and multiscale gamma transformations.

Parameters
zReference to heightfield array, MUST BE NORMALIZED in [0, 1].
angleHorizontal orientation of strata in degrees.
slopeVertical slope of strata.
gammaGamma exponent for non-linear remapping.
seedSeed for deterministic noise generation.
linear_gammaLinear or smooth gamma mapping.
kzBase scaling factor for frequency.
octavesNumber of iterative passes.
lacunarityFrequency multiplier per octave.
gamma_noise_ratioNoise influence ratio on gamma.
noise_ampAmplitude of base Perlin noise.
noise_kwFrequency vector for Perlin noise.
enable_ridge_noiseEnable Voronoi ridge noise.
ridge_noise_kwFrequency vector for ridge noise.
ridge_angle_shiftAngular shift for ridge direction.
ridge_noise_ampAmplitude of ridge noise.
ridge_clamp_vminMinimum clamp value for ridge noise.
ridge_remap_vminMinimum remap value for ridge noise.
apply_elevation_maskApply elevation mask.
apply_ridge_maskApply ridge mask.
mask_gammaMask gamma exponent.
p_maskOptional filter mask.
bboxDomain bounding box.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {1024, 1024};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
hmap::Array z1 = 1.f +
hmap::Array z2 = z1;
hmap::gpu::strata(z2, 30.f, 2.f, 0.7f, ++seed);
z1.dump("out0.png");
z2.dump();
hmap::export_banner_png("ex_strata.png", {z1, z2}, hmap::Cmap::TERRAIN, true);
}
void strata(Array &z, float angle, float slope, float gamma, std::uint32_t seed, bool linear_gamma=true, float kz=1.f, int octaves=4, float lacunarity=2.f, float gamma_noise_ratio=0.5f, float noise_amp=0.4f, const glm::vec2 &noise_kw={4.f, 4.f}, bool enable_ridge_noise=true, const glm::vec2 &ridge_noise_kw={4.f, 1.2f}, float ridge_angle_shift=45.f, float ridge_noise_amp=0.5f, float ridge_clamp_vmin=0.f, float ridge_remap_vmin=0.f, bool apply_elevation_mask=true, bool apply_ridge_mask=true, float mask_gamma=0.4f, const Array *p_mask=nullptr, const UvRect &uv_rect={0.f, 1.f, 0.f, 1.f})
Applies stratification to a heightfield using directional noise and multiscale gamma transformations.
Definition strata.cpp:21

Result

◆ strata_cells() [1/2]

void hmap::gpu::strata_cells ( Array & z,
glm::vec2 kw,
float amp,
std::uint32_t seed,
float gamma = 0.5f,
float gamma_lateral = 0.4f,
float angle = 0.f,
float noise_amp = 0.5f,
bool absolute_displacement = true,
float occurence_probability = 0.5f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Applies procedural stratified cell displacement to a heightmap.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 1;
hmap::Array z1 = z0;
float amp = 0.5f;
glm::vec2 kc = {4.f, 8.f};
float gamma = 0.4f;
float gamma_lateral = 0.4f;
float angle = 5.f;
bool enable_default_noise = true;
float noise_amp = 0.1f;
bool absolute_displacement = false;
float occurence_probability = 1.f;
kc,
amp,
seed,
gamma,
gamma_lateral,
angle,
noise_amp,
absolute_displacement,
occurence_probability);
int octaves = 6;
float persistence = 0.4f;
float lacunarity = 2.2f;
auto z2 = z0;
float default_noise_amp = 0.02f;
kc,
amp,
seed,
gamma,
gamma_lateral,
angle,
enable_default_noise,
default_noise_amp,
absolute_displacement,
occurence_probability,
octaves,
persistence,
lacunarity);
z0.dump("out0.png");
z1.dump("out1.png");
z2.dump("out2.png");
hmap::export_banner_png("ex_strata_cells.png",
{z0, z1, z2},
true);
}
void strata_cells(Array &z, glm::vec2 kw, float amp, std::uint32_t seed, float gamma=0.5f, float gamma_lateral=0.4f, float angle=0.f, float noise_amp=0.5f, bool absolute_displacement=true, float occurence_probability=0.5f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Applies procedural stratified cell displacement to a heightmap.
Definition strata.cpp:84
void strata_cells_fbm(Array &z, glm::vec2 kw, float amp, std::uint32_t seed, float gamma=0.5f, float gamma_lateral=0.4f, float angle=0.f, bool enable_default_noise=true, float default_noise_amp=0.05f, bool absolute_displacement=true, float occurence_probability=0.5f, int octaves=8, float persistence=0.4f, float lacunarity=2.2f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Applies multi-octave (fBm) stratified cell displacement.
Definition strata.cpp:171

Result

◆ strata_cells() [2/2]

void hmap::gpu::strata_cells ( Array & z,
glm::vec2 kw,
float amp,
std::uint32_t seed,
const Array * p_mask,
float gamma = 0.5f,
float gamma_lateral = 0.4f,
float angle = 0.f,
float noise_amp = 0.5f,
bool absolute_displacement = true,
float occurence_probability = 0.5f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

◆ strata_cells_fbm() [1/2]

void hmap::gpu::strata_cells_fbm ( Array & z,
glm::vec2 kw,
float amp,
std::uint32_t seed,
float gamma = 0.5f,
float gamma_lateral = 0.4f,
float angle = 0.f,
bool enable_default_noise = true,
float default_noise_amp = 0.05f,
bool absolute_displacement = true,
float occurence_probability = 0.5f,
int octaves = 8,
float persistence = 0.4f,
float lacunarity = 2.2f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Applies multi-octave (fBm) stratified cell displacement.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 1;
hmap::Array z1 = z0;
float amp = 0.5f;
glm::vec2 kc = {4.f, 8.f};
float gamma = 0.4f;
float gamma_lateral = 0.4f;
float angle = 5.f;
bool enable_default_noise = true;
float noise_amp = 0.1f;
bool absolute_displacement = false;
float occurence_probability = 1.f;
kc,
amp,
seed,
gamma,
gamma_lateral,
angle,
noise_amp,
absolute_displacement,
occurence_probability);
int octaves = 6;
float persistence = 0.4f;
float lacunarity = 2.2f;
auto z2 = z0;
float default_noise_amp = 0.02f;
kc,
amp,
seed,
gamma,
gamma_lateral,
angle,
enable_default_noise,
default_noise_amp,
absolute_displacement,
occurence_probability,
octaves,
persistence,
lacunarity);
z0.dump("out0.png");
z1.dump("out1.png");
z2.dump("out2.png");
hmap::export_banner_png("ex_strata_cells.png",
{z0, z1, z2},
true);
}

Result

◆ strata_cells_fbm() [2/2]

void hmap::gpu::strata_cells_fbm ( Array & z,
glm::vec2 kw,
float amp,
std::uint32_t seed,
const Array * p_mask,
float gamma = 0.5f,
float gamma_lateral = 0.4f,
float angle = 0.f,
bool enable_default_noise = true,
float default_noise_amp = 0.05f,
bool absolute_displacement = true,
float occurence_probability = 0.5f,
int octaves = 8,
float persistence = 0.4f,
float lacunarity = 2.2f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

◆ strata_plates()

void hmap::gpu::strata_plates ( Array & z,
const Array & talus,
int direction_offset = 0,
int direction_count = 3,
bool random_directions = false,
std::uint32_t seed = 0,
float vmin = -FLT_MAX,
float skew = 0.f,
float mix_ratio = 0.9f,
const Array * p_mask = nullptr,
const Array * p_dx = nullptr,
const Array * p_dy = nullptr )

Apply stratified talus projection along multiple directions.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
hmap::Array talus(shape, 2.f / shape.x);
auto z1 = z0;
hmap::export_banner_png("ex_strata_plates.png",
{z0, z1},
true);
}
void strata_plates(Array &z, const Array &talus, int direction_offset=0, int direction_count=3, bool random_directions=false, std::uint32_t seed=0, float vmin=-FLT_MAX, float skew=0.f, float mix_ratio=0.9f, const Array *p_mask=nullptr, const Array *p_dx=nullptr, const Array *p_dy=nullptr)
Apply stratified talus projection along multiple directions.
Definition strata_plates.cpp:18

Result

◆ strata_terrace() [1/2]

void hmap::gpu::strata_terrace ( Array & z,
float gamma,
std::uint32_t seed,
float kz = 4.f,
bool linear_gamma = true,
float gamma_noise_ratio = 0.5f,
float slope = 0.f,
float angle = 0.f,
const Array * p_noise = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Applies a terrace (stratification) filter to a heightmap.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 0;
float gamma = 0.5f;
float kz = 8.f; // 8-layers
bool linear_gamma = false;
float gamma_noise_ratio = 0.1f;
float slope = 8.f;
float angle = 15.f;
hmap::Array z2 = z1;
gamma,
seed,
kz,
linear_gamma,
gamma_noise_ratio);
hmap::Array z3 = z1;
shape,
{16.f, 16.f},
seed + 1);
gamma,
seed,
kz,
linear_gamma,
gamma_noise_ratio,
0.f,
0.f,
&noise);
auto z4 = z1;
gamma,
seed,
kz,
linear_gamma,
gamma_noise_ratio,
slope,
angle);
hmap::export_banner_png("ex_strata_terrace.png",
{z1, z2, z3, z4},
true);
}
void strata_terrace(Array &z, float gamma, std::uint32_t seed, float kz=4.f, bool linear_gamma=true, float gamma_noise_ratio=0.5f, float slope=0.f, float angle=0.f, const Array *p_noise=nullptr, const UvRect &uv_rect=UvRect::unit())
Applies a terrace (stratification) filter to a heightmap.
Definition strata.cpp:300

Result

◆ strata_terrace() [2/2]

void hmap::gpu::strata_terrace ( Array & z,
float gamma,
std::uint32_t seed,
const Array * p_mask,
float kz = 4.f,
bool linear_gamma = true,
float gamma_noise_ratio = 0.5f,
float slope = 0.f,
float angle = 0.f,
const Array * p_noise = nullptr,
const UvRect & uv_rect = UvRect::unit() )

◆ valley_fill() [1/2]

void hmap::gpu::valley_fill ( Array & z,
const Array & talus,
int iterations = 100,
float gamma = 2.f,
float ratio = 0.8f,
float zmin = 0.f,
float zmax = 0.f,
float elevation_max_ratio = 1.f,
bool preserve_elevation_range = true,
const Array * p_noise = nullptr,
Array * p_deposition_map = nullptr )

Fill valleys using thermal scree deposition and height-based blending.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 res = {4.f, 4.f};
int seed = 0;
auto z0 = z;
int iterations = 250;
hmap::gpu::valley_fill(z, hmap::Array(shape, 2.f / shape.x), iterations);
hmap::export_banner_png("ex_valley_fill.png",
{z0, z},
true);
}
void valley_fill(Array &z, const Array &talus, int iterations=100, float gamma=2.f, float ratio=0.8f, float zmin=0.f, float zmax=0.f, float elevation_max_ratio=1.f, bool preserve_elevation_range=true, const Array *p_noise=nullptr, Array *p_deposition_map=nullptr)
Fill valleys using thermal scree deposition and height-based blending.
Definition valley_fill.cpp:15
@ SIMPLEX2S
OpenSimplex2S.
Definition functions.hpp:73

Result

◆ valley_fill() [2/2]

void hmap::gpu::valley_fill ( Array & z,
const Array * p_mask,
const Array & talus,
int iterations = 100,
float gamma = 2.f,
float ratio = 0.8f,
float zmin = 0.f,
float zmax = 0.f,
float elevation_max_ratio = 1.f,
bool preserve_elevation_range = true,
const Array * p_noise = nullptr,
Array * p_deposition_map = nullptr )

◆ watershed_ridge() [1/2]

Array hmap::gpu::watershed_ridge ( const Array & z,
float amplitude = 0.2f,
float width = 32.f,
float edt_exponent = 0.5f,
int prefilter_ir = 0,
bool fast_approx = false,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const Array * p_scaling = nullptr )

Carves watershed ridges using basin-wise distance transforms.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 0;
float noise_amp = 0.03f;
shape,
4.f * kw,
seed);
// scale width and amplitude (smaller at the domain center)
hmap::Array scaling = 1.f - hmap::cubic_pulse(shape);
float amplitude = 0.2f;
float width = 24.f;
float exponent = 0.5f;
int prefilter_ir = 4;
amplitude,
width,
exponent,
prefilter_ir,
false,
&dx,
&dx,
&scaling);
amplitude,
width,
exponent,
prefilter_ir,
true,
&dx,
&dx,
&scaling);
hmap::export_banner_png("ex_watershed_ridge.png",
{z0, z1, z2},
true);
}
Array watershed_ridge(const Array &z, float amplitude=0.2f, float width=32.f, float edt_exponent=0.5f, int prefilter_ir=0, bool fast_approx=false, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_scaling=nullptr)
Carves watershed ridges using basin-wise distance transforms.
Definition watershed_ridge.cpp:21
Array cubic_pulse(glm::ivec2 shape)
Generates a cubic pulse kernel array.
Definition kernels.cpp:107

Result

◆ watershed_ridge() [2/2]

Array hmap::gpu::watershed_ridge ( const Array & z,
const Array * p_mask,
float amplitude = 0.2f,
float width = 32.f,
float edt_exponent = 0.5f,
int prefilter_ir = 0,
bool fast_approx = false,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const Array * p_scaling = nullptr )

◆ thermal() [1/3]

void hmap::gpu::thermal ( Array & z,
const Array & talus,
int iterations = 10,
const Array * p_bedrock = nullptr,
Array * p_deposition_map = nullptr )

Apply thermal weathering erosion.

Based on https://www.shadertoy.com/view/XtKSWh

Parameters
zInput array.
p_maskFilter mask, expected in [0, 1].
talusTalus limit.
p_bedrockLower elevation limit.
p_deposition_map[out] Reference to the deposition map, provided as an output field.
iterationsNumber of iterations.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
auto z1 = z0;
auto z2 = z0;
hmap::gpu::thermal(z1, 0.1f / shape.x, 500);
hmap::gpu::thermal_conserve(z2, 0.1f / shape.x, 500);
hmap::log::trace("z0 sum: {}", z0.sum());
hmap::log::trace("z0 sum: {}", z1.sum());
hmap::log::trace("z0 sum: {}", z2.sum());
hmap::export_banner_png("ex_thermal.png",
{z0, z1, z2},
true);
}
float sum(ICommunicator &comm=SingleArrayComm::instance()) const
Return the sum of all array values.
Definition methods.cpp:558
void thermal(Array &z, const Array &talus, int iterations=10, const Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
Apply thermal weathering erosion.
Definition thermal_gpu.cpp:20
void thermal_conserve(Array &z, const Array &talus, int iterations=10, float rate=0.5f, const Array *p_bedrock=nullptr, Array *p_deposition_map=nullptr)
Apply mass-preserving thermal weathering erosion.
Definition thermal_gpu.cpp:242
void trace(Args &&...args)
Definition logger.hpp:40

Result

◆ thermal() [2/3]

void hmap::gpu::thermal ( Array & z,
const Array * p_mask,
const Array & talus,
int iterations = 10,
const 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.

◆ thermal() [3/3]

void hmap::gpu::thermal ( Array & z,
float talus,
int iterations = 10,
const 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.

◆ thermal_auto_bedrock() [1/3]

void hmap::gpu::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.

Parameters
zInput array.
talusLocal talus limit.
iterationsNumber of iterations.
p_deposition_map[out] Reference to the deposition map, provided as an output field.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 1;
auto z0 = z;
hmap::gpu::thermal_auto_bedrock(z, 0.5f / shape.x, 500);
hmap::export_banner_png("ex_thermal_auto_bedrock.png",
{z0, z},
true);
}
void 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.
Definition thermal_gpu.cpp:156

Result

◆ thermal_auto_bedrock() [2/3]

void hmap::gpu::thermal_auto_bedrock ( Array & z,
const Array * p_mask,
const Array & talus,
int iterations = 10,
Array * p_deposition_map = nullptr )

◆ thermal_auto_bedrock() [3/3]

void hmap::gpu::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.

◆ thermal_conserve() [1/3]

void hmap::gpu::thermal_conserve ( Array & z,
const Array & talus,
int iterations = 10,
float rate = 0.5f,
const Array * p_bedrock = nullptr,
Array * p_deposition_map = nullptr )

Apply mass-preserving thermal weathering erosion.

Parameters
zInput array.
talusTalus limit.
iterationsNumber of iterations.
rateErosion rate factor.
p_bedrockLower elevation limit.
p_deposition_map[out] Reference to the deposition map, provided as an output field.

◆ thermal_conserve() [2/3]

void hmap::gpu::thermal_conserve ( Array & z,
const Array * p_mask,
const Array & talus,
int iterations = 10,
float rate = 0.5f,
const 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.

◆ thermal_conserve() [3/3]

void hmap::gpu::thermal_conserve ( Array & z,
float talus,
int iterations = 10,
float rate = 0.5f,
const 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.

◆ thermal_flatten() [1/2]

void hmap::gpu::thermal_flatten ( Array & z,
const Array & talus,
int iterations,
float sigma_inf = 0.5f,
float sigma_sup = 0.f )

Apply iterative thermal flattening erosion on a heightmap.

Parameters
[in,out]zHeightmap modified in-place.
[in]talusPer-cell talus threshold.
[in]iterationsNumber of iterations.
[in]sigma_infRelaxation factor for slopes below talus.
[in]sigma_supRelaxation factor for slopes above talus.

◆ thermal_flatten() [2/2]

void hmap::gpu::thermal_flatten ( Array & z,
const Array * p_mask,
const Array & talus,
int iterations,
float sigma_inf = 0.5f,
float sigma_sup = 0.f )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ thermal_olsen() [1/2]

void hmap::gpu::thermal_olsen ( Array & z,
const Array & talus,
int iterations )

Apply thermal weathering erosion (Olsen model).

Parameters
zInput array.
talusTalus limit.
iterationsNumber of iterations.

◆ thermal_olsen() [2/2]

void hmap::gpu::thermal_olsen ( Array & z,
const Array * p_mask,
const Array & talus,
int iterations )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ thermal_inflate() [1/2]

void hmap::gpu::thermal_inflate ( Array & z,
const Array & talus,
int iterations = 10 )

Apply thermal weathering erosion to give a scree like effect.

Parameters
zInput array.
talusTalus limit.
iterationsNumber of iterations.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {1024, 1024};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
auto z1 = z;
auto z2 = z;
auto z3 = z;
float talus = 2.f / shape.x;
hmap::Array talus_map = hmap::Array(shape, talus);
hmap::gpu::thermal_ridge(z1, talus_map, 500);
hmap::gpu::thermal_inflate(z2, talus_map, 500);
float zmax = 0.5f;
hmap::gpu::thermal_scree(z3, talus_map, hmap::Array(shape, zmax), 500);
z3.dump();
hmap::export_banner_png("ex_thermal_ridge.png",
{z, z1, z2, z3},
true);
}
void 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.
Definition thermal_gpu.cpp:570
void thermal_scree(Array &z, const Array &talus, const Array &zmax, int iterations=10, Array *p_deposition_map=nullptr)
Performs thermal scree erosion on a heightmap.
Definition thermal_gpu.cpp:702
void thermal_inflate(Array &z, const Array &talus, int iterations=10)
Apply thermal weathering erosion to give a scree like effect.
Definition thermal_gpu.cpp:417

Result

◆ thermal_inflate() [2/2]

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.

◆ thermal_rib() [1/2]

void hmap::gpu::thermal_rib ( Array & z,
int iterations )

Apply thermal erosion using a 'rib' algorithm.

Parameters
zInput heightmap.
iterationsNumber of iterations.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 1;
auto z0 = z;
hmap::export_banner_png("ex_thermal_rib.png",
{z0, z},
true);
}
void thermal_rib(Array &z, int iterations)
Apply thermal erosion using a 'rib' algorithm.
Definition thermal_gpu.cpp:524

Result

◆ thermal_rib() [2/2]

void hmap::gpu::thermal_rib ( Array & z,
const Array * p_mask,
int iterations )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ thermal_ridge() [1/2]

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.

Parameters
zInput array.
talusTalus limit.
iterationsNumber of iterations.
p_deposition_mapOptional deposition map output.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {1024, 1024};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
auto z1 = z;
auto z2 = z;
auto z3 = z;
float talus = 2.f / shape.x;
hmap::Array talus_map = hmap::Array(shape, talus);
hmap::gpu::thermal_ridge(z1, talus_map, 500);
hmap::gpu::thermal_inflate(z2, talus_map, 500);
float zmax = 0.5f;
hmap::gpu::thermal_scree(z3, talus_map, hmap::Array(shape, zmax), 500);
z3.dump();
hmap::export_banner_png("ex_thermal_ridge.png",
{z, z1, z2, z3},
true);
}

Result

◆ thermal_ridge() [2/2]

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.

◆ thermal_schott() [1/2]

void hmap::gpu::thermal_schott ( Array & z,
const Array & talus,
int iterations = 10,
float intensity = 0.2f,
Array * p_deposition_map = nullptr )

Applies the thermal erosion process with a uniform slope threshold (Schott model).

Parameters
zReference to elevation array.
talusConstant threshold slope value or talus array.
iterationsNumber of erosion iterations to apply.
intensityIntensity factor controlling amount of change.
p_deposition_mapOptional deposition map output.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 1;
auto z1 = z;
auto z2 = z;
int iterations = 500;
float talus = 2.f / shape.x;
hmap::gpu::thermal_schott(z1, hmap::Array(shape, talus), iterations);
// align talus constraint with the elevation
hmap::Array talus_map = z;
hmap::remap(talus_map, talus / 2.f, talus);
hmap::gpu::thermal_schott(z2, talus_map, iterations);
hmap::export_banner_png("ex_thermal_schott.png",
{z, z1, z2},
true);
}
void thermal_schott(Array &z, const Array &talus, int iterations=10, float intensity=0.2f, Array *p_deposition_map=nullptr)
Applies the thermal erosion process with a uniform slope threshold (Schott model).
Definition thermal_gpu.cpp:634

Result

◆ thermal_schott() [2/2]

void hmap::gpu::thermal_schott ( Array & z,
const Array * p_mask,
const Array & talus,
int iterations = 10,
float intensity = 0.2f,
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.

◆ thermal_scree() [1/2]

void hmap::gpu::thermal_scree ( Array & z,
const Array & talus,
const Array & zmax,
int iterations = 10,
Array * p_deposition_map = nullptr )

Performs thermal scree erosion on a heightmap.

Parameters
[out]zThe heightmap modified in-place.
[in]talusThreshold slope angles.
[in]zmaxMaximum allowed elevation.
[in]iterationsNumber of iterations.
[out]p_deposition_mapOptional deposition map output.

◆ thermal_scree() [2/2]

void hmap::gpu::thermal_scree ( Array & z,
const Array * p_mask,
const Array & talus,
const Array & zmax,
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.

◆ bilateral_filter() [1/2]

Array hmap::gpu::bilateral_filter ( const Array & array,
const Array & kernel2d,
const Array & kernel1d,
float kernel1d_value_scaling )

Apply a bilateral filter to an array.

This function performs edge-preserving smoothing by combining a spatial kernel (2D) and a value-domain kernel (1D). The spatial kernel controls the influence of neighboring samples based on their position, while the value kernel weights samples according to their value difference.

Parameters
arrayInput array to be filtered.
kernel2d2D spatial kernel defining neighborhood weights.
kernel1d1D kernel applied in the value domain.
kernel1d_value_scalingScaling factor applied to value differences before sampling the 1D kernel.
Returns
A new array containing the filtered result.

Example

Result

◆ bilateral_filter() [2/2]

Array hmap::gpu::bilateral_filter ( const Array & array,
int ir,
float kernel1d_value_scaling )

Apply a bilateral filter to an array using a radius-based Gaussian kernel.

This overload builds the spatial kernel implicitly from the given radius. The value-domain kernel behavior is controlled by the same scaling factor as the main overload.

Parameters
arrayInput array to be filtered.
irRadius of the spatial neighborhood.
kernel1d_value_scalingScaling factor applied to value differences before computing value-domain weights.
Returns
A new array containing the filtered result.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Example

Result

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ directional_blur() [1/2]

void hmap::gpu::directional_blur ( Array & array,
float radius,
const Array & angle,
int steps = 32 )

Applies a directional blur to the input array.

Blurs values along a direction specified per element by the angle array, using a given radius and number of sampling steps.

Parameters
arrayInput array to be blurred (modified in place).
radiusBlur radius.
angleArray of angles (in radians) defining blur direction per element.
stepsNumber of samples along the blur direction (default: 32).

Example

Result

◆ directional_blur() [2/2]

void hmap::gpu::directional_blur ( Array & array,
float radius,
const Array & angle,
const Array * p_mask,
int steps = 32 )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ distance_shaper()

Array hmap::gpu::distance_shaper ( const Array & array,
float falloff = 0.05f,
int directions = 8,
float skew = 0.f,
float angle = 0.f,
hmap::DistanceMode mode = DistanceMode::PYRAMID,
hmap::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 )

◆ expand() [1/4]

void hmap::gpu::expand ( Array & array,
int ir,
int iterations = 1 )

◆ expand() [2/4]

void hmap::gpu::expand ( 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.

◆ expand() [3/4]

void hmap::gpu::expand ( 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.

◆ expand() [4/4]

void hmap::gpu::expand ( 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.

◆ gamma_correction_local() [1/2]

void hmap::gpu::gamma_correction_local ( Array & array,
float gamma,
int ir,
float k = 0.1f,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ gamma_correction_local() [2/2]

void hmap::gpu::gamma_correction_local ( Array & array,
float gamma,
int ir,
const Array * p_mask,
float k = 0.1f,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ jagged() [1/2]

Array hmap::gpu::jagged ( const Array & array,
glm::vec2 kw,
float amp = 0.1f,
std::uint32_t seed = 0,
glm::vec2 jitter = {0.5f, 0.5f},
float gamma = 1.f,
float angle = 0.f,
const Array * p_mask = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Apply a Voronoi-based jagged bubble dome filter to an array.

For each Voronoi cell, computes a smooth dome profile vanishing at cell boundaries and peaking at the cell center, added to the input elevation:

\[\tau = \frac{d_{\text{edge}}}{d_{\text{center}} + d_{\text{edge}}} \]

\[Z_{\text{out}}(x) = Z(x) + \text{amp} \cdot \left( \sin\left(\frac{\pi}{2} \tau\right) \right)^\gamma \]

Parameters
arrayInput array to be filtered.
kwFrequency / wave numbers for Voronoi cells.
ampAmplitude of the bubble dome elevation (default: 0.1f).
seedSeed for random jitter of Voronoi cell centers.
jitterJitter amount controlling cell randomness (default: {0.5f, 0.5f}).
gammaShape exponent for the dome curvature (default: 1.0f).
angleOrientation angle in degrees for rotating the Voronoi pattern around (0, 0) (default: 0.0f).
p_maskOptional mask array for blending.
p_noise_xOptional noise array for X perturbation.
p_noise_yOptional noise array for Y perturbation.
bboxBounding box for domain mapping (default: {0.f, 1.f, 0.f, 1.f}).
Returns
Filtered array.

Example

#include "highmap.hpp"
int main(void)
{
const glm::ivec2 shape = {512, 512};
const glm::vec2 kw_base = {2.f, 2.f};
const int seed = 42;
// Base terrain heightmap
shape,
kw_base,
seed);
hmap::remap(z0, 0.f, 1.f);
const float kw = 8.f;
const float kw_fine = 16.f;
const glm::vec2 jitter = {0.6f, 0.6f};
const float amp_mild = 0.12f;
const float amp_strong = 0.22f;
const float gamma_plateau = 0.5f;
const float gamma_cusp = 2.0f;
const float mask_sigma = 0.25f;
// Jagged bubble domes with plateau profile (gamma = 0.5)
auto z1 = hmap::gpu::jagged(z0, kw, amp_mild, seed, jitter, gamma_plateau);
// Jagged bubble domes with standard parabolic profile (gamma = 1.0)
auto z2 = hmap::gpu::jagged(z0, kw, amp_mild, seed, jitter, 1.0f);
// Jagged bubble domes with cusp profile and mask (gamma = 2.0)
hmap::Array mask = hmap::gaussian_pulse(shape, mask_sigma);
auto z3 = hmap::gpu::jagged(z0,
kw_fine,
amp_strong,
seed,
jitter,
gamma_cusp,
30.f,
&mask);
hmap::export_banner_png("ex_jagged.png",
{z0, z1, z2, z3},
true);
}
Array jagged(const Array &array, glm::vec2 kw, float amp=0.1f, std::uint32_t seed=0, glm::vec2 jitter={0.5f, 0.5f}, float gamma=1.f, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Apply a Voronoi-based jagged bubble dome filter to an array.
Definition jagged.cpp:19
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.
Definition primitives.cpp:233

Result

◆ jagged() [2/2]

Array hmap::gpu::jagged ( const Array & array,
float kw,
float amp = 0.1f,
std::uint32_t seed = 0,
glm::vec2 jitter = {0.5f, 0.5f},
float gamma = 1.f,
float angle = 0.f,
const Array * p_mask = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Apply a Voronoi-based jagged bubble dome filter using an isotropic frequency.

Parameters
arrayInput array to be filtered.
kwIsotropic frequency / wave number for Voronoi cells.
ampAmplitude of the bubble dome elevation (default: 0.1f).
seedSeed for random jitter of Voronoi cell centers.
jitterJitter amount controlling cell randomness (default: {0.5f, 0.5f}).
gammaShape exponent for the dome curvature (default: 1.0f).
angleOrientation angle in degrees for rotating the Voronoi pattern around (0, 0) (default: 0.0f).
p_maskOptional mask array for blending.
p_noise_xOptional noise array for X perturbation.
p_noise_yOptional noise array for Y perturbation.
bboxBounding box for domain mapping (default: {0.f, 1.f, 0.f, 1.f}).
Returns
Filtered array.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ jagged_fbm() [1/2]

Array hmap::gpu::jagged_fbm ( const Array & array,
glm::vec2 kw,
float amp = 0.1f,
std::uint32_t seed = 0,
int octaves = 8,
float persistence = 0.5f,
float lacunarity = 2.f,
bool switch_kx_ky = false,
glm::vec2 jitter = {0.5f, 0.5f},
float gamma = 1.f,
float angle = 0.f,
const Array * p_mask = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Apply a fractal Brownian motion (fBm) version of the Voronoi-based jagged bubble dome filter to an array.

Applies sequential jagged filters across multiple octaves, scaling the frequency by lacunarity and the amplitude by persistence at each iteration.

Parameters
arrayInput array to be filtered.
kwFrequency / wave numbers for Voronoi cells.
ampInitial amplitude of the bubble dome elevation (default: 0.1f).
seedSeed for random jitter of Voronoi cell centers.
octavesNumber of fBm octaves (default: 8).
persistenceAmplitude multiplier per octave (default: 0.5f).
lacunarityFrequency multiplier per octave (default: 2.0f).
switch_kx_kyIf true, swaps kx and ky at each octave (default: false).
jitterJitter amount controlling cell randomness (default: {0.5f, 0.5f}).
gammaShape exponent for the dome curvature (default: 1.0f).
angleOrientation angle in degrees for rotating the Voronoi pattern around (0, 0) (default: 0.0f).
p_maskOptional mask array for blending.
p_noise_xOptional noise array for X perturbation.
p_noise_yOptional noise array for Y perturbation.
bboxBounding box for domain mapping (default: {0.f, 1.f, 0.f, 1.f}).
Returns
Filtered array.

Example

#include "highmap.hpp"
int main(void)
{
const glm::ivec2 shape = {512, 512};
const glm::vec2 kw_base = {2.f, 2.f};
const int seed = 42;
// Base terrain heightmap
shape,
kw_base,
seed);
hmap::remap(z0, 0.f, 1.f);
const float amp = 0.15f;
const int octaves = 4;
const float persistence = 0.5f;
const float lacunarity = 2.0f;
const glm::vec2 jitter = {0.6f, 0.6f};
// 1. Isotropic jagged fBm (kw = 6)
auto z1 = hmap::gpu::jagged_fbm(z0,
6.f,
amp,
seed,
octaves,
persistence,
lacunarity,
/* switch_kx_ky */ false,
jitter);
// 2. Anisotropic jagged fBm without switching (kw = {12, 3})
const glm::vec2 kw_aniso = {12.f, 3.f};
auto z2 = hmap::gpu::jagged_fbm(z0,
kw_aniso,
amp,
seed,
octaves,
persistence,
lacunarity,
/* switch_kx_ky */ false,
jitter);
// 3. Anisotropic jagged fBm with switching kx and ky at each octave
auto z3 = hmap::gpu::jagged_fbm(z0,
kw_aniso,
amp,
seed,
octaves,
persistence,
lacunarity,
/* switch_kx_ky */ true,
jitter);
hmap::export_banner_png("ex_jagged_fbm.png",
{z0, z1, z2, z3},
true);
}
Array jagged_fbm(const Array &array, glm::vec2 kw, float amp=0.1f, std::uint32_t seed=0, int octaves=8, float persistence=0.5f, float lacunarity=2.f, bool switch_kx_ky=false, glm::vec2 jitter={0.5f, 0.5f}, float gamma=1.f, float angle=0.f, const Array *p_mask=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Apply a fractal Brownian motion (fBm) version of the Voronoi-based jagged bubble dome filter to an ar...
Definition jagged.cpp:96

Result

◆ jagged_fbm() [2/2]

Array hmap::gpu::jagged_fbm ( const Array & array,
float kw,
float amp = 0.1f,
std::uint32_t seed = 0,
int octaves = 8,
float persistence = 0.5f,
float lacunarity = 2.f,
bool switch_kx_ky = false,
glm::vec2 jitter = {0.5f, 0.5f},
float gamma = 1.f,
float angle = 0.f,
const Array * p_mask = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Apply a fractal Brownian motion (fBm) version of the Voronoi-based jagged bubble dome filter using an isotropic frequency.

Parameters
arrayInput array to be filtered.
kwIsotropic frequency / wave number for Voronoi cells.
ampInitial amplitude of the bubble dome elevation (default: 0.1f).
seedSeed for random jitter of Voronoi cell centers.
octavesNumber of fBm octaves (default: 8).
persistenceAmplitude multiplier per octave (default: 0.5f).
lacunarityFrequency multiplier per octave (default: 2.0f).
switch_kx_kyIf true, swaps kx and ky at each octave (default: false).
jitterJitter amount controlling cell randomness (default: {0.5f, 0.5f}).
gammaShape exponent for the dome curvature (default: 1.0f).
angleOrientation angle in degrees for rotating the Voronoi pattern around (0, 0) (default: 0.0f).
p_maskOptional mask array for blending.
p_noise_xOptional noise array for X perturbation.
p_noise_yOptional noise array for Y perturbation.
bboxBounding box for domain mapping (default: {0.f, 1.f, 0.f, 1.f}).
Returns
Filtered array.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ laplace() [1/2]

void hmap::gpu::laplace ( Array & array,
float sigma = 0.2f,
int iterations = 3 )

◆ laplace() [2/2]

void hmap::gpu::laplace ( Array & array,
const Array * p_mask,
float sigma = 0.2f,
int iterations = 3 )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ mean_shift() [1/2]

Array hmap::gpu::mean_shift ( const Array & array,
int ir,
float talus,
int iterations = 1,
bool talus_weighted = true )

◆ mean_shift() [2/2]

Array hmap::gpu::mean_shift ( const Array & array,
int ir,
float talus,
const Array * p_mask,
int iterations = 1,
bool talus_weighted = true )

◆ median_3x3() [1/2]

void hmap::gpu::median_3x3 ( Array & array)

◆ median_3x3() [2/2]

void hmap::gpu::median_3x3 ( 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.

◆ median_pseudo()

Array hmap::gpu::median_pseudo ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ normal_displacement() [1/2]

void hmap::gpu::normal_displacement ( Array & array,
float amount = 0.1f,
int ir = 0,
bool reverse = false )

◆ normal_displacement() [2/2]

void hmap::gpu::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.

◆ plateau() [1/2]

void hmap::gpu::plateau ( Array & array,
const Array * p_mask,
int ir,
float factor,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ plateau() [2/2]

void hmap::gpu::plateau ( Array & array,
int ir,
float factor,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ project_talus_along_direction() [1/2]

Array hmap::gpu::project_talus_along_direction ( const Array & array,
const Array & talus,
int direction = 0,
float vmin = -FLT_MAX )

Projects array values along a given direction using talus attenuation.

Applies a directional propagation (D8 convention) where values decay with distance according to a talus coefficient. The computation is performed on the GPU using an OpenCL kernel.

Parameters
arrayInput 2D array.
talusTalus coefficient controlling distance-based attenuation.
directionPropagation direction (D8 convention, range [0–7]).
Returns
A new Array containing the projected values.
Note
The array is temporarily shifted to non-negative values to ensure correctness of OpenCL atomic operations on floats.

Example

Result

◆ project_talus_along_direction() [2/2]

Array hmap::gpu::project_talus_along_direction ( const Array & array,
const Array & talus,
const Array * p_mask,
int direction = 0,
float vmin = -FLT_MAX )

◆ recast_cliff() [1/2]

void hmap::gpu::recast_cliff ( Array & array,
float talus,
int ir,
float amplitude,
float gain = 2.f,
int iterations = 500,
Array * p_cliff_mask = nullptr,
int sync_interval = 0,
const UvTile & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

Transform heightmap to add cliffs where gradients are steep enough using Poisson gradient amplification.

Parameters
arrayInput array representing the heightmap to be modified.
talusReference talus angle / slope threshold.
irFilter radius used to smooth the heightmap before applying the cliff effect.
amplitudeAmplitude of the cliffs.
gainGain factor influencing the steepness of the cliffs.
iterationsNumber of Poisson solver iterations (default: 500).
p_cliff_mask[out] Optional pointer to an array that receives the cliff mask.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {1024, 1024};
glm::vec2 res = {4.f, 4.f};
int seed = 0;
float talus = 3.f / shape.x;
int ir = 0;
float amplitude = 2.f;
float gain = 2.f;
// isotropic cliff exaggeration
auto z_cliff = z;
hmap::gpu::recast_cliff(z_cliff, talus, ir, amplitude, gain);
hmap::remap(z_cliff);
// directional cliff exaggeration (angle = 45 deg)
auto z_cliff_dir = z;
float angle = 45.f;
talus,
ir,
amplitude,
angle,
gain);
hmap::remap(z_cliff_dir);
// directional cliff exaggeration with variable (local) angle
auto z_cliff_var = z;
shape,
glm::vec2(2.f, 2.f),
seed + 1);
hmap::remap(angle_field, 0.f, 360.f);
talus,
ir,
amplitude,
angle_field,
gain);
hmap::remap(z_cliff_var);
hmap::export_banner_png("ex_recast_cliff.png",
{z, z_cliff, z_cliff_dir, z_cliff_var},
true);
}
void recast_cliff(Array &array, float talus, int ir, float amplitude, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
Transform heightmap to add cliffs where gradients are steep enough using Poisson gradient amplificati...
Definition recast_cliff.cpp:27
void recast_cliff_directional(Array &array, float talus, int ir, float amplitude, float angle, float gain=2.f, int iterations=500, Array *p_cliff_mask=nullptr, int sync_interval=0, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
Transform heightmap to add directional cliffs where gradients are steep enough using Poisson gradient...
Definition recast_cliff.cpp:166

Result

◆ recast_cliff() [2/2]

void hmap::gpu::recast_cliff ( Array & array,
float talus,
int ir,
float amplitude,
const Array * p_mask,
float gain = 2.f,
int iterations = 500,
Array * p_cliff_mask = nullptr,
int sync_interval = 0,
const UvTile & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ recast_cliff_directional() [1/4]

void hmap::gpu::recast_cliff_directional ( Array & array,
float talus,
int ir,
float amplitude,
float angle,
float gain = 2.f,
int iterations = 500,
Array * p_cliff_mask = nullptr,
int sync_interval = 0,
const UvTile & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

Transform heightmap to add directional cliffs where gradients are steep enough using Poisson gradient amplification.

Parameters
arrayInput array representing the heightmap to be modified.
talusReference talus angle / slope threshold.
irFilter radius used to smooth the heightmap before applying the cliff effect.
amplitudeAmplitude of the cliffs.
angleAngle (in degrees) determining the direction of the cliffs.
gainGain factor influencing the steepness of the cliffs.
iterationsNumber of Poisson solver iterations (default: 500).
p_maskOptional filter mask.
p_cliff_mask[out] Optional pointer to an array that receives the cliff mask.
sync_intervalNumber of iterations between communicator tile syncs.
regionTile region geometry metadata.
commTiled communicator instance.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {1024, 1024};
glm::vec2 res = {4.f, 4.f};
int seed = 0;
float talus = 3.f / shape.x;
int ir = 0;
float amplitude = 2.f;
float gain = 2.f;
// isotropic cliff exaggeration
auto z_cliff = z;
hmap::gpu::recast_cliff(z_cliff, talus, ir, amplitude, gain);
hmap::remap(z_cliff);
// directional cliff exaggeration (angle = 45 deg)
auto z_cliff_dir = z;
float angle = 45.f;
talus,
ir,
amplitude,
angle,
gain);
hmap::remap(z_cliff_dir);
// directional cliff exaggeration with variable (local) angle
auto z_cliff_var = z;
shape,
glm::vec2(2.f, 2.f),
seed + 1);
hmap::remap(angle_field, 0.f, 360.f);
talus,
ir,
amplitude,
angle_field,
gain);
hmap::remap(z_cliff_var);
hmap::export_banner_png("ex_recast_cliff.png",
{z, z_cliff, z_cliff_dir, z_cliff_var},
true);
}

Result

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ recast_cliff_directional() [2/4]

void hmap::gpu::recast_cliff_directional ( Array & array,
float talus,
int ir,
float amplitude,
float angle,
const Array * p_mask,
float gain = 2.f,
int iterations = 500,
Array * p_cliff_mask = nullptr,
int sync_interval = 0,
const UvTile & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ recast_cliff_directional() [3/4]

void hmap::gpu::recast_cliff_directional ( Array & array,
float talus,
int ir,
float amplitude,
const Array & angle,
float gain = 2.f,
int iterations = 500,
Array * p_cliff_mask = nullptr,
int sync_interval = 0,
const UvTile & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ recast_cliff_directional() [4/4]

void hmap::gpu::recast_cliff_directional ( Array & array,
float talus,
int ir,
float amplitude,
const Array & angle,
const Array * p_mask,
float gain = 2.f,
int iterations = 500,
Array * p_cliff_mask = nullptr,
int sync_interval = 0,
const UvTile & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ ridge_accentuate() [1/2]

void hmap::gpu::ridge_accentuate ( Array & array,
float strength = 0.1f,
int ir = 0,
bool reverse = false )

◆ ridge_accentuate() [2/2]

void hmap::gpu::ridge_accentuate ( Array & array,
const Array * p_mask,
float strength = 0.1f,
int ir = 0,
bool reverse = false )

◆ shrink() [1/4]

void hmap::gpu::shrink ( Array & array,
int ir,
int iterations = 1 )

◆ shrink() [2/4]

void hmap::gpu::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.

◆ shrink() [3/4]

void hmap::gpu::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.

◆ shrink() [4/4]

void hmap::gpu::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.

◆ smooth_cpulse()

void hmap::gpu::smooth_cpulse ( Array & array,
int ir,
const Array * p_mask = nullptr,
const UvTile & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

◆ smooth_cpulse_edge_removing()

void hmap::gpu::smooth_cpulse_edge_removing ( Array & array,
float talus,
float talus_width,
int ir )

◆ smooth_fill() [1/2]

void hmap::gpu::smooth_fill ( Array & array,
int ir,
float k = 0.1f,
Array * p_deposition_map = nullptr )

◆ smooth_fill() [2/2]

void hmap::gpu::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.

◆ smooth_fill_holes() [1/2]

void hmap::gpu::smooth_fill_holes ( Array & array,
int ir )

◆ smooth_fill_holes() [2/2]

void hmap::gpu::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.

◆ smooth_fill_smear_peaks() [1/2]

void hmap::gpu::smooth_fill_smear_peaks ( Array & array,
int ir )

◆ smooth_fill_smear_peaks() [2/2]

void hmap::gpu::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.

◆ spectral_equalizer() [1/2]

Array hmap::gpu::spectral_equalizer ( const Array & array,
const std::vector< float > & weights,
int ir_min,
int ir_max )

Spectral equalizer for 2D fields using a multiscale Gaussian pyramid.

Decomposes the input array into log-spaced frequency bands using Gaussian smoothing, then recombines them using normalized user-defined weights.

Parameters
arrayInput 2D field.
weightsSpectral gains (mapped from low to high frequencies).
ir_minMinimum Gaussian radius.
ir_maxMaximum Gaussian radius.
Returns
Filtered array with adjusted spectral content.

Example

Result

◆ spectral_equalizer() [2/2]

Array hmap::gpu::spectral_equalizer ( const Array & array,
const std::vector< float > & weights,
int ir_min,
int ir_max,
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.

◆ voronoi_shrink() [1/5]

Array hmap::gpu::voronoi_shrink ( const Array & array,
glm::vec2 kw,
float shrink_factor = 0.8f,
float fill_value = 0.f,
std::uint32_t seed = 0,
glm::vec2 jitter = {0.5f, 0.5f},
float angle = 0.f,
const Array * p_mask = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Apply a Voronoi shrinker filter to an input heightmap.

Within each Voronoi cell, the input elevation field is shrunk towards the cell center, preserving the shape within the cell while creating rifts or gaps between adjacent Voronoi cells filled with fill_value.

Parameters
arrayInput array representing the heightmap to be filtered.
kwFrequency / wave numbers for the Voronoi grid.
shrink_factorLinear shrinking factor in (0, 1] towards cell centers.
fill_valueValue used to fill the rifts/gaps between shrunken cells.
seedSeed for random jitter of Voronoi cell centers.
jitterJitter amount controlling cell randomness (default: {0.5f, 0.5f}).
angleOrientation angle in degrees for rotating the Voronoi pattern (default: 0.0f).
p_maskOptional mask array for blending.
p_noise_xOptional noise array for X perturbation.
p_noise_yOptional noise array for Y perturbation.
bboxBounding box for domain mapping (default: {0.f, 1.f, 0.f, 1.f}).
Returns
Filtered array with shrunken Voronoi cells.

◆ voronoi_shrink() [2/5]

Array hmap::gpu::voronoi_shrink ( const Array & array,
float kw,
float shrink_factor = 0.8f,
float fill_value = 0.f,
std::uint32_t seed = 0,
glm::vec2 jitter = {0.5f, 0.5f},
float angle = 0.f,
const Array * p_mask = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Apply a Voronoi shrinker filter using an isotropic frequency.

Parameters
arrayInput array representing the heightmap to be filtered.
kwIsotropic frequency / wave number for the Voronoi grid.
shrink_factorLinear shrinking factor in (0, 1] towards cell centers.
fill_valueValue used to fill the rifts/gaps between shrunken cells.
seedSeed for random jitter of Voronoi cell centers.
jitterJitter amount controlling cell randomness (default: {0.5f, 0.5f}).
angleOrientation angle in degrees for rotating the Voronoi pattern (default: 0.0f).
p_maskOptional mask array for blending.
p_noise_xOptional noise array for X perturbation.
p_noise_yOptional noise array for Y perturbation.
bboxBounding box for domain mapping (default: {0.f, 1.f, 0.f, 1.f}).
Returns
Filtered array with shrunken Voronoi cells.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ voronoi_shrink() [3/5]

Array hmap::gpu::voronoi_shrink ( const Array & array,
const Cloud & cloud,
float shrink_factor = 0.8f,
float fill_value = 0.f,
const Array * p_mask = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Apply a Voronoi shrinker filter using a custom cloud of points.

Parameters
arrayInput array representing the heightmap to be filtered.
cloudCloud of 2D points defining the Voronoi cell centers.
shrink_factorLinear shrinking factor in (0, 1] towards cell centers.
fill_valueValue used to fill the rifts/gaps between shrunken cells.
p_maskOptional mask array for blending.
p_noise_xOptional noise array for X perturbation.
p_noise_yOptional noise array for Y perturbation.
bboxBounding box for domain mapping (default: {0.f, 1.f, 0.f, 1.f}).
Returns
Filtered array with shrunken Voronoi cells.

◆ voronoi_shrink() [4/5]

Array hmap::gpu::voronoi_shrink ( const Array & array,
const std::vector< Point > & points,
float shrink_factor = 0.8f,
float fill_value = 0.f,
const Array * p_mask = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Apply a Voronoi shrinker filter using a list of Point objects.

Parameters
arrayInput array representing the heightmap to be filtered.
pointsVector of Point objects defining Voronoi cell centers.
shrink_factorLinear shrinking factor in (0, 1] towards cell centers.
fill_valueValue used to fill the rifts/gaps between shrunken cells.
p_maskOptional mask array for blending.
p_noise_xOptional noise array for X perturbation.
p_noise_yOptional noise array for Y perturbation.
bboxBounding box for domain mapping (default: {0.f, 1.f, 0.f, 1.f}).
Returns
Filtered array with shrunken Voronoi cells.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ voronoi_shrink() [5/5]

Array hmap::gpu::voronoi_shrink ( const Array & array,
const std::vector< glm::vec2 > & points,
float shrink_factor = 0.8f,
float fill_value = 0.f,
const Array * p_mask = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Apply a Voronoi shrinker filter using a list of glm::vec2 coordinates.

Parameters
arrayInput array representing the heightmap to be filtered.
pointsVector of glm::vec2 coordinates defining Voronoi cell centers.
shrink_factorLinear shrinking factor in (0, 1] towards cell centers.
fill_valueValue used to fill the rifts/gaps between shrunken cells.
p_maskOptional mask array for blending.
p_noise_xOptional noise array for X perturbation.
p_noise_yOptional noise array for Y perturbation.
bboxBounding box for domain mapping (default: {0.f, 1.f, 0.f, 1.f}).
Returns
Filtered array with shrunken Voronoi cells.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ path_sdf_bezier_to_array()

Array hmap::gpu::path_sdf_bezier_to_array ( const Path & path,
glm::ivec2 shape,
const UvRect & uv_rect_array = UvRect::unit(),
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr )

◆ path_sdf_to_array()

Array hmap::gpu::path_sdf_to_array ( const Path & path,
glm::ivec2 shape,
const UvRect & uv_rect_array = UvRect::unit(),
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr )

◆ gradient_angle_circular_smoothing()

Array hmap::gpu::gradient_angle_circular_smoothing ( const Array & array,
int ir,
bool downward = false )

◆ laplacian_fract()

Array hmap::gpu::laplacian_fract ( const Array & array,
float s,
int ir )

Compute the fractional Laplacian of an array.

Approximates a non-local Laplacian of order s using a neighborhood of radius ir. The result is unnormalized.

Parameters
arrayInput scalar field.
sFractional order (> 0 and 1 is the standard Laplacian).
irNeighborhood radius.
Returns
Array Fractional Laplacian of array.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 res = {4.f, 4.f};
int seed = 1;
auto d = hmap::laplacian(z);
// same as standard laplacian
auto df0 = hmap::gpu::laplacian_fract(z, /* s */ 1.f, /* ir */ 1);
int ir = 8;
float s = 0.2f; // fractional exponent
auto df1 = hmap::gpu::laplacian_fract(z, s, ir);
hmap::export_banner_png("ex_laplacian.png",
{z, d, df0, df1},
true);
}
Array laplacian_fract(const Array &array, float s, int ir)
Compute the fractional Laplacian of an array.
Definition gradient_gpu.cpp:54
Array laplacian(const Array &array)
Compute the Laplacian of a 2D array.
Definition gradient.cpp:290

Result

◆ phase_averaging()

void hmap::gpu::phase_averaging ( Array & field_real,
Array & field_imag,
int ir )

Apply phase averaging on real and imaginary fields using a GPU kernel.

Parameters
field_realReal component (input/output).
field_imagImaginary component (input/output).
irAveraging radius.

◆ phase_field() [1/2]

Array hmap::gpu::phase_field ( const Array & array,
const glm::vec2 & kw,
std::uint32_t seed,
float kp,
bool rotate90 = false,
float normalization = 1.f,
const glm::vec2 & jitter = {0.5f, 0.5f},
int angle_filter_ir = 8,
const Array * p_ctrl_param = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
Array * p_modulus = nullptr,
Array * p_angle_jump_mask = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Compute a phase field from an input array using local orientation and noise.

Parameters
arrayInput scalar field.
kwWave vector.
seedRandom seed.
kpPhase gain.
rotate90Rotate local angle by 90 degrees if true.
normalizationDegree of normalization applied [0, 1].
jitterJitter applied to sampling.
angle_filter_irRadius for angle filtering.
p_ctrl_paramOptional control parameter field.
p_noise_xOptional noise field (x).
p_noise_yOptional noise field (y).
p_modulusOptional output.
bboxBounding box for evaluation.
Returns
Computed phase field.

Result

◆ phase_field() [2/2]

Array hmap::gpu::phase_field ( const Array & array,
std::uint32_t seed,
float kp_global,
bool rotate90 = false,
float normalization = 1.f,
const glm::vec2 & jitter = {0.5f, 0.5f},
int angle_filter_ir = 8,
const Array * p_ctrl_param = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
Array * p_modulus = nullptr,
Array * p_angle_jump_mask = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Compute a phase field using a global isotropic kp value.

Parameters
arrayInput scalar field.
seedRandom seed.
kp_globalGlobal phase gain.
rotate90Rotate local angle by 90 degrees if true.
normalizationDegree of normalization applied [0, 1].
jitterJitter applied to sampling.
angle_filter_irRadius for angle filtering.
p_ctrl_paramOptional control parameter field.
p_noise_xOptional noise field (x).
p_noise_yOptional noise field (y).
p_modulusOptional output.
bboxBounding box for evaluation.
Returns
Computed phase field.

Result

◆ phase_field_angle()

Array hmap::gpu::phase_field_angle ( const Array & angle,
const glm::vec2 & kw,
std::uint32_t seed,
float kp,
float normalization = 1.f,
const glm::vec2 & jitter = {0.5f, 0.5f},
const Array * p_ctrl_param = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
Array * p_modulus = nullptr,
Array * p_angle_jump_mask = nullptr,
const UvRect & uv_rect = UvRect::unit() )

◆ coastal_fetch()

Array hmap::gpu::coastal_fetch ( const Array & z,
int ndirections,
const Array * p_compute_mask = nullptr )

Computes the omnidirectional coastal fetch for each cell.

Casts ndirections evenly-spaced rays from each cell and averages the distance to the first land obstacle (or domain boundary) across all directions. High values indicate open, wave-exposed coastline; low values indicate sheltered or enclosed areas such as harbors.

Parameters
zInput elevation array.
ndirectionsNumber of ray directions (uniformly distributed over 2Ï€). Higher values improve accuracy at the cost of performance.
p_compute_maskOptional boolean mask; fetch is only evaluated where the mask is true. Pass nullptr to process the entire domain.
Returns
Array of mean fetch values (in grid cells).

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
int ndirections = 128;
// --- base isotropic
hmap::Array f1 = hmap::gpu::coastal_fetch(z, ndirections);
// with compute mask (compute only where mask is positive)
auto cmask = z;
hmap::remap(cmask, -0.5, 0.5f);
hmap::Array f2 = hmap::gpu::coastal_fetch(z, ndirections, &cmask);
// --- directional
float angle = 15.f; // degs
float exp = 1.f; // increase to sharpen selection
angle,
exp,
ndirections);
angle,
4.f * exp,
ndirections);
// --- output (normalized)
hmap::export_banner_png("ex_coastal_fetch.png",
{z, f1, f2, f3, f4},
false,
true);
}
Array coastal_fetch(const Array &z, int ndirections, const Array *p_compute_mask=nullptr)
Computes the omnidirectional coastal fetch for each cell.
Definition coastal_fetch.cpp:17
Array 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.
Definition coastal_fetch.cpp:46

Result

◆ coastal_fetch_directional()

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.

Each ray's fetch contribution is weighted by \( \max(0,\, \cos(\theta - \alpha))^e \), where \(\theta\) is the ray azimuth, \(\alpha\) is angle, and \(e\) is directional_exp. Rays in the back hemisphere are discarded. Increasing directional_exp narrows the effective lobe around the prevailing direction.

Parameters
zInput elevation array.
anglePrevailing direction (radians, trigonometric convention: 0 = East, π/2 = North).
directional_expExponent applied to the cosine weight. Use 1 for a full cosine lobe, 2 to approximate wind-energy weighting, or higher values for a narrower directional response.
ndirectionsNumber of ray directions sampled over 2Ï€.
p_compute_maskOptional boolean mask. Pass nullptr to process the entire domain.
Returns
Array of directionally-weighted fetch values (in grid cells).

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
int ndirections = 128;
// --- base isotropic
hmap::Array f1 = hmap::gpu::coastal_fetch(z, ndirections);
// with compute mask (compute only where mask is positive)
auto cmask = z;
hmap::remap(cmask, -0.5, 0.5f);
hmap::Array f2 = hmap::gpu::coastal_fetch(z, ndirections, &cmask);
// --- directional
float angle = 15.f; // degs
float exp = 1.f; // increase to sharpen selection
angle,
exp,
ndirections);
angle,
4.f * exp,
ndirections);
// --- output (normalized)
hmap::export_banner_png("ex_coastal_fetch.png",
{z, f1, f2, f3, f4},
false,
true);
}

Result

◆ flow_accumulation_from_velocity_field()

Array hmap::gpu::flow_accumulation_from_velocity_field ( const Array & u,
const Array & v,
int iterations )

Approximates flow accumulation from a 2D velocity field.

Advects a scalar accumulation field using an Eulerian transport scheme driven by the velocity components (u, v). Repeated iterations approximate upstream contributing area and highlight flow convergence (thalwegs).

Parameters
uX-component of the flow velocity field.
vY-component of the flow velocity field.
iterationsNumber of transport iterations to perform.
Returns
Flow accumulation field.

◆ flow_accumulation_stochastic()

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.

◆ flow_direction_d8()

Array hmap::gpu::flow_direction_d8 ( const Array & z)

◆ flow_simulation()

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 & region = 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.

Parameters
zTerrain height field.
water_heightGlobal water scaling factor.
depth_mapInitial relative water distribution.
iterationsNumber of simulation steps.
dtTime step size.
flux_diffusionEnables flux smoothing.
flux_diffusion_strengthStrength of flux diffusion.
dry_out_ratioRatio for removing thin remaining water layers.
p_rain_mapOptional spatial precipitation map.
rain_rateContinuous precipitation rate added per timestep.
evap_rateEvaporation rate per timestep.
outflow_boundariesAllows water to freely discharge outside the domain at boundaries.
p_vel_uOptional output array for horizontal velocity field.
p_vel_vOptional output array for vertical velocity field.
Returns
Array Final simulated water depth map.

◆ flow_simulation_viscous()

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 & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

GPU viscous shallow-water flow simulation using non-linear thin-film diffusion with upwind mobility.

Parameters
zTerrain height field.
water_depthGlobal initial water scaling factor.
depth_mapInitial relative water distribution.
iterationsNumber of simulation steps.
dtTime step size (-1 for adaptive).
dry_out_ratioRatio for removing thin remaining water layers.
viscosityFluid dynamic viscosity.
powerNon-linear mobility depth exponent.
evap_rateEvaporation rate per timestep.
outflow_boundariesAllows fluid to freely discharge outside domain at boundaries.
sync_intervalNumber of iterations between communicator tile syncs.
regionTile region geometry metadata.
commTiled communicator instance.
Returns
Array Final simulated water depth map.

◆ generate_riverbed()

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 )

◆ snow_mantle()

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.

Distinct from hydrodynamic snow simulation, this function computes a lightweight, natural surface snow coating influenced by altitude, slope, wind exposure, ridge accumulation, solar melting, micro-texture, and downhill redistribution via mass-preserving GPU thermal transport.

Parameters
zUnderlying terrain heightmap.
strengthOverall snow depth/thickness scaling.
snowlineAltitude above which snow begins to accumulate.
falloffTransition width around the snowline.
talus_coverageExclusion factor for steep slopes (0 = sticks to all slopes, 1 = excluded).
talus_thresholdTalus slope threshold above which snow begins shedding.
directionalWind exposure accumulation factor (leeward gain, windward loss).
wind_directionWind azimuth in degrees.
peaksExtra accumulation factor on ridges and convex peaks.
meltSolar melting factor.
sun_azimuthSun azimuth in degrees for melting.
sun_zenithSun zenith in degrees for melting.
thermal_iterationsIterations of GPU mass-preserving thermal transport (0 disables flow).
thermal_talusRepose talus for snow downhill flow.
coverageCoverage expansion/contraction via thresholding.
p_existing_snowOptional existing snow layer to accumulate upon.
p_maskOptional spatial accumulation mask.
p_noiseOptional external noise array to modulate snow accumulation.
Returns
Snow depth field.

Example

#include "highmap.hpp"
int main(void)
{
const glm::ivec2 shape = {256, 256};
const glm::vec2 kw = {4.f, 4.f};
const int seed = 2;
// Generate synthetic mountain terrain
const float strength = 0.05f;
const float talus = 1.f / float(shape.x);
// Base snow mantle (altitude, slope exclusion, peaks)
strength, // strength
0.45f, // snowline
0.10f, // falloff
0.80f, // talus_coverage
8,
talus, // talus_threshold
0.00f, // directional
0.00f, // wind_direction
0.30f, // peaks
0.00f, // melt
180.f, // sun_azimuth
45.f, // sun_zenith
100, // thermal_iterations
talus, // thermal_talus
0.50f // coverage
);
// Windward vs Leeward directional bias (wind from West -> azimuth 270 deg)
strength,
0.45f,
0.10f,
0.80f,
8,
talus,
1.00f, // directional bias
270.f, // wind azimuth
0.30f,
0.00f,
180.f,
45.f,
0,
talus,
0.50f);
// Optional high-frequency texture noise
shape,
{8.f, 8.f},
seed);
hmap::remap(noise, 0.2f, 1.f);
// Full mantle with solar melt, texture noise, and downhill GPU thermal flow
z,
strength,
0.45f,
0.10f,
0.80f,
8,
talus,
0.40f,
270.f,
0.30f,
0.50f, // melt
180.f,
45.f,
100, // thermal_iterations (GPU thermal_conserve)
talus, // thermal_talus
0.50f,
nullptr,
nullptr,
&noise);
z.dump("z.png");
snow_full.dump("snow_depth.png");
(z + snow_full).dump("z_snow.png");
hmap::export_banner_png("ex_snow_mantle.png",
{z, snow_base, snow_wind, z + snow_full},
return 0;
}
Array 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.
Definition snow_mantle.cpp:22

Result

◆ snow_simulation()

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 & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

Simulate snow accumulation and redistribution over a terrain.

Models snow fall, depth-dependent avalanching (above repose angle) and thermal creep smoothing (below repose angle), with optional melting and post-filtering. Snow progressively stabilizes into smooth, rounded forms.

Parameters
zHeightfield of the underlying terrain.
snow_depthTotal amount of snow to deposit.
fall_mapSpatial modulation of snow deposition.
melting_mapSpatial melting factor in [0,1].
talusLocal repose angle (talus slope).
iterationsNumber of simulation steps.
dtTime step.
fall_iterations_ratioFraction of iterations used for snowfall.
k_snowAvalanche transport coefficient.
k_viscThermal creep (sub-repose smoothing) coefficient.
k_melt_factorGlobal melting strength.
k_depth_ratioControls snow stiffening with depth.
k_depth_slope_ratioDepth influence on repose angle.
post_filterApply final smoothing pass if true.
thermal_talus_ratioControls creep strength relative to talus.
outflow_boundariesAllows snow to freely discharge outside the domain at boundaries.
Returns
Final snow depth field.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 2;
// parameters
const float talus_repose = 2.5f / shape.x;
const int iterations = 500;
const float amount = 1e-1f;
const hmap::Array talus(shape, talus_repose);
// no-melting
z,
amount,
hmap::Array(shape, 1.f), // fall_map
hmap::Array(shape, 0.f), // melting_map
talus,
iterations);
// with melting
z,
amount,
hmap::Array(shape, 1.f), // fall_map
melt_map,
talus,
iterations);
z.dump("z0.png");
(z + snow_depth1).dump("z.png");
snow_depth1.dump("depth.png");
hmap::export_banner_png("ex_snow_simulation.png",
{z, z + snow_depth0, melt_map, z + snow_depth1},
}
Array 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 &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
Simulate snow accumulation and redistribution over a terrain.
Definition snow_simulation.cpp:92
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.
Definition snow_simulation.cpp:29

Result

◆ water_depth_filter()

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.

Parameters
depthWater depth array to filter (in/out).
zElevation array used for filtering.
irFilter radius.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
auto water_depth1 = water_depth0;
auto water_depth2 = water_depth0;
int ir = 32;
hmap::gpu::water_depth_filter(water_depth1, z, ir);
z,
ir,
nullptr,
true); // smooth contour
"ex_water_depth_filter.png",
{z, z + water_depth0, z + water_depth1, z + water_depth2},
}
void 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.
Definition water_depth.cpp:369
Array 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.
Definition flooding.cpp:573

Result

◆ water_frontier_curvature()

Array hmap::gpu::water_frontier_curvature ( const Array & water_depth,
int prefilter_ir,
bool extend_values_from_interface = false )

◆ water_depth_from_mask()

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 )

◆ harmonic_interpolation() [1/2]

Array hmap::gpu::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(),
const Array * p_rhs = nullptr,
bool fix_domain_borders = true )

Perform harmonic interpolation on GPU using Red-Black Successive Over-Relaxation (RB-SOR).

Parameters
arrayInput 2D array providing the initial guess.
mask_fixed_valuesMask array where values > 0 are fixed boundary constraints.
iterations_maxMaximum number of iterations.
toleranceConvergence tolerance for early exit (default: 1e-5). If the maximum update in an iteration check falls below this threshold, the algorithm stops.
omegaRelaxation parameter (1.0 < omega < 2.0). If set to 0.0f (default), the optimal analytical relaxation factor for the grid shape is automatically computed.
Returns
Interpolated array.

◆ harmonic_interpolation() [2/2]

Array hmap::gpu::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 GPU with 2D variable diffusion coefficients (Dx, Dy) using Red-Black SOR.

Parameters
arrayInput 2D array providing the initial guess.
mask_fixed_valuesMask where values > 0 are fixed boundary constraints.
dxArray of diffusion coefficients in x-direction.
dyArray of diffusion coefficients in y-direction.
iterations_maxMaximum number of iterations.
toleranceConvergence tolerance.
omegaRelaxation factor (0 = auto-computed optimal).
Returns
Interpolated array.

◆ biharmonic_interpolation()

Array hmap::gpu::biharmonic_interpolation ( const Array & array,
const Array & mask_fixed_values,
int iterations_max = 1000,
float tolerance = 1e-5f,
float omega = 0.5f,
int sync_interval = 0,
const UvTile & region = UvTile::unit(),
ICommunicator & comm = SingleArrayComm::instance() )

◆ interpolate_array_bicubic() [1/2]

void hmap::gpu::interpolate_array_bicubic ( const Array & source,
Array & target )

◆ interpolate_array_bicubic() [2/2]

void hmap::gpu::interpolate_array_bicubic ( const Array & source,
Array & target,
const UvRect & uv_rect_source,
const UvRect & uv_rect_target )

◆ interpolate_array_bilinear() [1/2]

void hmap::gpu::interpolate_array_bilinear ( const Array & source,
Array & target )

◆ interpolate_array_bilinear() [2/2]

void hmap::gpu::interpolate_array_bilinear ( const Array & source,
Array & target,
const UvRect & uv_rect_source,
const UvRect & uv_rect_target )

◆ interpolate_array_lagrange()

void hmap::gpu::interpolate_array_lagrange ( const Array & source,
Array & target,
int order )

◆ interpolate_array_nearest() [1/2]

void hmap::gpu::interpolate_array_nearest ( const Array & source,
Array & target )

◆ interpolate_array_nearest() [2/2]

void hmap::gpu::interpolate_array_nearest ( const Array & source,
Array & target,
const UvRect & uv_rect_source,
const UvRect & uv_rect_target )

◆ local_aspect_variance()

Array hmap::gpu::local_aspect_variance ( const Array & array,
int ir )

Compute the average local aspect variance of an array.

Parameters
arrayInput array.
irRadius of the local window.
Returns
Array containing the averaged local variance.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 res = {2.f, 2.f};
int seed = 0;
const int ir = 16;
shape,
res,
seed,
8,
0.f);
// smooth lower elevations
auto mask = 1.f - z;
hmap::gpu::smooth_cpulse(z, ir, &mask);
std::vector<hmap::Array> arrays = {z};
std::vector<hmap::gpu::LocalMetrics> metrics = {
};
for (const auto metric : metrics)
{
hmap::Array out = hmap::gpu::local_metrics(z, ir, metric);
arrays.push_back(out);
}
hmap::export_banner_png("ex_local_metrics.png",
arrays,
false,
true);
}
Array local_metrics(const Array &array, int ir, LocalMetrics metric, MinMaxKernel kernel_type=MinMaxKernel::DISK)
Compute a local metric on the input array using a square neighborhood.
Definition local_metrics_wrapper.cpp:10
void smooth_cpulse(Array &array, int ir, const Array *p_mask=nullptr, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
See hmap::smooth_cpulse.
Definition filters_gpu.cpp:514
@ LM_LOCAL_MIN
Local minimum value.
Definition local_metrics.hpp:612
@ LM_RELATIVE_ELEVATION
Normalized elevation.
Definition local_metrics.hpp:620
@ LM_RUGGEDNESS
Measure of terrain roughness.
Definition local_metrics.hpp:622
@ LM_LOCAL_RELIEF
Diff. between local max & min.
Definition local_metrics.hpp:613
@ LM_LOCAL_ASPECT_VARIANCE
Variance of local slope directions.
Definition local_metrics.hpp:609
@ LM_LOCAL_Z_SCORE
Standardized value.
Definition local_metrics.hpp:617
@ LM_RUGOSITY_CONCAVE
Roughness of concave features.
Definition local_metrics.hpp:623
@ LM_TOPOGRAPHIC_POSITION_INDEX
Topographic index.
Definition local_metrics.hpp:618
@ LM_LOCAL_MAX
Local maximum value.
Definition local_metrics.hpp:610
@ LM_LOCAL_VARIANCE
Variance of local values.
Definition local_metrics.hpp:614
@ LM_ROUGHNESS
Local terrain roughness.
Definition local_metrics.hpp:621
@ LM_RUGOSITY_CONVEX
Roughness of convex features.
Definition local_metrics.hpp:624
@ LM_LOCAL_MEAN
Mean of local values.
Definition local_metrics.hpp:615
@ LM_TOPOGRAPHIC_WETNESS_INDEX
Topographic wetness index.
Definition local_metrics.hpp:619
@ LM_LOCAL_MEDIAN_DEVIATION
Deviation from local median.
Definition local_metrics.hpp:611
@ LM_LOCAL_SKEWNESS
Skewness.
Definition local_metrics.hpp:616

Result

◆ local_max()

Array hmap::gpu::local_max ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

Compute the local maximum using the specified kernel footprint.

Parameters
arrayInput array.
irRadius of the kernel footprint.
kernel_typeKernel footprint type (default: MinMaxKernel::DISK).
Returns
Array of local maximum values.

◆ local_max_disk()

Array hmap::gpu::local_max_disk ( const Array & array,
int ir )

Compute the local maximum using a disk kernel.

For each cell, returns the maximum value within a neighborhood of radius ir defined by a disk-shaped kernel.

Parameters
arrayInput array.
irRadius of the disk kernel.
Returns
Array of local maximum values.

Example

Result

◆ local_max_octagon()

Array hmap::gpu::local_max_octagon ( const Array & array,
int ir )

Compute the local maximum using an octagonal kernel approximation via 4 separable 1D passes (horizontal, vertical, and two diagonals).

Parameters
arrayInput array.
irRadius of the octagonal neighborhood footprint.
Returns
Array of local maximum values.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 42;
// input heightmap
const int radius = 12;
// compare exact disk kernel vs separable octagonal approximation vs separable
// square kernel
hmap::Array z_disk = hmap::gpu::local_max(z, radius);
hmap::Array z_octagon = hmap::gpu::local_max_octagon(z, radius);
hmap::export_banner_png("ex_local_max_kernels.png",
{z, z_disk, z_octagon, z_square},
}
Array local_max_octagon(const Array &array, int ir)
Compute the local maximum using an octagonal kernel approximation via 4 separable 1D passes (horizont...
Definition local_metrics_gpu.cpp:65
Array local_max_square(const Array &array, int ir)
Compute the local maximum using a square kernel with a 2-pass separable implementation.
Definition local_metrics_gpu.cpp:133
Array local_max(const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
Compute the local maximum using the specified kernel footprint.
Definition local_metrics_gpu.cpp:32
@ VIRIDIS
Definition colormaps.hpp:95

Result

◆ local_max_square()

Array hmap::gpu::local_max_square ( const Array & array,
int ir )

Compute the local maximum using a square kernel with a 2-pass separable implementation.

Parameters
arrayInput array.
irRadius of the square kernel footprint.
Returns
Array of local maximum values.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 42;
// input heightmap
const int radius = 12;
// compare exact disk kernel vs separable octagonal approximation vs separable
// square kernel
hmap::Array z_disk = hmap::gpu::local_max(z, radius);
hmap::Array z_octagon = hmap::gpu::local_max_octagon(z, radius);
hmap::export_banner_png("ex_local_max_kernels.png",
{z, z_disk, z_octagon, z_square},
}

Result

◆ local_median_deviation()

Array hmap::gpu::local_median_deviation ( const Array & array,
int ir )

◆ local_min()

Array hmap::gpu::local_min ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

Compute the local minimum using the specified kernel footprint.

Parameters
arrayInput array.
irRadius of the kernel footprint.
kernel_typeKernel footprint type (default: MinMaxKernel::DISK).
Returns
Array of local minimum values.

◆ local_min_disk()

Array hmap::gpu::local_min_disk ( const Array & array,
int ir )

Compute the local minimum using a disk kernel.

For each cell, returns the minimum value within a neighborhood of radius ir defined by a disk-shaped kernel.

Parameters
arrayInput array.
irRadius of the disk kernel.
Returns
Array of local minimum values.

Example

Result

◆ local_min_octagon()

Array hmap::gpu::local_min_octagon ( const Array & array,
int ir )

Compute the local minimum using an octagonal kernel approximation via 4 separable 1D passes (horizontal, vertical, and two diagonals).

Parameters
arrayInput array.
irRadius of the octagonal neighborhood footprint.
Returns
Array of local minimum values.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 42;
// input heightmap
const int radius = 12;
// compare exact disk kernel vs separable octagonal approximation vs separable
// square kernel
hmap::Array z_disk = hmap::gpu::local_max(z, radius);
hmap::Array z_octagon = hmap::gpu::local_max_octagon(z, radius);
hmap::export_banner_png("ex_local_max_kernels.png",
{z, z_disk, z_octagon, z_square},
}

Result

◆ local_min_square()

Array hmap::gpu::local_min_square ( const Array & array,
int ir )

Compute the local minimum using a square kernel with a 2-pass separable implementation.

Parameters
arrayInput array.
irRadius of the square kernel footprint.
Returns
Array of local minimum values.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 42;
// input heightmap
const int radius = 12;
// compare exact disk kernel vs separable octagonal approximation vs separable
// square kernel
hmap::Array z_disk = hmap::gpu::local_max(z, radius);
hmap::Array z_octagon = hmap::gpu::local_max_octagon(z, radius);
hmap::export_banner_png("ex_local_max_kernels.png",
{z, z_disk, z_octagon, z_square},
}

Result

◆ local_relief()

Array hmap::gpu::local_relief ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

Compute the local relief of an array.

The local relief is defined as the difference between the maximum and minimum values within a neighborhood of radius ir around each element. This provides a measure of local variation in the array (e.g., terrain ruggedness).

Parameters
arrayInput array representing scalar values (e.g., elevation map).
irRadius of the neighborhood (in pixels) used to compute local extrema.
kernel_typeKernel footprint type (default: MinMaxKernel::DISK).
Returns
Array An array of the same size as array, where each element contains the difference between the local maximum and minimum within the specified neighborhood.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 res = {4.f, 4.f};
int seed = 1;
int ir = 16;
// gpu version
hmap::export_banner_png("ex_local_relief.png", {z, z1}, hmap::Cmap::JET);
}
Array local_relief(const Array &array, int ir, MinMaxKernel kernel_type=MinMaxKernel::DISK)
Compute the local relief of an array.
Definition local_metrics_gpu.cpp:315

Result

◆ local_variance()

Array hmap::gpu::local_variance ( const Array & array,
int ir )

Compute the average local variance of an array.

Local variance is defined as the standard deviation within a window of radius ir centered on each cell. The function computes this value for every cell, then returns the average over the entire domain.

Parameters
arrayInput array.
irRadius of the local window.
Returns
Array containing the averaged local variance.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 res = {4.f, 4.f};
int seed = 1;
int ir = 16;
// gpu version
hmap::export_banner_png("ex_local_variance.png", {z, z1}, hmap::Cmap::JET);
}
Array local_variance(const Array &array, int ir)
Compute the average local variance of an array.
Definition local_metrics_gpu.cpp:342

Result

◆ local_mean()

Array hmap::gpu::local_mean ( const Array & array,
int ir )

◆ local_skewness()

Array hmap::gpu::local_skewness ( const Array & array,
int ir )

◆ local_z_score()

Array hmap::gpu::local_z_score ( const Array & array,
int ir )

Compute the local z-score of an array.

For each cell, computes the normalized difference between its value and the mean of a neighborhood of radius ir.

Parameters
arrayInput array.
irRadius of the local window.
Returns
Array of local z-score values.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 res = {4.f, 4.f};
int seed = 1;
int ir = 16;
// gpu version
hmap::export_banner_png("ex_local_z_score.png", {z, z1}, hmap::Cmap::JET);
}
Array local_z_score(const Array &array, int ir)
Compute the local z-score of an array.
Definition local_metrics_gpu.cpp:362

Result

◆ topographic_position_index()

Array hmap::gpu::topographic_position_index ( const Array & array,
int ir )

Compute the Topographic Position Index (TPI).

TPI measures the elevation difference between each cell and the mean elevation within a neighborhood of radius ir.

Parameters
arrayInput elevation array.
irRadius of the neighborhood.
Returns
Array of TPI values.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 res = {4.f, 4.f};
int seed = 1;
int ir = 16;
// gpu version
hmap::export_banner_png("ex_topographic_position_index.png",
{z, z1},
}
Array topographic_position_index(const Array &array, int ir)
Compute the Topographic Position Index (TPI).
Definition local_metrics_gpu.cpp:473

Result

◆ relative_elevation()

Array hmap::gpu::relative_elevation ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ relative_elevation_square_kernel()

Array hmap::gpu::relative_elevation_square_kernel ( const Array & array,
int ir )

◆ roughness()

Array hmap::gpu::roughness ( const Array & array,
int ir )

◆ ruggedness()

Array hmap::gpu::ruggedness ( const Array & array,
int ir )

◆ rugosity()

Array hmap::gpu::rugosity ( const Array & z,
int ir,
bool convex = true )

◆ topographic_residual()

Array hmap::gpu::topographic_residual ( const Array & z,
int ir,
bool normalize_output = false )

◆ valley_width()

Array hmap::gpu::valley_width ( const Array & z,
int ir = 0,
bool ridge_select = false )

◆ local_metrics()

Array hmap::gpu::local_metrics ( const Array & array,
int ir,
LocalMetrics metric,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

Compute a local metric on the input array using a square neighborhood.

Applies the selected local statistic or terrain descriptor (e.g. mean, variance, ruggedness) over a neighborhood of radius ir.

Parameters
arrayInput array to analyze.
irRadius of the square neighborhood.
metricLocal metric to compute.
Returns
Array Output array containing the computed metric.

Example

Result

See unit tests: test_local_metrics.cpp

◆ sparse_max_convolution() [1/2]

Array hmap::gpu::sparse_max_convolution ( const Array & array,
const Array & kernel,
bool scale_kernel_with_value = true,
float k_smoothmax = 0.f )

Apply a sparse max-convolution.

This operator propagates the non-zero values of the input array through a spatial kernel using a max-reduction instead of a summation. For each non-zero value of the input array, the kernel is centered at the sample position and contributes to the output through a weighted maximum.

The operation is conceptually similar to a sparse morphological dilation or a max-convolution.

Parameters
arrayInput sparse scalar field.
kernelPropagation kernel.
scale_kernel_with_valueIf true, the effective kernel size is scaled according to the local input value. Larger values propagate over a larger neighborhood, while smaller values use a reduced kernel support. If false, the full kernel size is used everywhere.
k_smoothmaxSmooth maximum factor.
Returns
Sparse max-convolved array.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
int seed = 0;
// --- generate mask
hmap::BBox2D bbox = {0.f, 1.f, 0.f, 1.f};
hmap::Path path = hmap::Path(10, seed, hmap::BBox2D(0.1f, 0.9f, 0.1f, 0.9f));
path.reorder_nns();
auto mask = hmap::bezier(path).to_array(shape, bbox);
hmap::clamp_min(mask, 0.f);
// --- splat kernel
glm::ivec2 kernel_shape = {64, 64};
hmap::Array kernel = hmap::cubic_pulse(kernel_shape);
auto z = hmap::gpu::sparse_max_convolution(mask, kernel);
hmap::export_banner_png("ex_sparse_max_convolution.png",
{mask, z},
}
Represents an ordered set of points in 2D, forming a polyline (open or closed).
Definition path.hpp:43
void to_array(Array &array, const BBox2D &bbox=BBox2D{}, bool filled=false) const
Project path points to an array.
Definition path.cpp:547
void reorder_nns(int start_index=0)
Reorder points using a nearest neighbor search.
Definition path.cpp:350
Array sparse_max_convolution(const Array &array, const Array &kernel, bool scale_kernel_with_value=true, float k_smoothmax=0.f)
Apply a sparse max-convolution.
Definition sparse_max_convolution.cpp:15
void clamp_min(Array &array, float vmin)
Clamp array values lower than a given bound.
Definition range.cpp:155
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.
Definition path_functions.cpp:51
Axis-aligned 2D bounding box in world coordinates.
Definition bbox2d.hpp:25

Result

◆ sparse_max_convolution() [2/2]

Array hmap::gpu::sparse_max_convolution ( const Array & array_values,
const Array & array_sizes,
const Array & kernel,
float k_smoothmax = 0.f )

◆ border()

Array hmap::gpu::border ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ closing()

Array hmap::gpu::closing ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ closing_by_reconstruction()

Array hmap::gpu::closing_by_reconstruction ( const Array & array,
int ir,
float k_smooth_max = 0.f,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ contour_smoothing()

Array hmap::gpu::contour_smoothing ( const Array & array,
int ir,
float transition_ratio = 0.1f )

◆ dilation()

Array hmap::gpu::dilation ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ dilation_expand_border_only()

Array hmap::gpu::dilation_expand_border_only ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ distance_transform_jfa()

Array hmap::gpu::distance_transform_jfa ( const Array & array,
bool return_squared_distance = false )

Return the Euclidean distance transform.

(Almost) exact transform based on the jump flooding algorithm.

Parameters
arrayInput array to be transformed, will be converted into binary: 1 wherever input is greater than 0, 0 elsewhere.
return_squared_distanceWhether the distance returned is squared or not.
Returns
Array Reference to the output array.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {2048, 2048};
// shape = {4096, 4096};
glm::vec2 res = {4.f, 4.f};
int seed = 1;
hmap::clamp_min(z, 0.f);
hmap::Timer::Start("approx.");
hmap::Timer::Stop("approx.");
hmap::Timer::Start("manhattan");
hmap::Timer::Stop("manhattan");
z.to_png("ex_distance_transform0.png", hmap::Cmap::VIRIDIS);
d0.to_png("ex_distance_transform1.png", hmap::Cmap::VIRIDIS);
d1.to_png("ex_distance_transform2.png", hmap::Cmap::VIRIDIS);
d2.to_png("ex_distance_transform3.png", hmap::Cmap::VIRIDIS);
d3.to_png("ex_distance_transform4.png", hmap::Cmap::VIRIDIS);
}
static void Stop(const std::string &name)
Stops the timer for the specified event name.
Definition timer.cpp:59
static void Start(const std::string &name)
Starts a timer for the specified event name.
Definition timer.cpp:54
Array distance_transform_jfa(const Array &array, bool return_squared_distance=false)
Return the Euclidean distance transform.
Definition distance_transform_jfa.cpp:18
Array distance_transform_approx(const Array &array, bool return_squared_distance=false)
Calculates an approximate distance transform of the input array.
Definition distance_transform_approx.cpp:15
Array distance_transform(const Array &array, bool return_squared_distance=false, const UvTile &region=UvTile::dummy(), ICommunicator &comm=SingleArrayComm::instance())
Return the Euclidean distance transform.
Definition distance_transform.cpp:27
Array distance_transform_manhattan(const Array &array, bool return_squared_distance=false)
Calculates the Manhattan distance transform of an array.
Definition distance_transform_approx.cpp:59

Result

◆ erosion()

Array hmap::gpu::erosion ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ morphological_black_hat()

Array hmap::gpu::morphological_black_hat ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ morphological_gradient()

Array hmap::gpu::morphological_gradient ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ morphological_laplacian()

Array hmap::gpu::morphological_laplacian ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ morphological_top_hat()

Array hmap::gpu::morphological_top_hat ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ opening()

Array hmap::gpu::opening ( const Array & array,
int ir,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ opening_by_reconstruction()

Array hmap::gpu::opening_by_reconstruction ( const Array & array,
int ir,
float k_smooth_min = 0.f,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ reconstruction_by_dilation()

Array hmap::gpu::reconstruction_by_dilation ( const Array & marker,
const Array & mask,
int ir,
float k_smooth_min = 0.f,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ reconstruction_by_erosion()

Array hmap::gpu::reconstruction_by_erosion ( const Array & marker,
const Array & mask,
int ir,
float k_smooth_max = 0.f,
MinMaxKernel kernel_type = MinMaxKernel::DISK )

◆ relative_distance_from_skeleton() [1/2]

Array hmap::gpu::relative_distance_from_skeleton ( const Array & array,
int ir_search,
bool zero_at_borders = true,
int ir_erosion = 1 )

◆ relative_distance_from_skeleton() [2/2]

Array hmap::gpu::relative_distance_from_skeleton ( const Array & array,
const Array & skeleton,
int ir_search,
int ir_erosion = 1 )

◆ signed_curvature_from_distance()

Array hmap::gpu::signed_curvature_from_distance ( const Array & array,
int prefilter_ir = 0 )

◆ signed_distance_transform()

Array hmap::gpu::signed_distance_transform ( const Array & array,
int prefilter_ir = 0 )

◆ skeleton()

Array hmap::gpu::skeleton ( const Array & array,
bool zero_at_borders = true )

◆ morphological_operators()

Array hmap::gpu::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.).

Parameters
arrayInput array to process.
irRadius of the square structuring element.
operationMorphological operation to apply.
Returns
Array Resulting array after applying the operation.

◆ helper_bind_optional_buffer()

void hmap::gpu::helper_bind_optional_buffer ( clwrapper::Run & run,
const std::string & id,
const Array * p_array )

◆ init_opencl()

bool hmap::gpu::init_opencl ( )

◆ gabor_wave() [1/2]

Array hmap::gpu::gabor_wave ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
const Array & angle,
float angle_spread_ratio = 1.f,
const UvRect & uv_rect = UvRect::unit() )

Return an array filled with coherence Gabor noise.

Parameters
shapeArray shape.
kwNoise wavenumbers {kx, ky} for each directions.
seedRandom seed number.
angleBase orientation angle for the Gabor wavelets (in radians). Defaults to 0.
angle_spread_ratioRatio that controls the spread of wave orientations around the base angle. Defaults to 1.
bboxDomain bounding box.
Returns
Array Fractal noise.
Note
Taken from https://www.shadertoy.com/view/clGyWm
Only available if OpenCL is enabled.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 1;
// --- base
hmap::Array z = hmap::gpu::gabor_wave(shape, kw, seed);
hmap::Array z_fbm = hmap::gpu::gabor_wave_fbm(shape, kw, seed);
// --- angle control
float angle = 45.f;
float angle_spread_ratio = 0.f;
{16.f, 16.f},
seed,
angle_spread_ratio);
hmap::Array za1 = hmap::gpu::gabor_wave(shape, {16.f, 16.f}, seed, 0.f, 0.5f);
{16.f, 16.f},
seed,
0.f,
0.1f);
// --- local angle
hmap::Array field = hmap::noise(hmap::NoiseType::PERLIN, shape, kw, seed);
hmap::Array array_angle = hmap::gradient_angle(field) * 180.f / 3.14159f;
angle_spread_ratio = 0.f;
{16.f, 16.f},
seed,
array_angle,
angle_spread_ratio);
{16.f, 16.f},
seed,
array_angle,
angle_spread_ratio);
hmap::export_banner_png("ex_gabor_wave.png",
{z, z_fbm, za0, za1, za2, zr1, zr2},
true);
}
Array gabor_wave_fbm(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, const Array &angle, float angle_spread_ratio=1.f, 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())
Return an array filled with coherence Gabor noise.
Definition primitives_gpu.cpp:102
Array gabor_wave(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, const Array &angle, float angle_spread_ratio=1.f, const UvRect &uv_rect=UvRect::unit())
Return an array filled with coherence Gabor noise.
Definition primitives_gpu.cpp:54
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.
Definition noise.cpp:17
Array gradient_angle(const Array &array, bool downward=false)
Compute the polar angle of the gradient of a 2D array.
Definition gradient.cpp:73

Result

◆ gabor_wave() [2/2]

Array hmap::gpu::gabor_wave ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float angle = 0.f,
float angle_spread_ratio = 1.f,
const UvRect & uv_rect = UvRect::unit() )

◆ gabor_wave_fbm() [1/2]

Array hmap::gpu::gabor_wave_fbm ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
const Array & angle,
float angle_spread_ratio = 1.f,
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() )

Return an array filled with coherence Gabor noise.

Parameters
shapeArray shape.
kwNoise wavenumbers {kx, ky} for each directions.
seedRandom seed number.
angleBase orientation angle for the Gabor wavelets (in radians). Defaults to 0.
angle_spread_ratioRatio that controls the spread of wave orientations around the base angle. Defaults to 1.
octavesNumber of octaves.
weigthOctave weighting.
persistenceOctave persistence.
lacunarityDefines the wavenumber ratio between each octaves.
p_ctrl_paramReference to the control parameter array (acts as a multiplier for the weight parameter).
p_noise_x,p_noise_yReference to the input noise arrays.
bboxDomain bounding box.
Returns
Array Fractal noise.
Note
Taken from https://www.shadertoy.com/view/clGyWm
Only available if OpenCL is enabled.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 1;
// --- base
hmap::Array z = hmap::gpu::gabor_wave(shape, kw, seed);
hmap::Array z_fbm = hmap::gpu::gabor_wave_fbm(shape, kw, seed);
// --- angle control
float angle = 45.f;
float angle_spread_ratio = 0.f;
{16.f, 16.f},
seed,
angle_spread_ratio);
hmap::Array za1 = hmap::gpu::gabor_wave(shape, {16.f, 16.f}, seed, 0.f, 0.5f);
{16.f, 16.f},
seed,
0.f,
0.1f);
// --- local angle
hmap::Array field = hmap::noise(hmap::NoiseType::PERLIN, shape, kw, seed);
hmap::Array array_angle = hmap::gradient_angle(field) * 180.f / 3.14159f;
angle_spread_ratio = 0.f;
{16.f, 16.f},
seed,
array_angle,
angle_spread_ratio);
{16.f, 16.f},
seed,
array_angle,
angle_spread_ratio);
hmap::export_banner_png("ex_gabor_wave.png",
{z, z_fbm, za0, za1, za2, zr1, zr2},
true);
}

Result

◆ gabor_wave_fbm() [2/2]

Array hmap::gpu::gabor_wave_fbm ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float angle = 0.f,
float angle_spread_ratio = 1.f,
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() )

◆ gavoronoise() [1/3]

Array hmap::gpu::gavoronoise ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
const Array & angle,
float amplitude = 0.05f,
float angle_spread_ratio = 1.f,
glm::vec2 kw_multiplier = {4.f, 4.f},
float slope_strength = 1.f,
float branch_strength = 2.f,
float z_cut_min = 0.2f,
float z_cut_max = 1.f,
int octaves = 8,
float persistence = 0.4f,
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() )

Generates a 2D array using the GavoroNoise algorithm, which is a procedural noise technique for terrain generation and other applications.

Parameters
shapeDimensions of the output array.
kwWave number vector controlling the noise frequency.
seedSeed value for random number generation.
amplitudeAmplitude of the noise.
kw_multiplierMultiplier for wave numbers in the noise function.
slope_strengthStrength of slope-based directional erosion in the noise.
branch_strengthStrength of branch-like structures in the generated noise.
z_cut_minMinimum cutoff for Z-value in the noise.
z_cut_maxMaximum cutoff for Z-value in the noise.
octavesNumber of octaves for fractal Brownian motion (fBm).
persistenceAmplitude scaling factor between noise octaves.
lacunarityFrequency scaling factor between noise octaves.
p_ctrl_paramOptional array for control parameters, can modify the Z cutoff dynamically.
p_noise_xOptional array for X-axis noise perturbation.
p_noise_yOptional array for Y-axis noise perturbation.
bboxBounding box for mapping grid coordinates to world space.
Returns
A 2D array containing the generated GavoroNoise values.
Note
Taken from https://www.shadertoy.com/view/MtGcWh
Only available if OpenCL is enabled.

This function leverages an OpenCL kernel to compute the GavoroNoise values on the GPU, allowing for efficient large-scale generation. The kernel applies a combination of fractal Brownian motion (fBm), directional erosion, and other procedural techniques to generate intricate noise patterns.

The optional p_ctrl_param, p_noise_x, and p_noise_y buffers provide additional flexibility for dynamically adjusting noise parameters and perturbations.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 1;
// --- base usage
hmap::Array z1 = hmap::gpu::gavoronoise(shape, kw, seed);
float amp = 0.05f;
float angle = 45.f;
float angle_spread_ratio = 0.f;
kw,
seed,
angle,
amp,
angle_spread_ratio);
// --- with input base noise
int octaves = 2;
shape,
kw,
++seed,
octaves);
// base amplitude amplitude expected to be in [-1, 1] (approx.)
hmap::remap(base, -1.f, 1.f);
hmap::Array z3 = hmap::gpu::gavoronoise(base, kw, seed, amp);
// --- local angle
hmap::Array field = hmap::noise(hmap::NoiseType::PERLIN, shape, kw, seed);
hmap::Array array_angle = hmap::gradient_angle(field) * 180.f / 3.14159f;
angle_spread_ratio = 0.f;
{8.f, 8.f},
seed,
array_angle,
amp,
angle_spread_ratio);
hmap::export_banner_png("ex_gavoronoise.png",
{z1, z2, z3, z4},
true);
}
Array gavoronoise(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, const Array &angle, float amplitude=0.05f, float angle_spread_ratio=1.f, glm::vec2 kw_multiplier={4.f, 4.f}, float slope_strength=1.f, float branch_strength=2.f, float z_cut_min=0.2f, float z_cut_max=1.f, int octaves=8, float persistence=0.4f, 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())
Generates a 2D array using the GavoroNoise algorithm, which is a procedural noise technique for terra...
Definition primitives_gpu.cpp:196

Result

◆ gavoronoise() [2/3]

Array hmap::gpu::gavoronoise ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float angle = 0.f,
float amplitude = 0.05f,
float angle_spread_ratio = 1.f,
glm::vec2 kw_multiplier = {4.f, 4.f},
float slope_strength = 1.f,
float branch_strength = 2.f,
float z_cut_min = 0.2f,
float z_cut_max = 1.f,
int octaves = 8,
float persistence = 0.4f,
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() )

◆ gavoronoise() [3/3]

Array hmap::gpu::gavoronoise ( const Array & base,
glm::vec2 kw,
std::uint32_t seed,
float amplitude = 0.05f,
glm::vec2 kw_multiplier = {4.f, 4.f},
float slope_strength = 1.f,
float branch_strength = 2.f,
float z_cut_min = 0.2f,
float z_cut_max = 1.f,
int octaves = 8,
float persistence = 0.4f,
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() )

◆ noise()

Array hmap::gpu::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(),
glm::ivec2 period = {0, 0},
float angle = 0.f,
float stretch = 1.f )

See hmap::noise. period sets the tiling period in lattice cells. For the heightmap to be periodic with respect to the full domain, period must be equal to the wavenumber kw, i.e. period = {round(kw.x), round(kw.y)}; a smaller period makes the pattern repeat within the domain. A component <= 0 disables wrapping on that axis (default {0, 0}: non-periodic). Tiling is exact only for lattice noise types with integer kw; simplex is never wrapped.

◆ noise_fbm()

Array hmap::gpu::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(),
glm::ivec2 period = {0, 0},
float angle = 0.f,
float stretch = 1.f,
float stretch_decay = 0.f )

See hmap::noise_fbm. period sets the tiling period in lattice cells for the base octave. For the heightmap to be periodic with respect to the full domain, period must be equal to the wavenumber kw, i.e. period = {round(kw.x), round(kw.y)}; a smaller period makes the pattern repeat within the domain. A component <= 0 disables wrapping on that axis (default {0, 0}: non-periodic). Seamless tiling additionally requires an integer lacunarity (the default 2); simplex is never wrapped.

◆ noise_slope()

Array hmap::gpu::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(),
glm::ivec2 period = {0, 0},
float angle = 0.f,
float stretch = 1.f,
float stretch_decay = 0.f )

See hmap::noise_slope. period sets the tiling period in lattice cells for the base octave.

◆ phasor()

Array hmap::gpu::phasor ( PhasorProfile phasor_profile,
glm::ivec2 shape,
float kp_global,
std::uint32_t seed,
float angle_shift = 0.f,
float normalization = 1.f,
const glm::vec2 jitter = {1.f, 1.f},
float delta = 0.01f,
float phase_smoothing = 10.f,
const Array * p_angle = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a procedural phasor-based pattern.

Produces a directional, phase-driven field using a selected profile, optional angle control, and spatial distortion noise.

Parameters
phasor_profilePhasor shaping profile.
shapeOutput array dimensions.
kp_globalGlobal frequency factor.
seedRandom seed.
angle_shiftGlobal phase angle offset (degrees).
n_kernel_samplesNumber of kernel samples.
jitterSampling jitter (x,y).
deltaFinite difference step.
phase_smoothingPhase smoothing factor.
p_angleOptional external angle field.
p_noise_xOptional X distortion field.
p_noise_yOptional Y distortion field.
bboxDomain bounding box.
Returns
Array Generated phasor field.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {1024, 1024};
float kp = 16.f;
std::uint32_t seed = 0;
std::vector<hmap::PhasorProfile> profiles = {
};
std::vector<hmap::Array> arrays;
for (auto p : profiles)
{
shape,
kp,
seed,
/* angle_shift */ 15.f);
arrays.push_back(z);
}
// fbm phasor
shape,
kp,
seed,
/* angle_shift */ 15.f);
arrays.push_back(z);
hmap::export_banner_png("ex_phasor.png",
arrays,
false,
true);
}
Array phasor(PhasorProfile phasor_profile, glm::ivec2 shape, float kp_global, std::uint32_t seed, float angle_shift=0.f, float normalization=1.f, const glm::vec2 jitter={1.f, 1.f}, float delta=0.01f, float phase_smoothing=10.f, const Array *p_angle=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Generates a procedural phasor-based pattern.
Definition phasor.cpp:18
Array phasor_fbm(PhasorProfile phasor_profile, glm::ivec2 shape, float kp_global, std::uint32_t seed, float angle_shift=0.f, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, float normalization=1.f, const glm::vec2 jitter={1.f, 1.f}, float delta=0.01f, float phase_smoothing=10.f, const Array *p_angle=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Generates a multi-octave (fBm) phasor-based pattern.
Definition phasor.cpp:79
@ PP_COSINE_PEAKY
Definition profiles.hpp:40
@ PP_COSINE_BULKY
Definition profiles.hpp:39
@ PP_TRIANGLE
Definition profiles.hpp:43
@ PP_COSINE_SQUARE
Definition profiles.hpp:41
@ PP_COSINE_STD
Definition profiles.hpp:42

Result

◆ phasor_fbm()

Array hmap::gpu::phasor_fbm ( PhasorProfile phasor_profile,
glm::ivec2 shape,
float kp_global,
std::uint32_t seed,
float angle_shift = 0.f,
int octaves = 8,
float weight = 0.7f,
float persistence = 0.5f,
float lacunarity = 2.f,
float normalization = 1.f,
const glm::vec2 jitter = {1.f, 1.f},
float delta = 0.01f,
float phase_smoothing = 10.f,
const Array * p_angle = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a multi-octave (fBm) phasor-based pattern.

Accumulates several scaled phasor layers using persistence and lacunarity for richer multi-scale structure.

Parameters
phasor_profilePhasor shaping profile.
shapeOutput array dimensions.
kp_globalBase frequency factor.
seedRandom seed.
angle_shiftGlobal phase angle offset (degrees).
octavesNumber of fBm layers.
weightInitial octave weight.
persistenceAmplitude multiplier per octave.
lacunarityFrequency multiplier per octave.
normalizationDegree of normalization applied [0, 1].
jitterSampling jitter (x,y).
deltaFinite difference step.
phase_smoothingPhase smoothing factor.
p_angleOptional external angle field.
p_noise_xOptional X distortion field.
p_noise_yOptional Y distortion field.
bboxDomain bounding box.
Returns
Array Generated multi-scale phasor field.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {1024, 1024};
float kp = 16.f;
std::uint32_t seed = 0;
std::vector<hmap::PhasorProfile> profiles = {
};
std::vector<hmap::Array> arrays;
for (auto p : profiles)
{
shape,
kp,
seed,
/* angle_shift */ 15.f);
arrays.push_back(z);
}
// fbm phasor
shape,
kp,
seed,
/* angle_shift */ 15.f);
arrays.push_back(z);
hmap::export_banner_png("ex_phasor.png",
arrays,
false,
true);
}

Result

◆ vorolines()

Array hmap::gpu::vorolines ( glm::ivec2 shape,
float density,
std::uint32_t seed,
float k_smoothing = 0.f,
float exp_sigma = 0.f,
float alpha = 0.f,
float alpha_span = cte::pi,
VoronoiReturnType return_type = VoronoiReturnType::F1_SQUARED,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit(),
const UvRect & uv_rect_points = UvRect::unit() )

Generates a Voronoi-based pattern where cells are defined by proximity to random lines.

This function generates an OpenCL-accelerated Voronoi-like pattern based on the distance from each pixel to a set of randomly oriented lines. Each line is defined by a random point and a direction sampled from a uniform distribution around a given angle.

Parameters
shapeThe resolution of the resulting 2D array (width, height).
densityNumber of base points per unit area used to define lines.
seedSeed for the random number generator used to generate base points and directions.
k_smoothingKernel smoothing factor; controls how sharp or soft the distance fields are.
exp_sigmaExponential smoothing parameter applied to the computed distance field.
alphaBase angle (in radians) used to orient the generated lines.
alpha_spanMaximum angular deviation from alpha; controls line orientation variability.
return_typeType of Voronoi output to return (e.g., F1, F2, edge distance, smoothed field, etc.).
p_noise_xOptional pointer to an input noise field applied to the X coordinates (can be nullptr).
p_noise_yOptional pointer to an input noise field applied to the Y coordinates (can be nullptr).
bboxBounding box in normalized coordinates (min_x, max_x, min_y, max_y) of the final array.
bbox_pointsBounding box within which random base points are sampled.
Returns
A 2D array (of type Array) containing the computed distance field based on line proximity.
Note
Each line is defined from a point (x, y) to a direction offset using angle theta = alpha + rand * alpha_span.
The OpenCL kernel "vorolines" must be defined and compiled beforehand.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
int seed = 1;
float density = 8.f;
float k_smoothing = 0.005f;
float exp_sigma = 0.01f;
float alpha = 0.f;
float alpha_span = 0.5f * M_PI;
std::vector<hmap::VoronoiReturnType> types = {
std::vector<hmap::Array> zs = {};
for (auto type : types)
{
density,
seed,
k_smoothing,
exp_sigma,
alpha,
alpha_span,
type);
z = sqrt(z);
zs.push_back(z);
}
hmap::export_banner_png("ex_vorolines.png", zs, hmap::Cmap::INFERNO);
// FBM
zs = {};
for (auto type : types)
{
density,
seed,
k_smoothing,
exp_sigma,
alpha,
alpha_span,
type);
z = sqrt(z);
zs.push_back(z);
}
hmap::export_banner_png("ex_vorolines_fbm.png", zs, hmap::Cmap::INFERNO);
}
Array vorolines(glm::ivec2 shape, float density, std::uint32_t seed, float k_smoothing=0.f, float exp_sigma=0.f, float alpha=0.f, float alpha_span=cte::pi, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), const UvRect &uv_rect_points=UvRect::unit())
Generates a Voronoi-based pattern where cells are defined by proximity to random lines.
Definition primitives_gpu.cpp:899
Array vorolines_fbm(glm::ivec2 shape, float density, std::uint32_t seed, float k_smoothing=0.f, float exp_sigma=0.f, float alpha=0.f, float alpha_span=cte::pi, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), const UvRect &uv_rect_points=UvRect::unit())
Generates a Voronoi-based pattern using distances to lines defined by random points and angles,...
Definition primitives_gpu.cpp:985
Array sqrt(const Array &array)
Square root.
Definition math.cpp:616
@ EDGE_DISTANCE_SQUARED
Squared edge distance.
Definition coherent_noise.hpp:37
@ F1_SQUARED
Returns F1^2.
Definition coherent_noise.hpp:31
@ CONSTANT_F2MF1_SQUARED
Constant × (F2 - F1)^2.
Definition coherent_noise.hpp:39
@ F2_SQUARED
Returns F2^2.
Definition coherent_noise.hpp:32
@ CONSTANT
Constant value.
Definition coherent_noise.hpp:38
@ F1TF2_SQUARED
Returns (F1 * F2)^2.
Definition coherent_noise.hpp:33
@ F2MF1_SQUARED
Returns (F2 - F1)^2.
Definition coherent_noise.hpp:35
@ F1DF2_SQUARED
Returns (F1 / F2)^2.
Definition coherent_noise.hpp:34
@ EDGE_DISTANCE_EXP
Exponential edge distance.
Definition coherent_noise.hpp:36
@ INFERNO
Definition colormaps.hpp:87

Result

◆ vorolines_fbm()

Array hmap::gpu::vorolines_fbm ( glm::ivec2 shape,
float density,
std::uint32_t seed,
float k_smoothing = 0.f,
float exp_sigma = 0.f,
float alpha = 0.f,
float alpha_span = cte::pi,
VoronoiReturnType return_type = VoronoiReturnType::F1_SQUARED,
int octaves = 8,
float weight = 0.7f,
float persistence = 0.5f,
float lacunarity = 2.f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit(),
const UvRect & uv_rect_points = UvRect::unit() )

Generates a Voronoi-based pattern using distances to lines defined by random points and angles, with additional fractal Brownian motion (fBm) noise modulation.

This function extends the standard vorolines generation by introducing fBm-based warping of the coordinate space, resulting in more organic and fractal-like structures. It creates a Voronoi distance field based on proximity to oriented line segments and distorts the result using multi-octave procedural noise.

Parameters
shapeOutput resolution of the 2D array (width, height).
densityNumber of base points per unit area used to define lines.
seedSeed value for the random number generator.
k_smoothingKernel smoothing coefficient to soften distance values (e.g., for blending).
exp_sigmaSigma value for optional exponential smoothing on the final field.
alphaBase orientation angle (in radians) of lines generated from random points.
alpha_spanMaximum angle deviation from alpha, determining directional randomness of lines.
return_typeType of output to return (e.g., F1, F2, distance to edge, smoothed version).
octavesNumber of noise octaves used in the fBm modulation.
weightWeight of each octave's contribution to the total noise.
persistenceAmplitude decay factor for each successive octave (commonly 0.5–0.8).
lacunarityFrequency multiplier for each successive octave (commonly 2.0).
p_noise_xOptional pointer to an external noise field applied to X coordinates (can be nullptr).
p_noise_yOptional pointer to an external noise field applied to Y coordinates (can be nullptr).
bboxBounding box for the final image domain (min_x, max_x, min_y, max_y).
bbox_pointsBounding box from which the initial set of points are sampled.
Returns
A 2D Array representing the Voronoi-fBm field, distorted by noise and influenced by distance to random lines.
Note
This version uses internally computed fBm noise unless external fields (p_noise_x, p_noise_y) are provided.
This function requires an OpenCL kernel named "vorolines_fbm" to be compiled and accessible.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
int seed = 1;
float density = 8.f;
float k_smoothing = 0.005f;
float exp_sigma = 0.01f;
float alpha = 0.f;
float alpha_span = 0.5f * M_PI;
std::vector<hmap::VoronoiReturnType> types = {
std::vector<hmap::Array> zs = {};
for (auto type : types)
{
density,
seed,
k_smoothing,
exp_sigma,
alpha,
alpha_span,
type);
z = sqrt(z);
zs.push_back(z);
}
hmap::export_banner_png("ex_vorolines.png", zs, hmap::Cmap::INFERNO);
// FBM
zs = {};
for (auto type : types)
{
density,
seed,
k_smoothing,
exp_sigma,
alpha,
alpha_span,
type);
z = sqrt(z);
zs.push_back(z);
}
hmap::export_banner_png("ex_vorolines_fbm.png", zs, hmap::Cmap::INFERNO);
}

Result

◆ voronoi()

Array hmap::gpu::voronoi ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
glm::vec2 jitter = {0.5f, 0.5f},
float bias = 0.f,
float k_smoothing = 0.f,
float exp_sigma = 0.f,
VoronoiReturnType return_type = VoronoiReturnType::F1_SQUARED,
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 Voronoi diagram in a 2D array with configurable properties.

Parameters
shapeThe dimensions of the output array as a 2D vector of integers.
kwThe frequency scale factors for the Voronoi cells, given as a 2D vector of floats.
seedA seed value for random number generation, ensuring reproducibility.
jitter(Optional) The amount of random variation in the positions of Voronoi cell sites, given as a 2D vector of floats. Defaults to {0.5f, 0.5f}.
bias(Optional) Reach bonus bias for additively weighted Voronoi partitioning. Defaults to 0.f.
return_type(Optional) The type of value to compute for the Voronoi diagram. Defaults to VoronoiReturnType::F1_SQUARED.
p_ctrl_param(Optional) A pointer to an Array used to control the Voronoi computation. Used here as a multiplier for the jitter. If nullptr, no control is applied.
p_noise_x(Optional) A pointer to an Array providing additional noise in the x-direction for cell positions. If nullptr, no x-noise is applied.
p_noise_y(Optional) A pointer to an Array providing additional noise in the y-direction for cell positions. If nullptr, no y-noise is applied.
bbox(Optional) The bounding box for the Voronoi computation, given as a 4D vector of floats representing {min_x, max_x, min_y, max_y}. Defaults to {0.f, 1.f, 0.f, 1.f}.
Returns
A 2D array representing the generated Voronoi diagram.
Note
Only available if OpenCL is enabled.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {8.f, 8.f};
int seed = 1;
glm::vec2 jitter = {1.f, 1.f};
float k_smoothing = 0.f;
float exp_sigma = 0.05f;
std::vector<hmap::VoronoiReturnType> types = {
std::vector<hmap::Array> zs = {};
for (auto type : types)
{
kw,
seed,
jitter,
/* bias */ 0.f,
k_smoothing,
exp_sigma,
type);
zs.push_back(z);
}
for (auto type : types)
{
kw,
seed,
jitter,
/* bias */ 0.f,
k_smoothing,
exp_sigma,
type);
zs.push_back(z);
}
}
Array voronoi(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, glm::vec2 jitter={0.5f, 0.5f}, float bias=0.f, float k_smoothing=0.f, float exp_sigma=0.f, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, 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 Voronoi diagram in a 2D array with configurable properties.
Definition primitives_gpu.cpp:1034
Array voronoi_fbm(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, glm::vec2 jitter={0.5f, 0.5f}, float bias=0.f, float k_smoothing=0.f, float exp_sigma=0.f, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, 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())
Generates a Voronoi diagram in a 2D array with configurable properties.
Definition primitives_gpu.cpp:1084

Result

◆ voronoi_fbm()

Array hmap::gpu::voronoi_fbm ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
glm::vec2 jitter = {0.5f, 0.5f},
float bias = 0.f,
float k_smoothing = 0.f,
float exp_sigma = 0.f,
VoronoiReturnType return_type = VoronoiReturnType::F1_SQUARED,
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() )

Generates a Voronoi diagram in a 2D array with configurable properties.

Parameters
shapeThe dimensions of the output array as a 2D vector of integers.
kwThe frequency scale factors for the base Voronoi cells, given as a 2D vector of floats.
seedA seed value for random number generation, ensuring reproducibility.
jitter(Optional) The amount of random variation in the positions of Voronoi cell sites, given as a 2D vector of floats. Defaults to {0.5f, 0.5f}.
bias(Optional) Reach bonus bias for additively weighted Voronoi partitioning. Defaults to 0.f.
return_type(Optional) The type of value to compute for the Voronoi diagram. Defaults to VoronoiReturnType::F1_SQUARED.
octaves(Optional) The number of layers (octaves) in the fractal Brownian motion. Defaults to 8.
weight(Optional) The initial weight of the base layer in the FBM computation. Defaults to 0.7f.
persistence(Optional) The persistence factor that controls the amplitude reduction between octaves. Defaults to 0.5f.
lacunarity(Optional) The lacunarity factor that controls the frequency increase between octaves. Defaults to 2.f.
p_ctrl_param(Optional) A pointer to an Array used to control the Voronoi computation. If nullptr, no control is applied.
p_noise_x(Optional) A pointer to an Array providing additional noise in the x-direction for cell positions. If nullptr, no x-noise is applied.
p_noise_y(Optional) A pointer to an Array providing additional noise in the y-direction for cell positions. If nullptr, no y-noise is applied.
bbox(Optional) The bounding box for the Voronoi computation, given as a 4D vector of floats representing {min_x, max_x, min_y, max_y}. Defaults to {0.f, 1.f, 0.f, 1.f}.
Returns
A 2D array representing the generated Voronoi diagram.
Note
Only available if OpenCL is enabled.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {8.f, 8.f};
int seed = 1;
glm::vec2 jitter = {1.f, 1.f};
float k_smoothing = 0.f;
float exp_sigma = 0.05f;
std::vector<hmap::VoronoiReturnType> types = {
std::vector<hmap::Array> zs = {};
for (auto type : types)
{
kw,
seed,
jitter,
/* bias */ 0.f,
k_smoothing,
exp_sigma,
type);
zs.push_back(z);
}
for (auto type : types)
{
kw,
seed,
jitter,
/* bias */ 0.f,
k_smoothing,
exp_sigma,
type);
zs.push_back(z);
}
}

Result

◆ voronoi_edge_distance()

Array hmap::gpu::voronoi_edge_distance ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
glm::vec2 jitter = {0.5f, 0.5f},
float bias = 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() )

Computes the Voronoi edge distance.

Parameters
shapeThe shape of the grid as a 2D vector (width, height).
kwThe weights for the Voronoi kernel as a 2D vector.
seedThe random seed used for generating Voronoi points.
jitterOptional parameter for controlling jitter in Voronoi point placement (default is {0.5f, 0.5f}).
biasOptional reach bonus bias for weighted Voronoi partitioning (default is 0.f).
p_ctrl_paramOptional pointer to an Array specifying control parameters for Voronoi grid jitter (default is nullptr).
p_noise_x,p_noise_yReference to the input noise arrays.
bboxThe bounding box for the Voronoi diagram as {x_min, x_max, y_min, y_max} (default is {0.f, 1.f, 0.f, 1.f}).
Note
Taken from https://www.shadertoy.com/view/llG3zy
Only available if OpenCL is enabled.
The resulting Array has the same dimensions as the input shape.

◆ voronoise()

Array hmap::gpu::voronoise ( glm::ivec2 shape,
glm::vec2 kw,
float u_param,
float v_param,
std::uint32_t seed,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a 2D Voronoi noise array.

This function computes a Voronoi noise pattern based on the input parameters and returns it as a 2D array. The noise is calculated in the OpenCL kernel noise_voronoise, which uses a combination of hashing and smoothstep functions to generate a weighted Voronoi noise field.

Note
Taken from https://www.shadertoy.com/view/Xd23Dh
Only available if OpenCL is enabled.
Parameters
shapeThe dimensions of the 2D output array as a vector (width and height).
kwWave numbers for scaling the noise pattern, represented as a 2D vector.
u_paramA control parameter for the noise, adjusting the contribution of random offsets.
v_paramA control parameter for the noise, affecting the smoothness of the pattern.
p_ctrl_paramOptional pointer to an Array specifying control parameters for Voronoi grid jitter (default is nullptr).
p_noise_x,p_noise_yReference to the input noise arrays.
seedA seed value for random number generation, ensuring reproducibility.
Returns
An Array object containing the generated 2D Voronoi noise values.

Example

Result

◆ voronoise_fbm()

Array hmap::gpu::voronoise_fbm ( glm::ivec2 shape,
glm::vec2 kw,
float u_param,
float v_param,
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() )

Return an array filled with coherence Voronoise.

Parameters
shapeArray shape.
kwNoise wavenumbers {kx, ky} for each directions.
seedRandom seed number.
octavesNumber of octaves.
weigthOctave weighting.
persistenceOctave persistence.
lacunarityDefines the wavenumber ratio between each octaves.
p_ctrl_paramReference to the control parameter array (acts as a multiplier for the weight parameter).
p_noise_x,p_noise_yReference to the input noise arrays.
bboxDomain bounding box.
Returns
Array Fractal noise.
Note
Taken from https://www.shadertoy.com/view/clGyWm
Only available if OpenCL is enabled.

Example

Result

◆ vororand() [1/2]

Array hmap::gpu::vororand ( glm::ivec2 shape,
float density,
float variability,
std::uint32_t seed,
float k_smoothing = 0.f,
float exp_sigma = 0.f,
VoronoiReturnType return_type = VoronoiReturnType::F1_SQUARED,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit(),
const UvRect & uv_rect_points = UvRect::unit() )

Generates a 2D Voronoi-based scalar field using OpenCL.

This function computes a Voronoi diagram or derived metric (such as F1, F2, or edge distances) on a grid of given shape. A set of random points is generated within an extended bounding box, based on the desired density and variability, to reduce edge artifacts. Optionally, per-pixel displacement can be applied through noise fields.

The result is stored in an Array object representing a 2D scalar field.

Parameters
shapeDimensions of the output array (width x height).
densityNumber of random points per unit area for Voronoi diagram.
variabilityAmount of randomness added to the point generation bounding box.
seedSeed for random number generation used in point sampling.
k_smoothingSmoothing factor used in soft minimum/maximum Voronoi distance computations.
exp_sigmaStandard deviation used in exponential falloff for edge distance computation.
return_typeType of Voronoi computation to perform (e.g., F1, F2, F2-F1, edge distance).
p_noise_xOptional pointer to a noise field applied to X coordinates of grid points.
p_noise_yOptional pointer to a noise field applied to Y coordinates of grid points.
bboxBounding box of the domain in which the field is computed: {xmin, xmax, ymin, ymax}.
bbox_pointsBounding box for point generation, usually larger than bbox to avoid edge effects.
Returns
An Array object containing the computed scalar field.
Note
  • The kernel "vororand" must be compiled and available in the OpenCL context.
  • If p_noise_x or p_noise_y are provided, they must match the shape of the output array.
  • The generated point cloud will be larger than bbox to reduce border artifacts.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
float density = 8.f;
float variability = 4.f;
int seed = 1;
float k_smoothing = 0.05f;
float exp_sigma = 0.01f;
std::vector<hmap::VoronoiReturnType> types = {
std::vector<hmap::Array> zs = {};
for (auto type : types)
{
density,
variability,
seed,
k_smoothing,
exp_sigma,
type);
zs.push_back(z);
}
}
Array vororand(glm::ivec2 shape, float density, float variability, std::uint32_t seed, float k_smoothing=0.f, float exp_sigma=0.f, VoronoiReturnType return_type=VoronoiReturnType::F1_SQUARED, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit(), const UvRect &uv_rect_points=UvRect::unit())
Generates a 2D Voronoi-based scalar field using OpenCL.
Definition primitives_gpu.cpp:1277

Result

◆ vororand() [2/2]

Array hmap::gpu::vororand ( glm::ivec2 shape,
const std::vector< float > & xp,
const std::vector< float > & yp,
float k_smoothing = 0.f,
float exp_sigma = 0.f,
VoronoiReturnType return_type = VoronoiReturnType::F1_SQUARED,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

◆ wavelet_noise()

Array hmap::gpu::wavelet_noise ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float kw_multiplier = 2.f,
float vorticity = 0.f,
float density = 1.f,
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() )

Generates 2D wavelet noise using an OpenCL kernel.

This function creates a 2D noise field of the given shape using multi-octave wavelet turbulence. The noise is computed on the GPU via the "wavelet_noise" OpenCL kernel. Various parameters control the frequency evolution, amplitude decay, vorticity injection, and optional modulation using additional input arrays.

Parameters
shapeResolution of the output noise array (width, height).
kwBase wave number (frequency) in each axis. Controls the initial spatial frequency of the wavelet field.
seedInteger seed used by the random hashing functions inside the kernel.
kw_multiplierMultiplier applied to the wave number per octave (similar to gain). Higher values increase frequency growth across octaves.
vorticityAmount of rotational distortion injected into the noise. When > 0, the kernel applies additional angular perturbations to produce turbulent flow-like patterns.
densityGlobal scaling factor controlling the overall contrast or amplitude of the generated noise.
octavesNumber of wavelet noise layers combined. Higher octaves yield more detail but increase computational cost.
weightWeight applied to the base octave, used as a global intensity multiplier before persistence attenuation is applied.
persistenceAmplitude decay factor per octave. Values in (0,1) produce the classic fractal noise falloff; higher values retain more high-frequency detail.
lacunarityFrequency multiplier per octave. Controls how rapidly frequency increases at each octave, with typical values in the range [1.5, 3.0].
p_ctrl_paramOptional pointer to a control-parameter array. When provided, values inside this array modulate the generated noise spatially. Pass nullptr to disable this feature.
p_noise_xOptional pointer to an auxiliary noise array used to perturb sampling positions horizontally. Pass nullptr to disable.
p_noise_yOptional pointer to an auxiliary noise array used to perturb sampling positions vertically. Pass nullptr to disable.
bboxBounding-box mapping (xmin, ymin, xmax, ymax). Converts pixel-space indices into world-space coordinates for spatially consistent noise.
Returns
Array A 2D floating-point array containing the generated wavelet noise.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
int seed = 1;
hmap::Array z = hmap::gpu::wavelet_noise(shape, kw, seed);
hmap::export_banner_png("ex_wavelet_noise.png", {z}, hmap::Cmap::JET);
}
Array wavelet_noise(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float kw_multiplier=2.f, float vorticity=0.f, float density=1.f, 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())
Generates 2D wavelet noise using an OpenCL kernel.
Definition primitives_gpu.cpp:1378

Result

◆ hemisphere_field()

Array hmap::gpu::hemisphere_field ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float rmin = 0.05f,
float rmax = 0.8f,
float amplitude_random_ratio = 1.f,
float density = 0.1f,
glm::vec2 jitter = {1.f, 1.f},
float shift = 0.f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const Array * p_noise_distance = nullptr,
const Array * p_density_multiplier = nullptr,
const Array * p_size_multiplier = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a scalar field representing the signed distance to randomly generated hemispheres.

Parameters
shapeResolution of the output field (width, height).
kwScaling factor for field coordinates (world units per pixel).
seedRandom seed generation.
rminMinimum sphere radius (relative to bbox size).
rmaxMaximum sphere radius (relative to bbox size).
densityFraction of pixels covered by polygons (approximate).
jitterRandom displacement factor applied to sphere vertices.
shiftRandom position shift applied to sphere center.
p_noise_xOptional displacement noise field in the X direction (nullptr to disable).
p_noise_yOptional displacement noise field in the Y direction (nullptr to disable).
bboxBounding box in normalized coordinates {xmin, xmax, ymin, ymax}.
Returns
Array 2D array containing the signed distance field.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 1;
z.to_png("ex_phemisphere_field.png", hmap::Cmap::VIRIDIS);
}
Array hemisphere_field(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float rmin=0.05f, float rmax=0.8f, float amplitude_random_ratio=1.f, float density=0.1f, glm::vec2 jitter={1.f, 1.f}, float shift=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_noise_distance=nullptr, const Array *p_density_multiplier=nullptr, const Array *p_size_multiplier=nullptr, const UvRect &uv_rect=UvRect::unit())
Generates a scalar field representing the signed distance to randomly generated hemispheres.
Definition primitives_gpu.cpp:375

Result

◆ hemisphere_field_fbm()

Array hmap::gpu::hemisphere_field_fbm ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float rmin = 0.05f,
float rmax = 0.8f,
float amplitude_random_ratio = 1.f,
float density = 0.1f,
glm::vec2 jitter = {0.5f, 0.5f},
float shift = 0.1f,
int octaves = 8,
float persistence = 0.5f,
float lacunarity = 2.f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const Array * p_noise_distance = nullptr,
const Array * p_density_multiplier = nullptr,
const Array * p_size_multiplier = nullptr,
const UvRect & uv_rect = UvRect::unit() )

See hmap::hemisphere_field.

◆ multisteps()

Array hmap::gpu::multisteps ( glm::ivec2 shape,
float angle,
std::uint32_t seed,
glm::vec2 kw = {2.f, 2.f},
float noise_amp = 0.1f,
float noise_rugosity = 0.f,
bool noise_inflate = true,
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 glm::vec2 & center = {0.5f, 0.5f},
const BBox2D & bbox = BBox2D::unit() )

GPU-accelerated multi-step height generation with procedural noise.

Builds the same multi-step profile as the CPU version but injects a Voronoi-FBM noise field to modulate the step positions. Noise can be inflated or deflated and is projected onto the step axis before being passed to the CPU multisteps() implementation.

Parameters
shapeOutput array resolution.
angleRotation angle in degrees.
seedNoise seed.
kwBase wave numbers for noise.
noise_ampAmplitude of injected noise.
noise_rugosityRoughness of the FBM noise.
noise_inflateWhether to invert noise direction.
rGeometric ratio between steps.
nstepsNumber of steps.
elevation_exponentExponent shaping step heights.
shape_gainGain used to reshape intra-step transitions.
scaleScale of the step axis.
outer_slopeSlope outside the [0,1] axis interval.
p_ctrl_paramOptional control parameter array.
centerCenter of the step axis.
bboxBounding box of the domain.
Returns
Generated Array.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
auto z1 = hmap::multisteps(shape, 10.f);
// with built-in default noise
std::uint32_t seed = 0;
auto z2 = hmap::gpu::multisteps(shape, 10.f, seed);
hmap::export_banner_png("ex_multisteps.png", {z1, z2}, hmap::Cmap::INFERNO);
}
Array multisteps(glm::ivec2 shape, float angle, std::uint32_t seed, glm::vec2 kw={2.f, 2.f}, float noise_amp=0.1f, float noise_rugosity=0.f, bool noise_inflate=true, 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 glm::vec2 &center={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit())
GPU-accelerated multi-step height generation with procedural noise.
Definition multisteps.cpp:93
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 &center={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit())
Generate a multi-step height profile along a rotated axis.
Definition multisteps.cpp:18

Result

◆ polygon_field()

Array hmap::gpu::polygon_field ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float rmin = 0.05f,
float rmax = 0.8f,
float clamping_dist = 0.1f,
float clamping_k = 0.1f,
int n_vertices_min = 3,
int n_vertices_max = 16,
float density = 0.5f,
glm::vec2 jitter = {0.5f, 0.5f},
float shift = 0.1f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const Array * p_noise_distance = nullptr,
const Array * p_density_multiplier = nullptr,
const Array * p_size_multiplier = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a scalar field representing the signed distance to randomly generated polygons.

This function procedurally generates a field where each pixel stores the signed distance to the nearest polygon, using a smooth signed distance function (SDF) with optional clamping. The polygons are generated randomly within the specified bounding box, with configurable vertex counts, sizes, jitter, and density. Optionally, displacement noise fields can be applied to polygon positions.

Parameters
shapeResolution of the output field (width, height).
kwScaling factor for field coordinates (world units per pixel).
seedRandom seed for polygon generation.
rminMinimum polygon radius (relative to bbox size).
rmaxMaximum polygon radius (relative to bbox size).
clamping_distDistance threshold for clamping the SDF value (used to soften edges).
clamping_kSmoothness parameter for clamping.
n_vertices_minMinimum number of vertices per polygon.
n_vertices_maxMaximum number of vertices per polygon.
densityFraction of pixels covered by polygons (approximate).
jitterRandom displacement factor applied to polygon vertices.
shiftRandom position shift applied to polygon center.
p_noise_xOptional displacement noise field in the X direction (nullptr to disable).
p_noise_yOptional displacement noise field in the Y direction (nullptr to disable).
bboxBounding box in normalized coordinates {xmin, xmax, ymin, ymax}.
Returns
Array 2D array containing the signed distance field.
Note
Polygons are randomly generated per call and are not guaranteed to be convex.
The sign of the SDF is negative inside polygons and positive outside.

Example

Result

◆ polygon_field_fbm()

Array hmap::gpu::polygon_field_fbm ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float rmin = 0.05f,
float rmax = 0.8f,
float clamping_dist = 0.1f,
float clamping_k = 0.1f,
int n_vertices_min = 3,
int n_vertices_max = 16,
float density = 0.1f,
glm::vec2 jitter = {0.5f, 0.5f},
float shift = 0.1f,
int octaves = 8,
float persistence = 0.5f,
float lacunarity = 2.f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const Array * p_noise_distance = nullptr,
const Array * p_density_multiplier = nullptr,
const Array * p_size_multiplier = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a scalar field representing the signed distance to randomly generated polygons combined with fractal Brownian motion (fBm) noise modulation.

Similar to polygon_field(), but the generated SDF is modulated by an fBm noise function to create more natural, irregular shapes. The fBm parameters allow control over the noise persistence, lacunarity, and number of octaves.

Parameters
shapeResolution of the output field (width, height).
kwScaling factor for field coordinates (world units per pixel).
seedRandom seed for polygon generation and fBm noise.
rminMinimum polygon radius (relative to bbox size).
rmaxMaximum polygon radius (relative to bbox size).
clamping_distDistance threshold for clamping the SDF value (used to soften edges).
clamping_kSmoothness parameter for clamping.
n_vertices_minMinimum number of vertices per polygon.
n_vertices_maxMaximum number of vertices per polygon.
densityFraction of pixels covered by polygons (approximate).
jitterRandom displacement factor applied to polygon vertices.
shiftRandom position shift applied to polygon center.
octavesNumber of fBm octaves.
persistenceAmplitude decay per octave in fBm.
lacunarityFrequency multiplier per octave in fBm.
p_noise_xOptional displacement noise field in the X direction (nullptr to disable).
p_noise_yOptional displacement noise field in the Y direction (nullptr to disable).
bboxBounding box in normalized coordinates {xmin, xmax, ymin, ymax}.
Returns
Array 2D array containing the signed distance field modulated by fBm.
Note
The sign of the SDF is negative inside polygons and positive outside.

Example

Result

◆ badlands()

Array hmap::gpu::badlands ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
int octaves = 8,
float rugosity = 0.2f,
float angle = 30.f,
float bias = 0.f,
float k_smoothing = 0.1f,
float base_noise_amp = 0.2f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a synthetic "badlands" terrain heightmap.

This function procedurally creates a 2D elevation field resembling badlands (highly eroded terrain with sharp ridges and valleys). It combines fractal noise (FBM) with a Voronoi-based primitive, displaced along a specified orientation.

Parameters
shapeOutput array shape (resolution in x and y).
kwFrequency vector controlling the scale of the features.
seedRandom seed used for noise and Voronoi generation.
rugosityControls roughness of the fractal noise (higher = more irregular).
angleOrientation angle (degrees) of terrain displacements.
biasReach bonus bias for weighted Voronoi partitioning.
k_smoothingVoronoi smoothing parameter (controls ridge sharpness).
base_noise_ampAmplitude of the base displacement noise.
p_noise_xOptional pointer to external displacement noise field (X-axis).
p_noise_yOptional pointer to external displacement noise field (Y-axis).
bboxBounding box of the generation domain in normalized coordinates.
Returns
Array containing the generated badlands heightmap.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {2.f, 2.f};
std::uint32_t seed = 0;
hmap::Array z1 = hmap::gpu::badlands(shape, kw, seed);
hmap::export_banner_png("ex_badlands.png", {z1}, hmap::Cmap::TERRAIN, true);
}
Array badlands(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, int octaves=8, float rugosity=0.2f, float angle=30.f, float bias=0.f, float k_smoothing=0.1f, float base_noise_amp=0.2f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Generates a synthetic "badlands" terrain heightmap.
Definition badlands.cpp:16

Result

◆ basalt_field()

Array hmap::gpu::basalt_field ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float warp_kw = 4.f,
float large_scale_warp_amp = 0.2f,
float large_scale_gain = 6.f,
float large_scale_amp = 0.2f,
float medium_scale_kw_ratio = 3.f,
float medium_scale_warp_amp = 1.f,
float medium_scale_gain = 7.f,
float medium_scale_amp = 0.08f,
float small_scale_kw_ratio = 10.f,
float small_scale_amp = 0.1f,
float small_scale_overlay_amp = 0.002f,
float rugosity_kw_ratio = 1.f,
float rugosity_amp = 1.f,
bool flatten_activate = true,
float flatten_kw_ratio = 1.f,
float flatten_amp = 0.f,
float bias = 0.f,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a synthetic procedural terrain resembling basaltic landforms.

This function creates a multi-scale procedural field combining large, medium, and small-scale Voronoi-based patterns, noise warping, and optional flattening, simulating the morphology of fractured basalt or volcanic terrains. The terrain is constructed using a combination of Voronoi diagrams (via voronoi_fbm) and fractal noise (noise_fbm), layered with frequency-domain manipulations and amplitude/gain controls at each scale.

The final output is a heightmap represented as an Array, normalized and composed of:

  • Large-scale cellular patterns with smoothed Voronoi edge distances.
  • Medium and small-scale structures introducing finer surface variation.
  • Optional rugosity (fine detail) and flattening to simulate erosion or flow effects.
Parameters
shapeOutput resolution (width x height) of the field.
kwBase wave numbers (frequency) for the terrain features.
seedInitial seed used for deterministic random generation.
warp_kwFrequency of the warping noise that displaces Voronoi positions.
large_scale_warp_ampAmplitude of displacement for large-scale Voronoi warping.
large_scale_gainGain adjustment applied to the large-scale features.
large_scale_ampFinal amplitude of the large-scale height contribution.
medium_scale_kw_ratioScaling factor for the frequency of the medium-scale patterns.
medium_scale_warp_ampAmplitude of warping for the medium-scale displacement.
medium_scale_gainGain control for medium-scale modulation.
medium_scale_ampAmplitude of the medium-scale heightmap.
small_scale_kw_ratioFrequency ratio for small-scale details.
small_scale_ampAmplitude of small-scale pattern contribution.
small_scale_overlay_ampAdditional overlay strength for repeating the small-scale pattern.
rugosity_kw_ratioFrequency ratio for high-frequency noise applied as fine roughness.
rugosity_ampStrength of the rugosity (high-frequency modulation).
flatten_activateEnables or disables the final flattening operation.
flatten_kw_ratioFrequency scaling of the flattening noise field.
flatten_ampAmplitude control of the flattening operation.
biasReach bonus bias for weighted Voronoi partitioning.
p_noise_xOptional pointer to a noise field used to displace grid coordinates in X.
p_noise_yOptional pointer to a noise field used to displace grid coordinates in Y.
bboxThe 2D bounding box ({xmin, xmax, ymin, ymax}) over which the terrain is generated.
Returns
A procedurally generated Array representing the synthetic basalt-like terrain field.
Note
  • This function relies on OpenCL-based kernels via the gpu:: namespace.
  • The returned field is normalized in amplitude but may require rescaling to match specific physical units.
  • Adjusting seed, warp_kw, and the gain/amplitude values can produce a wide variety of terrain features.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
int seed = 0;
hmap::Array z = hmap::gpu::basalt_field(shape, kw, seed);
hmap::export_banner_png("ex_basalt_field.png",
{z},
true);
}
Array basalt_field(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float warp_kw=4.f, float large_scale_warp_amp=0.2f, float large_scale_gain=6.f, float large_scale_amp=0.2f, float medium_scale_kw_ratio=3.f, float medium_scale_warp_amp=1.f, float medium_scale_gain=7.f, float medium_scale_amp=0.08f, float small_scale_kw_ratio=10.f, float small_scale_amp=0.1f, float small_scale_overlay_amp=0.002f, float rugosity_kw_ratio=1.f, float rugosity_amp=1.f, bool flatten_activate=true, float flatten_kw_ratio=1.f, float flatten_amp=0.f, float bias=0.f, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Generates a synthetic procedural terrain resembling basaltic landforms.
Definition basalt_field.cpp:18

Result

◆ island() [1/2]

Array hmap::gpu::island ( const Array & land_mask,
const Array * p_noise_r = nullptr,
float apex_elevation = 1.f,
bool filter_distance = true,
int filter_ir = 32,
float slope_min = 0.1f,
float slope_max = 8.f,
float slope_start = 0.5f,
float slope_end = 1.f,
float slope_noise_intensity = 0.5f,
float k_smooth = 0.05f,
float radial_noise_intensity = 0.3f,
float radial_profile_gain = 2.f,
float water_decay = 0.05f,
float water_depth = 0.3f,
float lee_angle = 30.f,
float lee_amp = 0.f,
float uplift_amp = 0.f,
Array * p_water_depth = nullptr,
Array * p_inland_mask = nullptr )

Generates an island heightmap from a land mask using radial profiles, slope shaping, optional noise, and water attenuation.

Applies elevation shaping inside the land mask using distance-based profiles, slope controls, optional radial and slope noise, and water-depth modeling.

Parameters
land_maskBinary mask defining the island shape.
p_noise_rOptional radial noise field (same size as mask).
apex_elevationMaximum elevation at island center.
filter_distanceEnable smoothing of the distance transform.
filter_irRadius of the distance filter.
slope_minMinimum slope.
slope_maxMaximum slope.
slope_startStart of slope ramp (0–1).
slope_endEnd of slope ramp (0–1).
slope_noise_intensityIntensity of slope noise modulation.
k_smoothSmoothing factor for the final profile.
radial_noise_intensityIntensity of radial displacement noise.
radial_profile_gainExponent for radial falloff.
water_decayTransition sharpness to water level.
water_depthWater depth below the shoreline.
lee_angleAngle for lee-side (wind shadow) erosion.
lee_ampAmplitude of lee-side erosion.
uplift_ampAmplitude of uplift (orographic) effect.
p_water_depthOptional output: per-pixel water depth.
p_inland_maskOptional output: mask of inland pixels.
Returns
Heightmap array representing the generated island.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
std::uint32_t seed = 0;
shape,
kw,
seed++,
8,
0.f);
hmap::remap(noise);
// use dedicated mask generator
float radius = 0.3f;
float displacement = 0.2f;
radius,
seed,
displacement,
noise_type);
// default noise
hmap::Array za = hmap::gpu::island(land_mask, seed);
// custom noise (expected in [0, 1])
hmap::Array zb = hmap::gpu::island(land_mask, &noise);
// use "any" noise as land mask
auto land_mask2 = noise;
hmap::zeroed_edges(land_mask2);
hmap::make_binary(land_mask2, 0.15f);
hmap::Array zc = hmap::gpu::island(land_mask2, seed);
hmap::export_banner_png("ex_island.png",
{land_mask, za, zb, zc},
true);
}
Array island(const Array &land_mask, const Array *p_noise_r=nullptr, float apex_elevation=1.f, bool filter_distance=true, int filter_ir=32, float slope_min=0.1f, float slope_max=8.f, float slope_start=0.5f, float slope_end=1.f, float slope_noise_intensity=0.5f, float k_smooth=0.05f, float radial_noise_intensity=0.3f, float radial_profile_gain=2.f, float water_decay=0.05f, float water_depth=0.3f, float lee_angle=30.f, float lee_amp=0.f, float uplift_amp=0.f, Array *p_water_depth=nullptr, Array *p_inland_mask=nullptr)
Generates an island heightmap from a land mask using radial profiles, slope shaping,...
Definition island.cpp:116
void make_binary(Array &array, float threshold=0.f)
Convert array values to binary using a threshold.
Definition filters.cpp:538
Array island_land_mask(glm::ivec2 shape, float radius, std::uint32_t seed, float displacement=0.2f, NoiseType noise_type=NoiseType::SIMPLEX2S, float kw=4.f, int octaves=8, float weight=0.f, float persistence=0.5f, float lacunarity=2.f, const glm::vec2 &center={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit())
Generates a 2D island mask by perturbing a radial boundary with noise.
Definition island.cpp:25
NoiseType
Enumeration of various noise types used for procedural generation.
Definition functions.hpp:67

Result

◆ island() [2/2]

Array hmap::gpu::island ( const Array & land_mask,
std::uint32_t seed,
float noise_amp = 0.07f,
glm::vec2 noise_kw = {4.f, 4.f},
int noise_octaves = 8,
float noise_rugosity = 0.7f,
float noise_angle = 45.f,
float noise_k_smoothing = 0.05f,
float apex_elevation = 1.f,
bool filter_distance = true,
int filter_ir = 32,
float slope_min = 0.1f,
float slope_max = 8.f,
float slope_start = 0.5f,
float slope_end = 1.f,
float slope_noise_intensity = 0.5f,
float k_smooth = 0.05f,
float radial_noise_intensity = 0.3f,
float radial_profile_gain = 2.f,
float water_decay = 0.05f,
float water_depth = 0.3f,
float lee_angle = 30.f,
float lee_amp = 0.f,
float uplift_amp = 0.f,
Array * p_water_depth = nullptr,
Array * p_inland_mask = nullptr )

Generates an island heightmap from a land mask using internally generated FBM noise for radial perturbation and slope modulation.

Same as the other overload but creates a noise field procedurally from a seed, including frequency, octaves, orientation, and smoothing controls.

Parameters
land_maskBinary mask defining the island shape.
seedNoise seed.
noise_ampAmplitude of generated noise.
noise_kwNoise frequencies (x, y).
noise_octavesNumber of FBM octaves.
noise_rugosityPersistence-like roughness control.
noise_angleRotation of the noise field (radians).
noise_k_smoothingSmoothing applied to the noise field.
apex_elevationMaximum elevation at island center.
filter_distanceEnable smoothing of the distance transform.
filter_irRadius of distance filter.
slope_minMinimum slope.
slope_maxMaximum slope.
slope_startStart of slope ramp (0–1).
slope_endEnd of slope ramp (0–1).
slope_noise_intensityIntensity of slope noise modulation.
k_smoothSmoothing factor for final profile.
radial_noise_intensityIntensity of radial displacement noise.
radial_profile_gainExponent for radial falloff.
water_decayTransition sharpness to water level.
water_depthWater depth below the shoreline.
lee_angleAngle for lee-side erosion.
lee_ampAmplitude for lee-side erosion.
uplift_ampAmplitude of uplift (orographic) effect.
p_water_depthOptional output: per-pixel water depth.
p_inland_maskOptional output: mask of inland pixels.
Returns
Heightmap array representing the generated island.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 kw = {4.f, 4.f};
std::uint32_t seed = 0;
shape,
kw,
seed++,
8,
0.f);
hmap::remap(noise);
// use dedicated mask generator
float radius = 0.3f;
float displacement = 0.2f;
radius,
seed,
displacement,
noise_type);
// default noise
hmap::Array za = hmap::gpu::island(land_mask, seed);
// custom noise (expected in [0, 1])
hmap::Array zb = hmap::gpu::island(land_mask, &noise);
// use "any" noise as land mask
auto land_mask2 = noise;
hmap::zeroed_edges(land_mask2);
hmap::make_binary(land_mask2, 0.15f);
hmap::Array zc = hmap::gpu::island(land_mask2, seed);
hmap::export_banner_png("ex_island.png",
{land_mask, za, zb, zc},
true);
}

Result

◆ mountain_cone()

Array hmap::gpu::mountain_cone ( glm::ivec2 shape,
std::uint32_t seed,
float scale = 1.f,
int octaves = 8,
float peak_kw = 4.f,
float rugosity = 0.f,
float angle = 45.f,
float bias = 0.f,
float k_smoothing = 0.f,
float gamma = 0.5f,
float cone_alpha = 1.f,
float ridge_amp = 0.4f,
float base_noise_amp = 0.05f,
glm::vec2 center = {0.5f, 0.5f},
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a procedural "mountain cone" heightmap using fractal noise and Voronoi patterns.

This function synthesizes a terrain-like array shaped as a cone with noise-based ridges and surface roughness. The generation combines a cone-shaped envelope (cone_sigmoid), a fractal base noise (gpu::noise_fbm), and a Voronoi ridge structure (voronoi_fbm), producing a mountain with controlled smoothness, angular distortion, and noise-based displacements.

Parameters
shapeThe output array dimensions (width, height).
seedThe random seed for noise generation.
scaleGlobal scaling factor for the mountain size.
octavesNumber of fractal noise octaves for both FBM and Voronoi.
peak_kwControls the base frequency (inverse wavelength) of the peak noise.
rugosityControls the amplitude decay across octaves (higher = rougher surface).
angleDirection (in degrees) for the displacement noise distortion.
biasReach bonus bias for weighted Voronoi partitioning.
k_smoothingSmoothing factor applied in Voronoi blending.
gammaGamma correction exponent applied at the end.
cone_alphaControls the cone envelope steepness (higher = sharper peak).
ridge_ampControls the amplitude of ridge enhancement in the Voronoi term.
base_noise_ampAmplitude multiplier for the displacement noise.
centerThe 2D position (in normalized coordinates) of the mountain cone center.
p_noise_xOptional pointer to an external X displacement noise field (can be nullptr).
p_noise_yOptional pointer to an external Y displacement noise field (can be nullptr).
bboxThe bounding box (min_x, min_y, max_x, max_y) defining the spatial extent of the map.
Returns
An Array representing the final terrain heightmap in normalized [0, 1] range.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
std::uint32_t seed = 3;
hmap::export_banner_png("ex_mountain_cone.png",
{z1},
true);
}
Array mountain_cone(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=4.f, float rugosity=0.f, float angle=45.f, float bias=0.f, float k_smoothing=0.f, float gamma=0.5f, float cone_alpha=1.f, float ridge_amp=0.4f, float base_noise_amp=0.05f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Generates a procedural "mountain cone" heightmap using fractal noise and Voronoi patterns.
Definition mountain_cone.cpp:20

Result

◆ mountain_inselberg()

Array hmap::gpu::mountain_inselberg ( glm::ivec2 shape,
std::uint32_t seed,
float scale = 1.f,
int octaves = 8,
float rugosity = 0.2f,
float angle = 45.f,
float gamma = 1.1f,
bool round_shape = false,
bool add_deposition = true,
float bulk_amp = 0.2f,
float base_noise_amp = 0.2f,
float bias = 0.f,
float k_smoothing = 0.1f,
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 mountain-like inselberg (isolated hill) heightmap.

This function procedurally creates a 2D elevation field resembling an inselberg, using a combination of fractal noise (FBM), Gaussian pulses, and Voronoi-based structures. It allows control over scale, shape, orientation, rugosity, and optional geological-like effects such as bulk uplift and deposition smoothing.

Parameters
shapeOutput array shape (resolution in x and y).
seedRandom seed used for noise and Voronoi generation.
scaleGlobal scaling factor for the inselberg width and structure.
rugosityControls roughness of the fractal noise (higher = more irregular).
angleOrientation angle (degrees) for directional displacements.
gammaGamma correction factor applied to the final heightmap.
round_shapeIf true, generates a symmetric round shape; if false, adds directional displacement.
add_depositionIf true, applies a smoothing fill step simulating sediment deposition.
bulk_ampAmplitude of bulk uplift applied to the base pulse (0 = none, >0 = raises and normalizes the feature).
base_noise_ampAmplitude of the base displacement noise.
biasReach bonus bias for weighted Voronoi partitioning.
k_smoothingVoronoi smoothing parameter (controls ridge sharpness).
centerCenter of the inselberg in normalized coordinates.
p_noise_xOptional pointer to external displacement noise field (X-axis).
p_noise_yOptional pointer to external displacement noise field (Y-axis).
bboxBounding box of the generation domain in normalized coordinates.
Returns
Array containing the generated inselberg heightmap.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
std::uint32_t seed = 10;
float scale = 0.5f;
hmap::export_banner_png("ex_mountain_inselberg.png",
{z1, z2},
true);
}
Array mountain_inselberg(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float rugosity=0.2f, float angle=45.f, float gamma=1.1f, bool round_shape=false, bool add_deposition=true, float bulk_amp=0.2f, float base_noise_amp=0.2f, float bias=0.f, float k_smoothing=0.1f, 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 mountain-like inselberg (isolated hill) heightmap.
Definition mountain_inselberg.cpp:19
Cloud scale(const Cloud &cloud, glm::vec2 scale, glm::vec2 center={0.5f, 0.5f})
Scales the point coordinates in a cloud relative to a center point.
Definition cloud_functions.cpp:163

Result**

◆ mountain_range_radial()

Array hmap::gpu::mountain_range_radial ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float half_width = 0.2f,
float angle_spread_ratio = 0.5f,
float core_size_ratio = 1.f,
glm::vec2 center = {0.5f, 0.5f},
int octaves = 8,
float weight = 0.7f,
float persistence = 0.5f,
float lacunarity = 2.f,
const Array * p_ctrl_param = nullptr,
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const Array * p_angle = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a heightmap representing a radial mountain range.

This function creates a heightmap that simulates a mountain range emanating radially from a specified center. The mountain range is influenced by various noise parameters and control attributes.

Parameters
shapeThe dimensions of the output heightmap as a 2D vector.
kwThe wave numbers (frequency components) as a 2D vector.
seedThe seed for random noise generation.
half_widthThe half-width of the radial mountain range, controlling its spread. Default is 0.2f.
angle_spread_ratioThe ratio controlling the angular spread of the mountain range. Default is 0.5f.
centerThe center point of the radial mountain range as normalized coordinates within [0, 1]. Default is {0.5f, 0.5f}.
octavesThe number of octaves for fractal noise generation. Default is 8.
weightThe initial weight for noise contribution. Default is 0.7f.
persistenceThe amplitude scaling factor for subsequent noise octaves. Default is 0.5f.
lacunarityThe frequency scaling factor for subsequent noise octaves. Default is 2.0f.
p_ctrl_paramOptional pointer to an array of control parameters influencing the terrain generation.
p_noise_xOptional pointer to a precomputed noise array for the X-axis.
p_noise_yOptional pointer to a precomputed noise array for the Y-axis.
p_angleOptional pointer to an array to output the angle.
bboxThe bounding box of the output heightmap in normalized coordinates [xmin, xmax, ymin, ymax]. Default is {0.0f, 1.0f, 0.0f, 1.0f}.
Returns
Array The generated heightmap representing the radial mountain range.
Note
Only available if OpenCL is enabled.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {1024, 1024};
glm::vec2 kw = {8.f, 8.f};
int seed = 1;
hmap::export_banner_png("ex_mountain_range_radial.png",
{z1},
true);
}
Array mountain_range_radial(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float half_width=0.2f, float angle_spread_ratio=0.5f, float core_size_ratio=1.f, glm::vec2 center={0.5f, 0.5f}, int octaves=8, float weight=0.7f, float persistence=0.5f, float lacunarity=2.f, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const Array *p_angle=nullptr, const UvRect &uv_rect=UvRect::unit())
Generates a heightmap representing a radial mountain range.
Definition primitives_gpu.cpp:511

Result

◆ mountain_stump()

Array hmap::gpu::mountain_stump ( glm::ivec2 shape,
std::uint32_t seed,
float scale = 1.f,
int octaves = 8,
float peak_kw = 6.f,
float rugosity = 0.f,
float angle = 45.f,
float k_smoothing = 0.f,
float gamma = 0.25f,
bool add_deposition = true,
float ridge_amp = 0.75f,
float base_noise_amp = 0.1f,
glm::vec2 center = {0.5f, 0.5f},
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a mountain-like heightmap with a flattened (stump-shaped) peak.

This function procedurally creates a terrain resembling a broad mountain with a smooth, truncated summit. The result combines layered fractal noise (FBM), Gaussian shaping, and Voronoi-based ridge formation to produce natural-looking geomorphological features. The shape can be modulated by directional displacement noise, smoothed using deposition simulation, and refined through gamma and smoothing parameters.

Parameters
shapeDimensions of the output heightmap (width, height).
seedRandom seed for noise generation.
scaleGlobal scale factor controlling the size of features.
octavesNumber of noise octaves used in FBM generation.
peak_kwBase spatial frequency of the main ridge/peak structure.
rugosityControls the roughness of base noise displacements.
angleOrientation angle (in degrees) of the main ridge direction.
k_smoothingSmoothing coefficient applied to the Voronoi FBM ridges.
gammaGamma correction applied to the ridge intensity.
add_depositionIf true, applies an additional smoothing pass to simulate sediment deposition.
ridge_ampAmplitude scaling factor for ridge prominence.
base_noise_ampAmplitude scaling factor for base displacement noise.
centerNormalized coordinates of the mountain’s center (default domain: [0, 1]²).
p_noise_xOptional pointer to horizontal displacement noise (nullptr for none).
p_noise_yOptional pointer to vertical displacement noise (nullptr for none).
bboxBounding box of the generated region (xmin, xmax, ymin, ymax).
Returns
A 2D Array containing the generated mountain stump heightmap.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {1024, 1024};
std::uint32_t seed = 3;
z1.dump();
hmap::export_banner_png("ex_mountain_stump.png",
{z1},
true);
}
Array mountain_stump(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=6.f, float rugosity=0.f, float angle=45.f, float k_smoothing=0.f, float gamma=0.25f, bool add_deposition=true, float ridge_amp=0.75f, float base_noise_amp=0.1f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Generates a mountain-like heightmap with a flattened (stump-shaped) peak.
Definition mountain_stump.cpp:19

Result

◆ mountain_tibesti()

Array hmap::gpu::mountain_tibesti ( glm::ivec2 shape,
std::uint32_t seed,
float scale = 1.f,
int octaves = 8,
float peak_kw = 20.f,
float rugosity = 0.f,
float angle = 30.f,
float angle_spread_ratio = 0.25f,
float gamma = 1.f,
bool add_deposition = true,
float bulk_amp = 1.f,
float base_noise_amp = 0.1f,
glm::vec2 center = {0.5f, 0.5f},
const Array * p_noise_x = nullptr,
const Array * p_noise_y = nullptr,
const UvRect & uv_rect = UvRect::unit() )

Generates a synthetic "Tibesti" mountain heightmap.

This function procedurally creates a 2D elevation field inspired by the Tibesti mountains, a desert volcanic range. The terrain is built by combining Gabor wavelets, fractal simplex noise, and a Gaussian envelope, producing sharp volcanic peaks modulated by erosion-like patterns.

Parameters
shapeOutput array shape (resolution in x and y).
seedRandom seed used for noise and wavelet generation.
scaleGlobal scaling factor controlling the overall mountain size.
octavesNumber of octaves used in the fractal noise and Gabor FBM.
peak_kwBase frequency of the peak features (scaled internally by scale).
rugosityControls roughness of the fractal noise (higher = more irregular).
angleOrientation angle (degrees) for Gabor waves.
angle_spread_ratioSpread ratio of the Gabor wave orientation (controls anisotropy).
gammaGamma correction factor applied to auxiliary noise fields.
add_depositionIf true, applies a smoothing fill step simulating sediment deposition.
bulk_ampAmplitude of bulk uplift applied to the peaks (affects normalization with noise weighting).
base_noise_ampAmplitude of the base displacement noise.
centerCenter of the mountain in normalized coordinates.
p_noise_xOptional pointer to external displacement noise field (X-axis).
p_noise_yOptional pointer to external displacement noise field (Y-axis).
bboxBounding box of the generation domain in normalized coordinates.
Returns
Array containing the generated Tibesti mountain heightmap.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
std::uint32_t seed = 0;
float scale = 0.5f;
hmap::export_banner_png("ex_mountain_tibesti.png",
{z1, z2},
true);
}
Array mountain_tibesti(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=20.f, float rugosity=0.f, float angle=30.f, float angle_spread_ratio=0.25f, float gamma=1.f, bool add_deposition=true, float bulk_amp=1.f, float base_noise_amp=0.1f, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Generates a synthetic "Tibesti" mountain heightmap.
Definition mountain_tibesti.cpp:19

Result

◆ plates()

Array hmap::gpu::plates ( glm::ivec2 shape,
glm::vec2 kw,
std::uint32_t seed,
float talus,
int direction = 0,
float mix_ratio = 0.9f,
float bias = 0.f,
float base_noise_amp = 0.05f,
float kw_multiplier = 2.f,
int octaves = 8,
float rugosity = 0.f,
const UvRect & uv_rect = UvRect::unit() )

Generate a tectonic plate–like heightfield using Voronoi FBM and directional talus projection.

Combines Voronoi edge-distance FBM with a base noise displacement, then applies a talus projection along a given direction and blends the result with the original field.

Parameters
shapeGrid resolution.
kwBase wavelength/frequency.
seedRandom seed.
talusTalus strength for directional projection.
directionProjection direction.
mix_ratioBlend factor between raw Voronoi and projected plates.
biasReach bonus bias for weighted Voronoi partitioning.
base_noise_ampAmplitude of the displacement noise.
kw_multiplierFrequency multiplier for base noise.
rugosityNoise roughness.
bboxBounding box for noise evaluation.
Returns
Generated plate heightfield.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
shape = {1024, 1024};
glm::vec2 kw = {4.f, 4.f};
std::uint32_t seed = 0;
hmap::Array z1 = hmap::gpu::plates(shape, kw, seed, 2.f / shape.x);
z1.dump();
hmap::export_banner_png("ex_plates.png", {z1}, hmap::Cmap::TERRAIN, true);
}
Array plates(glm::ivec2 shape, glm::vec2 kw, std::uint32_t seed, float talus, int direction=0, float mix_ratio=0.9f, float bias=0.f, float base_noise_amp=0.05f, float kw_multiplier=2.f, int octaves=8, float rugosity=0.f, const UvRect &uv_rect=UvRect::unit())
Generate a tectonic plate–like heightfield using Voronoi FBM and directional talus projection.
Definition plates.cpp:17

Result

◆ shattered_peak()

Array hmap::gpu::shattered_peak ( glm::ivec2 shape,
std::uint32_t seed,
float scale = 1.f,
int octaves = 8,
float peak_kw = 4.f,
float rugosity = 0.f,
float angle = 30.f,
float gamma = 1.f,
bool add_deposition = true,
float bulk_amp = 0.3f,
float base_noise_amp = 0.1f,
float bias = 0.f,
float k_smoothing = 0.f,
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 "shattered peak" terrain heightmap.

This function procedurally creates a 2D elevation field resembling a sharp, fractured mountain peak. It combines a Gaussian pulse envelope, fractal noise displacements, and Voronoi-based primitives with edge-distance shaping. The result is a rugged peak structure with broken ridges and steep slopes.

Parameters
shapeOutput array shape (resolution in x and y).
seedRandom seed used for noise and Voronoi generation.
scaleGlobal scaling factor controlling the overall peak size.
peak_kwBase frequency of the peak features (scaled internally by scale).
rugosityControls roughness of the fractal noise (higher = more irregular).
angleOrientation angle (degrees) for directional displacements.
gammaGamma correction factor applied to the final heightmap.
add_depositionIf true, applies a smoothing fill step simulating sediment deposition.
bulk_ampAmplitude of bulk uplift applied to the peak (internally overridden to 0.5f for normalization).
base_noise_ampAmplitude of the base displacement noise.
biasReach bonus bias for weighted Voronoi partitioning.
k_smoothingVoronoi smoothing parameter (controls ridge sharpness).
centerCenter of the peak in normalized coordinates.
p_noise_xOptional pointer to external displacement noise field (X-axis).
p_noise_yOptional pointer to external displacement noise field (Y-axis).
bboxBounding box of the generation domain in normalized coordinates.
Returns
Array containing the generated shattered peak heightmap.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
std::uint32_t seed = 3;
hmap::export_banner_png("ex_shattered_peak.png",
{z1},
true);
}
Array shattered_peak(glm::ivec2 shape, std::uint32_t seed, float scale=1.f, int octaves=8, float peak_kw=4.f, float rugosity=0.f, float angle=30.f, float gamma=1.f, bool add_deposition=true, float bulk_amp=0.3f, float base_noise_amp=0.1f, float bias=0.f, float k_smoothing=0.f, 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 "shattered peak" terrain heightmap.
Definition shattered_peak.cpp:18

Result

◆ sdf_2d_polyline()

Array hmap::gpu::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 )

◆ sdf_2d_polyline_bezier()

Array hmap::gpu::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 )

◆ select_cavities()

Array hmap::gpu::select_cavities ( const Array & array,
int ir,
bool concave = true,
bool normalize = false,
ICommunicator & comm = SingleArrayComm::instance() )

◆ select_soil_flow()

Array hmap::gpu::select_soil_flow ( const Array & z,
int ir_gradient = 1,
float gradient_weight = 1.f,
float gradient_scaling_factor = 0.f,
float flow_weight = 0.05f,
float talus_ref = 0.f,
float clipping_ratio = 50.f,
float flow_gamma = 1.f,
float k_smooth = 0.01f,
bool normalize = false,
ICommunicator & comm = SingleArrayComm::instance() )

Computes a soil–flow selection map based on terrain gradient, river mask, and smoothing parameters.

Parameters
zInput heightmap.
ir_gradientRadius used for the morphological gradient.
gradient_weightWeight applied to the gradient magnitude.
gradient_scaling_factorScaling factor applied to the gradient; defaults to z.shape.x if <= 0.
talus_refReference talus value for river extraction; defaults to 1.f / z.shape.x if <= 0.
clipping_ratioClipping ratio used in the river selection step.
flow_gammaGamma correction exponent applied to the river mask; 1.0 disables correction.
k_smoothSmoothing parameter for the maximum blending.
normalizeIf true, normalize and clip output to [0, 1] using standard deviation with a smooth transition.
commCommunicator for collective normalization.
Returns
A 2D Array representing the final soil-flow selection mask.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
std::uint32_t seed = 0;
// weathered
int ir_curvature = 0;
int ir_gradient = 4;
z,
ir_curvature,
ir_gradient,
1.f,
1.f,
0.2f);
// flow
hmap::remap(sflow);
z.dump("out0.png");
sflow.dump("out1.png");
hmap::export_banner_png("ex_select_soil_weathered.png",
{z, sw, sflow},
}
Array select_soil_flow(const Array &z, int ir_gradient=1, float gradient_weight=1.f, float gradient_scaling_factor=0.f, float flow_weight=0.05f, float talus_ref=0.f, float clipping_ratio=50.f, float flow_gamma=1.f, float k_smooth=0.01f, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Computes a soil–flow selection map based on terrain gradient, river mask, and smoothing parameters.
Definition select_soil_flow.cpp:14
Array select_soil_weathered(const Array &z, int ir_curvature=0, int ir_gradient=4, ClampMode curvature_clamp_mode=ClampMode::POSITIVE_ONLY, float curvature_clamping=10.f, float curvature_weight=1.f, float gradient_weight=1.f, float gradient_scaling_factor=0.f, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Computes a soil weathering selection map based on curvature and gradient analysis.
Definition select_soil_weathered.cpp:15
@ POSITIVE_ONLY
Definition range.hpp:27

Result

◆ select_soil_rocks()

Array hmap::gpu::select_soil_rocks ( const Array & z,
int ir_max = 64,
int ir_min = 0,
int steps = 4,
float smaller_scales_weight = 1.f,
ClampMode curvature_clamp_mode = ClampMode::POSITIVE_ONLY,
float curvature_clamping = 1.f,
bool normalize = false,
ICommunicator & comm = SingleArrayComm::instance() )

Computes a multi-scale soil/rock selector using curvature analysis.

Applies progressively increasing smoothing radii in logarithmic steps (handling ir_min = 0), computes the mean curvature at each scale, clamps it, and accumulates the maximum response across all scales.

Parameters
zInput heightmap or scalar field.
ir_maxMaximum smoothing radius (log-scale upper bound).
ir_minMinimum smoothing radius (0 allowed; replaced by 1 for log scale).
stepsNumber of logarithmic scales to evaluate.
smaller_scales_weightWeight factor applied when descending scales.
curvature_clamp_modeMode used to clamp curvature values.
curvature_clampingCurvature clamp threshold.
normalizeIf true, normalize and clip output to [0, 1] using standard deviation with a smooth transition.
commCommunicator for collective normalization.
Returns
An Array representing soil/rock selection values across scales.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
std::uint32_t seed = 0;
hmap::remap(srocks);
// optional -- consider increasing contrast of srocks with hmap::saturate
if (true) hmap::saturate(srocks, 0.f, 0.3f);
hmap::export_banner_png("ex_select_soil_rocks.png",
{z, srocks},
}
Array select_soil_rocks(const Array &z, int ir_max=64, int ir_min=0, int steps=4, float smaller_scales_weight=1.f, ClampMode curvature_clamp_mode=ClampMode::POSITIVE_ONLY, float curvature_clamping=1.f, bool normalize=false, ICommunicator &comm=SingleArrayComm::instance())
Computes a multi-scale soil/rock selector using curvature analysis.
Definition select_soil_rocks.cpp:16
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 modif...
Definition recurve.cpp:173

Result

◆ select_soil_weathered() [1/2]

Array hmap::gpu::select_soil_weathered ( const Array & z,
int ir_curvature = 0,
int ir_gradient = 4,
ClampMode curvature_clamp_mode = ClampMode::POSITIVE_ONLY,
float curvature_clamping = 10.f,
float curvature_weight = 1.f,
float gradient_weight = 1.f,
float gradient_scaling_factor = 0.f,
bool normalize = false,
ICommunicator & comm = SingleArrayComm::instance() )

Computes a soil weathering selection map based on curvature and gradient analysis.

This function generates a combined array representing the degree of soil weathering using two main components:

  • Curvature contribution: derived from smoothed height variations.
  • Gradient contribution: derived from local slope magnitudes.
Parameters
zInput heightmap or scalar field.
ir_curvatureRadius (in pixels or samples) for curvature smoothing. If zero, curvature smoothing is skipped.
ir_gradientRadius (in pixels or samples) for gradient computation.
curvature_clamp_modeClamping mode applied to curvature values (see ::ClampMode).
curvature_clampingMaximum absolute value used for curvature clamping.
curvature_weightWeight applied to the curvature component in the final mix.
gradient_weightWeight applied to the gradient component in the final mix.
gradient_scaling_factorEmpirical scaling factor for both curvature and gradient terms. If non-positive, defaults to z.shape.x.
normalizeIf true, normalize and clip output to [0, 1] using standard deviation with a smooth transition.
commCommunicator for collective normalization.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
std::uint32_t seed = 0;
// weathered
int ir_curvature = 0;
int ir_gradient = 4;
z,
ir_curvature,
ir_gradient,
1.f,
1.f,
0.2f);
// flow
hmap::remap(sflow);
z.dump("out0.png");
sflow.dump("out1.png");
hmap::export_banner_png("ex_select_soil_weathered.png",
{z, sw, sflow},
}

Result

◆ select_soil_weathered() [2/2]

Array hmap::gpu::select_soil_weathered ( const Array & z,
const Array & gradient_norm,
int ir_curvature,
ClampMode curvature_clamp_mode,
float curvature_clamping,
float curvature_weight,
float gradient_weight,
float gradient_scaling_factor,
bool normalize = false,
ICommunicator & comm = SingleArrayComm::instance() )

◆ select_slope()

Array hmap::gpu::select_slope ( const Array & z,
int ir = 0,
bool normalize = false,
MinMaxKernel kernel_type = MinMaxKernel::OCTAGON,
const UvTile & region = UvTile::dummy(),
ICommunicator & comm = SingleArrayComm::instance() )

Selects terrain slope.

Computes slope from heightmap. If ir == 0, uses gradient norm; if ir > 0, uses morphological gradient with kernel radius ir.

Parameters
zInput heightmap.
irKernel radius. If 0, uses gradient norm; if > 0, uses morphological gradient.
normalizeIf true, normalize and clip output to [0, 1] using standard deviation with a smooth transition.
kernel_typeKernel footprint type (default: MinMaxKernel::OCTAGON).
commCommunicator for collective normalization.
Returns
Array Output slope array.

◆ select_valley()

Array hmap::gpu::select_valley ( const Array & z,
int ir,
bool ridge_select = false,
bool normalize = false,
ICommunicator & comm = SingleArrayComm::instance() )

◆ fill_masked_holes()

void hmap::gpu::fill_masked_holes ( Array & z,
const Array & mask,
int iterations_max = 500,
float tolerance = 1e-5f,
float omega = 0.f,
float detail_amplitude = 1.f,
int patch_size = 16,
std::uint32_t seed = 0,
int sync_interval = 1,
const UvTile & region = UvTile::unit(),
ICommunicator & comm = SingleArrayComm::instance() )

Fill masked holes in a heightmap by reconstructing the masked regions from the surrounding terrain using GPU biharmonic interpolation.

Uses tileable GPU biharmonic interpolation to smoothly reconstruct the masked holes with $C^1$ continuity while preserving the original terrain outside the mask.

Parameters
zHeightmap to modify in-place.
maskHole mask in [0, 1] (> 0 = holes to fill, <= 0 = preserved terrain).
iterations_maxMaximum number of iterations.
toleranceConvergence tolerance for biharmonic interpolation.
omegaRelaxation factor (0 = auto-computed default 0.5).
detail_amplitudeAmplitude of gradient-patch detail injected inside the hole (0.f = pure smooth harmonic fill).
patch_sizeSide length of gradient patches harvested from the unmasked terrain (if < 4, detail transfer is skipped).
seedRandom seed for deterministic patch selection.
sync_intervalHalo synchronization interval for tiled execution.
regionTile descriptor for tiled execution.
commCommunicator for tiled execution.

◆ advection_particle() [1/11]

Array hmap::gpu::advection_particle ( const Array & z,
const Array & advected_field,
int iterations,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

Performs particle-based advection on a scalar field.

This function advects particles through a velocity field (or gradient field) derived from the input array z. Each particle carries a value from the advected_field and evolves over a number of iterations according to advection parameters such as inertia and persistence. Optionally, advection and masking fields can be applied to control which areas are affected.

Parameters
zInput scalar field defining the base flow or gradient field used for particle advection.
advected_fieldThe scalar field whose values are transported along particle trajectories.
iterationsNumber of advection iterations to perform per particle.
nparticlesNumber of particles to simulate during advection.
seedRandom seed used for initializing particle positions and stochastic behavior.
reverseIf true, reverses the advection direction (useful for backtracing or inverse advection).
post_filterIf true, applies a smoothing or filtering operation after advection to reduce artifacts.
advection_lengthMaximum advection step length per iteration (controls particle displacement scale).
value_persistenceControls how much of a particle’s advected value is preserved between iterations (1.0 means full preservation, lower values introduce decay).
inertiaControls how much a particle’s previous velocity affects its next step (simulates momentum).
p_advection_maskOptional mask array controlling where advection occurs (nullptr to disable).
p_maskOptional general mask restricting where output values are written (nullptr to disable).
Returns
An Array representing the advected version of advected_field after applying particle advection.

Example

#include "highmap.hpp"
int main(void)
{
glm::ivec2 shape = {256, 256};
glm::vec2 res = {2.f, 2.f};
int seed = 1;
int nparticles = 10000;
hmap::Array za = z;
za = hmap::gpu::advection_particle(z, za, nparticles, seed);
// advect another field based on the elevation
shape,
{32.f, 32.f},
seed);
hmap::Array n = n0;
int iterations = 10;
n = hmap::gpu::advection_particle(z, n0, iterations, nparticles, seed);
hmap::export_banner_png("ex_advection_particle.png",
{z, za, n},
true);
}
Array advection_particle(const Array &z, const Array &advected_field, int iterations, int nparticles, std::uint32_t seed, bool reverse=false, bool post_filter=true, float post_filter_sigma=0.125f, float advection_length=0.1f, float value_persistence=0.99f, float inertia=0.f, const Array *p_advection_mask=nullptr, const Array *p_mask=nullptr)
Performs particle-based advection on a scalar field.
Definition advection_particle_gpu.cpp:25

Result

◆ advection_particle() [2/11]

std::vector< Array > hmap::gpu::advection_particle ( const Array & z,
const std::vector< const Array * > & advected_fields,
int iterations,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle() [3/11]

std::vector< Array > hmap::gpu::advection_particle ( const Array & z,
const std::vector< Array > & advected_fields,
int iterations,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle() [4/11]

Array hmap::gpu::advection_particle ( const Array & z,
const Array & advected_field,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle() [5/11]

std::vector< Array > hmap::gpu::advection_particle ( const Array & z,
const std::vector< const Array * > & advected_fields,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle() [6/11]

std::vector< Array > hmap::gpu::advection_particle ( const Array & z,
const std::vector< Array > & advected_fields,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle() [7/11]

Array hmap::gpu::advection_particle ( const Array & dx,
const Array & dy,
const Array & advected_field,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle() [8/11]

std::vector< Array > hmap::gpu::advection_particle ( const Array & dx,
const Array & dy,
const std::vector< const Array * > & advected_fields,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle() [9/11]

std::vector< Array > hmap::gpu::advection_particle ( const Array & dx,
const Array & dy,
const std::vector< Array > & advected_fields,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle() [10/11]

Texture hmap::gpu::advection_particle ( const Array & z,
const Texture & texture,
int iterations,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle() [11/11]

Texture hmap::gpu::advection_particle ( const Array & z,
const Texture & texture,
int nparticles,
std::uint32_t seed,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle_multiscale() [1/4]

Array hmap::gpu::advection_particle_multiscale ( const Array & z,
const Array & advected_field,
std::uint32_t seed,
const std::vector< int > & steps_per_level = {4, 2, 1},
float particles_ratio = 0.5f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
float mix = 1.f,
float warp = 0.f,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

Performs multiscale particle-based advection on a scalar field.

This function advects particles through a gradient field derived from the input heightmap z across a geometric hierarchy of resolution levels, applying coarse-to-fine delta upsampling with optional domain warping.

Parameters
zInput scalar field defining the base flow.
advected_fieldThe scalar field whose values are transported.
seedRandom seed for particle positions and warping.
steps_per_levelNumber of particle steps / iterations per level.
particles_ratioRatio of particles relative to grid cells.
advection_lengthMaximum advection step length per iteration.
value_persistenceControls how much of the advected value is preserved.
inertiaMomentum factor for particle velocity.
mixBlend factor for coarse advection deltas into the field.
warpDomain warp amplitude during delta upsampling.
reverseIf true, reverses the advection direction.
post_filterIf true, applies Laplace smoothing post-filter.
post_filter_sigmaLaplace smoothing sigma parameter.
p_advection_maskOptional mask controlling where advection occurs.
p_maskOptional general mask restricting output values.
Returns
An Array representing the advected field.

◆ advection_particle_multiscale() [2/4]

std::vector< Array > hmap::gpu::advection_particle_multiscale ( const Array & z,
const std::vector< const Array * > & advected_fields,
std::uint32_t seed,
const std::vector< int > & steps_per_level = {4, 2, 1},
float particles_ratio = 0.5f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
float mix = 1.f,
float warp = 0.f,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle_multiscale() [3/4]

std::vector< Array > hmap::gpu::advection_particle_multiscale ( const Array & z,
const std::vector< Array > & advected_fields,
std::uint32_t seed,
const std::vector< int > & steps_per_level = {4, 2, 1},
float particles_ratio = 0.5f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
float mix = 1.f,
float warp = 0.f,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ advection_particle_multiscale() [4/4]

Texture hmap::gpu::advection_particle_multiscale ( const Array & z,
const Texture & texture,
std::uint32_t seed,
const std::vector< int > & steps_per_level = {4, 2, 1},
float particles_ratio = 0.5f,
float advection_length = 0.1f,
float value_persistence = 0.99f,
float inertia = 0.f,
float mix = 1.f,
float warp = 0.f,
bool reverse = false,
bool post_filter = true,
float post_filter_sigma = 0.125f,
const Array * p_advection_mask = nullptr,
const Array * p_mask = nullptr )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ rotate()

void hmap::gpu::rotate ( Array & array,
float angle,
bool zoom_in = true )

◆ warp()

void hmap::gpu::warp ( Array & array,
const Array * p_dx,
const Array * p_dy )

See hmap::warp.

◆ helper_vflow_compute_adaptive_dt()

float hmap::gpu::helper_vflow_compute_adaptive_dt ( const Array & h,
float viscosity,
float power )

◆ helper_transform_bbox()

glm::vec4 hmap::gpu::helper_transform_bbox ( const UvRect & uv_rect_source,
const UvRect & uv_rect_target )

◆ helper_bind_optional_buffers()

void hmap::gpu::helper_bind_optional_buffers ( clwrapper::Run & run,
const Array * p_noise_x,
const Array * p_noise_y )

◆ helper_radial_profile()

float hmap::gpu::helper_radial_profile ( float r,
float slope_start,
float slope_end,
float apex_elevation,
float k_smooth,
float radial_gain )
inline

◆ helper_apply_leeward()

float hmap::gpu::helper_apply_leeward ( float h,
float r,
float hs,
float slope_max,
float k_smooth,
float lee_amp,
float alpha,
float lee_alpha )
inline

◆ helper_apply_uplift()

float hmap::gpu::helper_apply_uplift ( float h,
float r,
float slope_max,
float uplift_amp,
float k_smooth )
inline