使用掩模生成地形噪声?
我有一张黑白二维地图,其中白色部分应高于海平面,黑色部分应低于海平面。我不知道如何生成适合该蒙版的地形。岛屿的轮廓是否不正确并不重要,重要的是噪声应该大致符合所描述的岛屿的轮廓。
我看过 Perlin 噪声,但我不确定如何使其适应我的场景。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案如下:
发明一个函数 dist(x,y),返回距 (x,y) 最近的海岸点的距离。
然后生成标准柏林噪声高度场,但将每个高度乘以 dist(x,y)。
如果您在水上,dist(x,y) 实际上应该是负距离,如果您在陆地上,则应该是正距离。这样,高度场会根据距海岸的距离而被推低或拉高,但地形仍然相当连续。
如果结果看起来很奇怪,您可能需要稍微扭曲 dist(x,y),例如使用 sqrt(dist(x,y)) 或 sgn(dist(x,y))*log(1+abs(dist) (x,y))) 或类似的东西。
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.