I have a 2D map in black-and-white with the white parts that should be above sea-level and the black parts below sea-level. I'm not sure how to go about generating terrain to fit to that mask. It doesn't matter if the contours of the islands are not correct, but what does matter is that the noise should roughly fit the contours of the islands described.
I have looked at Perlin noise, but I'm not sure how to adapt 开发者_运维百科it to my scenario.
A solution could be the following:
Invent a function dist(x,y) returning the distance to the shore point nearest to (x,y). Then generate a standard perlin-noise height field, but multiply each height by dist(x,y). dist(x,y) should be actually be the negative distance if you are on water and the positive distance if you are on land. That way the height field is pushed down or pulled up depending on how far you are from the shore, but the terrain is still rather continuous. If the results look to strange you may want to distort dist(x,y) a little, e.g. by using sqrt(dist(x,y)) or sgn(dist(x,y))*log(1+abs(dist(x,y))) or something like that.
精彩评论