feat(authoring): add stochastic-local-search terrain deformation (#409) - #441
Open
barrulus wants to merge 1 commit into
Open
Conversation
… tests and example (#409) Implements the constraint-based terrain deformation of Stachniak & Stuerzlinger, "An Algorithm for Automated Fractal Terrain Deformation" (WSCG 2005): a heightmap is deformed by a sequence of truncated-Gaussian pushes (location, amplitude, radius) chosen by stochastic local search to minimise a per-vertex fitness sum. Constraints are combinable terms (target, weight, MATCH/ABOVE/BELOW, scale) covering the paper's shape-mask, fixed-road and edge-matching cases. Deviations from the paper: the push amplitude is the least-squares optimum of the local quadratic penalty over the kernel footprint (clamped by the slope limit) instead of a sampled set; candidate vertices come from a jittered grid plus penalty-weighted sampling instead of quad-tree refinement; the confidence-based prediction optimisation is not implemented. Also adds apply_gaussian_pushes() to replay a recorded push sequence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #409
Implements the constraint-based terrain deformation of Stachniak & Stuerzlinger, An Algorithm for Automated Fractal Terrain Deformation (WSCG 2005), as
hmap::sls_deformation()in the authoring module.What's in
sls_deformation(): deforms a heightmap by a sequence of truncated-Gaussian pushes(location, amplitude, radius)chosen by stochastic local search to minimise a per-vertex fitness sum. One push per iteration; the best candidate is applied with probabilityp_best(0.65 as in the paper), otherwise one of thetop_fractionbest. The slope limittalus_max * radiusimplements the paper's frequency limitation.DeformationConstraint {target, weight, MATCH | ABOVE | BELOW, scale}: combinable fitness terms covering the paper's cases (match a heightmap, shape mask, fixed road, edge matching), see the header docs.GaussianPush+apply_gaussian_pushes(): the applied sequence can be recorded and replayed (paper §4.5).ex_sls_deformation(star island + S-shaped road at 512², a few seconds per run),docs/images/ex_sls_deformation.png.Deviations from the paper
CPU only (OpenMP over candidates); a GPU variant or applying several non-overlapping pushes per iteration would be natural follow-ups.