PolyhedralDev / Terra

Voxel world generation modding platform
MIT License
642 stars 85 forks source link

[Feature] Distance transform sampler #395

Closed Astrashh closed 1 year ago

Astrashh commented 1 year ago

A sampler that accepts an Image (implemented by #385) and returns the distance to the closest 'on' pixel derived from thresholding the provided image. This is commonly reffered to as a distance transformation.

The primary usecase I can think of this is allowing users to draw land mass shapes very simply, while also reaping the benefits of gradient noise (such as how Overworld 2.0 utilises continent noise for shaping terrain).

See examples below:

image-1

image-2

The result could be utilised as a noise sampler as a drop in replacement for other noise algorithms, allowing users to draw their noise.

A distance array can be precomputed at load time, meaning performance of this should not be a concern (but faster algs may improve pack load time, especially with larger source images).

This could act similarly to the cellular noise sampler, with multiple return types and distance calculation methods.

Astrashh commented 1 year ago

image-3

Here's another image produced with GIMP, demonstrating how drawing nice mountain ranges would be very easy for end users

Astrashh commented 1 year ago

Implemented in #385