开发者

Generation of Terrain Noise with a Mask?

开发者 https://www.devze.com 2023-03-24 00:00 出处:网络
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 doe

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号