Skip to content

feat: flatten heightmap around points #421

Description

@otto-link

use case: settlements or "big" objects placement

Add a function to flatten a heightmap locally around a set of points.

Proposed behavior

Given:

  • a heightmap
  • a set of (x, y) points
  • an optional per-point radius scaling factor r
  • an influence radius ir in pixels

the function modifies the elevation around each point toward a reference elevation.

Reference elevation

The reference elevation should be configurable:

  • POINT — elevation at the point
  • MEAN — average elevation within ir around the point
  • MIN — minimum elevation
  • MAX — maximum elevation
  • potentially other statistics later (median, percentile, etc.)

Radial flattening

Instead of explicitly interpolating with lerp, the flattening amount should be determined from the normalized radial distance to the point and the radial functions already available in HighMap.

For a pixel at distance d from the point:

u = d / radius

A radial function f(u) determines the flattening profile, with u = 0 at the center and u = 1 at the influence boundary.

The resulting elevation can then be expressed conceptually as:

h' = h + strength * f(u) * (h_ref - h)

where:

  • h is the current elevation
  • h_ref is the reference elevation
  • strength controls the overall flattening intensity
  • f controls the spatial shape of the flattening

The existing radial functions should be reused rather than introducing a new falloff implementation.

The effective radius is:

radius = ir * r

with r = 1 by default.

Shape and strength

The API should expose both:

  • strength — how strongly the terrain is flattened toward the reference elevation
  • shape / radial-function parameters — how the flattening is distributed spatially

This separates how much the terrain is modified from how the modification is shaped.

Overlapping points

The behavior for overlapping influence areas should be deterministic and explicitly defined.

Possible approaches include combining the individual influence weights and reference elevations, or applying the strongest influence. A weighted combination is likely preferable to sequentially processing the points, as it avoids order-dependent results.

Possible extensions

  • Inner radius with full flattening and an outer falloff radius.
  • Anisotropic/elliptical influence regions if needed later.
  • Per-point strength, radius, and shape parameters rather than only global values.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme: nodes-algorithmsNew nodes, primitives, filters, operators, node consolidation

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions