Skip to content

Repository files navigation

Generating sand dunes proceduraly in Godot 4.3

dunes

Mesh structure

The mesh is generated using the primitive TRIANGLE_STRIP, this saves on memory as the generated triangles share vertexes, however it means that the normals have to be manually computed later in the pipeline.
mesh

The pipeline

While the mesh is being generated, the function "run_pipeline()" is run on each point, this takes an array of callables and executes them all on the requested point. This structure makes the pipeline very easy to modify as functions can be changed added or removed with very littel code editing, they can even be added programatically if that ever becomes a requirement. Currently the pipeline contains a series of sine waves of decreasing aplitudes and increasing frequencies at varying angles, this creates the bulk of the detail of the sand dunes, this is then followed by a perlin noise layer to ensure that the repeating sine wave patterns to not become repetetive. Finally a all values below a threshold are damped to simulate a bedrock layer.

Normals

After the next position is generated, the normal for the last triangle created is calculated by cross multiplying differences between the previous three verticies. This part of the process is WIP, and currently leaves some artefacts caused by the fact that when one line of the mesh grid is generated, its normals are calulated before the next line is created, this means that the normals cannot be correctly smoothed.
normal buffer

Known issues

[x] Jagged edges to terrain (#1 (comment))

[ ] Normals have "banding" effect (#2 (comment))

[ ] Performance is poor when working with large grid sizes (#3 (comment))

[ ] Repetition is noticable at larger grid sizes (#4 (comment))

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages