Setup
I recently started to work with Unity. I want to generate a custom terrain at runtime. To do this i take a grid with a variable amount of squares. For each of the squares i calculate the height with a exchangeable height function. The height function takes the X and Z coordinate as arguments. X and Z range between 0 and 1.
I wrote some height function using perlin noise and random numbers.
Problem
I want to generate a hill. The hilltop (height 1.0
) should be in the center (coordinate 0.5
, 0.5
). And the edges mark the bottom of the hill (height 0.0
).
My best bet was a gaussian like function. The result is quite what i am looking for. A smooth top and leveled at the edges. The problem is that the edges are always a bit raised. You can reduce that by scaling X and Z but this results in a smaller hill.
I also tried other functions. But they all have shortcomings like sharp edges or raised edges.
Can anyone help me pick an appropriate function? Or maybe a combination of functions?