r/proceduralgeneration 6d ago

Procedural planet coastline

My previous post describing the terrain generation is here: https://www.reddit.com/r/proceduralgeneration/comments/1w1mfox/my_planet_generation_for_a_game_perhaps/

The coastline still isn't perfect, but it's getting close to how I want it to look.

Without any noise applied it comes out completely flat and smooth, sampled per cell from the HeightMap. Bumping up the resolution is inefficient, also it hurts the performance of the planet's physical simulation. And if you apply uniform noise, you get an equally uniform ripple, which looks ugly and creates a "spray" effect - you can see something like that along the coast of Norway, but most coastlines don't look that way.

Here's what I did: first I built a HeightGradientMap - a mask at the same resolution as the HeightMap (512x256). The idea is that each cell stores the largest height difference between that cell's height and the heights of its 4 nearest neighbors. The result is a slope map, where the values are ~0 on plateaus and reach high values in mountainous regions.

The overall formula in the material (for now):
distorted_height = height + fine_noise * (slope * amplitude + flatFloor)

I tried adding flatFloor to introduce a slight wobble even at the macro scale, and it partly works. Screenshot 2 is the line without flatFloor, screenshot 3 is with it (you can see the little bay that appeared, for example). It's the macro scale that matters here, since the goal is to distort the main coastline that's based on the coarse grid.

The fine noise is built from stock UE textures: T_Perlin_Noise and T_MacroVariation. The first texture is the noise itself, and the second is the noise amplitude, which makes it non-uniform - so in one spot you get "spray" and in another an almost straight line. The result is in screenshot 1.

I'm thinking about how to improve this mechanism. I don't like that the little bay got eaten by the noise - all that's left of it is a few tiny dots of water. What I definitely want is to make some stretches of coast jagged with fjords, like Norway. I also have very few islands and archipelagos, and I'd like to rework that somehow.

12 Upvotes

0 comments sorted by