真实的二维地形图生成

发布于 2024-08-06 02:12:11 字数 671 浏览 3 评论 0原文

我正在寻找一些算法来生成逼真的二维地形图。 我所说的现实是指人们会将此类地图视为“正常”地形图,而不是人工创建的。 我不想创建逼真的地图。只是类似于可以在地理地图集中查看的地图的东西。

到目前为止,我使用 perlin 噪声 作为高度图,然后添加湖泊、河流、山脉、沼泽等。您可以看看下面的图片:

地形图 http://www.freeimagehosting.net/ uploads/1f1e9372bf.png

我对此不满意。这不现实,但我自己无法想出更好的办法。时间不是问题,因此算法可能需要大量计算。

感谢您抽出时间。

编辑后:

我想我找到了一篇可能有帮助的文章: http://portal .acm.org/itation.cfm?id=1255047.1255077

但是它无法免费获得,所以我仍在寻找答案或想法。

I am looking for some algorithms which allow me to generate a realistic 2D terrain map.
By realistic I mean that person will consider such map as a "normal" terrain map, not created artificially.
I don't want to create photorealistic map. Just something similar to maps that can be viewed in a geographical atlas.

So far I am using perlin noise for height map and then I am adding lakes, rivers, mountains, swamps and so on. You may look how it looks on the picture below:

Terrain map http://www.freeimagehosting.net/uploads/1f1e9372bf.png

I am not happy with it. It's not realistic but I can't figure out something better on my own. Time is not a matter so the algorithms may be heavy computational.

Thanks for your time.

After edit:

I think I've found one article that can be helpful: http://portal.acm.org/citation.cfm?id=1255047.1255077

However it can't be obtained for free so I am still looking for answers or ideas.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

把人绕傻吧 2024-08-13 02:12:11

我以前玩过地形生成。假设目标是位图,我找到了一种方法来制作河流之类的东西,并且总体上使其看起来更好:侵蚀。

一旦您通过其他方式生成了地形,就会稍微侵蚀它:您需要以像素高度表示的世界。在地图上选取一个点,并将一个高度单位移动到最低的邻居。将光标移动到该邻居并重复,直到它不动为止。对其他像素重复此操作。

为了让河流计算你经过某个位置的次数,向下移动一些位。受影响最严重的地方是河流。

后续:我并没有侵蚀每个像素,而只是侵蚀大量随机像素,直到它足够风化。实际侵蚀它们的原因是,这会带走碎片并填补漏洞。如果没有它,就不会有河流,因为会有死区滞留水流——流动的像素会填充任何小孔并形成有效的水道。

抱歉,我无法提供任何示例,这是很多年前的事了,虽然旧代码可能在某个地方,但我不知道在哪里查找。

I've played with terrain generation before. Assuming the objective is a bitmap I found a way to make things like rivers and in general make it look better: Erosion.

Once you have terrain generated by other means erode it a bit: You need the world expressed as heights of pixels. Take a spot on the map and move one unit of height to the lowest neighbor. Move the cursor to this neighbor and repeat until it doesn't move. Repeat for other pixels.

To make rivers count the number of times you pass through a location moving bits down. Spots that get hit the most are rivers.

Followup: I wasn't eroding each pixel so much as simply a large number of random pixels until it weathered enough. The reason for actually eroding them is that this carries bits down and fills in holes. Without that there can be no rivers as there will be dead that trap the flow--the flowing pixels fill in any small holes and make working waterways.

Sorry I can't give any samples, this was many years ago and while the old code is probably around somewhere I don't know where to look.

爱给你人给你 2024-08-13 02:12:11

地形是由无数不同的原因在许多不同的时间尺度上形成的。为了真正创建真实的地形,您必须模拟这些地形。

从“短期”来看,水圈决定了大部分特征。您可以从包含主要特征(山脉等)的体素/粒子/高度图/网格地形开始,并将其视为不可变的,然后使用大量的水模拟对其进行后处理。您需要计算河流和湖泊的位置、它们如何侵蚀基础景观以及它们在哪里形成沉积物。如果我必须编写这个代码,我可能会从 3D 体素世界开始。

这将是一项艰巨的任务,我确信有很多技巧可用于生成需要几毫秒而不是几分钟的特定地形类型。您想要创建什么样的地形?多山?低地?工业化?森林?沙漠?群岛?

长话短说:如果你想要人类(毕竟,他们往往是这类事情的专家)看起来逼真的地形,你必须通过模拟实际的地质过程来创建它。

Terrain is created by a myriad different causes over many different time-scales. In order to truly create realistic terrain, you'd have to simulate these.

In the "short" term, the hydrosphere determines most of the characteristics. You can probably start with a voxel/particle/heightmap/mesh terrain containing major features (mountain ranges etc.) and treat it as immutable, then post-process it with a plethora of water simulations. You'll need to compute where the rivers and lakes will be, how they erode the base landscape, and where they form deposits. If I had to code this I'd probably start with a 3D voxel world.

This would be a gargantuan task and I'm sure there are lots of tricks available for generating specific terrain types that take milliseconds instead of minutes. What kind of terrain are you looking to create? Mountainous? Lowland? Industrialised? Forest? Desert? Archipelago?

Long story short: if you want terrain that looks realistic to humans (who tend to be, after all, experts on this kind of thing), you'll have to create it by simulating actual geological processes.

记忆里有你的影子 2024-08-13 02:12:11

我在 Terra3D 中的方法是生成随机高度值,然后进行 3 次平滑处理,并在算法中写入一些整形。重塑会导致吃水线以下的地形稍微向下移动,而吃水线以上的一切都向上移动一点。但效果是有很多山丘和小湖泊。这可能不是您正在寻找的。

然而,我不相信我的方法背后的原理不能用来得到你想要的东西。您可能只需要在重塑/平滑算法中写入更多条件。例如,减少较高海拔地形的平滑量将产生更多落基山脉的外观。然后编写一个更复杂的平滑(或高斯)算法,进一步延伸到较低的海拔,可以将这些湖泊拉在一起形成天然河流。

如果您有兴趣,这里是 Terra3D 中地形生成的代码:

  // GENERATE TERRAIN
  for (i = 0; i < MAX; i++)
  {     
    for (i2 = 0; i2 < MAX; i2++)
    {
        if (i<10 || i2<10 || i>MAX-10 || i2>MAX-10)
        field[i][i2].y=0;
      else
        field[i][i2].y=(GLfloat(rand()%151)-75)/50+(field[i-1][i2-1].y+field[i-1][i2].y+field[i-1][i2+1].y+field[i-1][i2-2].y+field[i-1][i2+2].y)/5.05;
    }
  }

  // SMOOTH/RESHAPE TERRAIN
  for (int cnt = 0; cnt < 3; cnt++)
  {  
    for (int t = 1; t < MAX-1; t++)
    {
      for (int t2 = 1; t2 < MAX-1; t2++)
      {
        field[t][t2].y = (field[t+1][t2].y+field[t][t2-1].y+field[t-1][t2].y+field[t][t2+1].y)/4;

        if (cnt == 0)
        {
          if (field[t][t2].y < -1 && field[t][t2].y > -1-.5) field[t][t2].y -= .45, field[t][t2].y *= 2;
          else if (field[t][t2].y > -1 && field[t][t2].y < -1+.5) field[t][t2].y += .5, field[t][t2].y /= 5;
        } 
      }
    }
  }

它很草率我大约 10 年前写的代码。 Terra3D 是一个漫长的学习过程,需要在黑暗中进行实验和摸索,以产生我想要的效果类型。但也许会有帮助。

My method in Terra3D was to generate random height values, and then make 3 smoothing passes with a little reshaping written into the algorithm. The reshaping causes the terrain under the water line to shift downwards a bit and everything above the water line shift up a bit. The effect though is a lot of hills and small lakes. And that may not be what you're looking for exactly.

However, I'm not convinced that the principal behind my method couldn't be used to get what you want. You may just have to write some more conditions into the reshaping/smoothing algorithm. For example, reducing the amount of smoothing on the terrain at higher elevations will create more of a rocky mountain appearance. And then writing a more involved smoothing (or gaussian) algorithm that stretches out further for the lower elevations could pull those lakes together to form natural rivers.

Here's the code for the terrain generation in Terra3D in case you're interested:

  // GENERATE TERRAIN
  for (i = 0; i < MAX; i++)
  {     
    for (i2 = 0; i2 < MAX; i2++)
    {
        if (i<10 || i2<10 || i>MAX-10 || i2>MAX-10)
        field[i][i2].y=0;
      else
        field[i][i2].y=(GLfloat(rand()%151)-75)/50+(field[i-1][i2-1].y+field[i-1][i2].y+field[i-1][i2+1].y+field[i-1][i2-2].y+field[i-1][i2+2].y)/5.05;
    }
  }

  // SMOOTH/RESHAPE TERRAIN
  for (int cnt = 0; cnt < 3; cnt++)
  {  
    for (int t = 1; t < MAX-1; t++)
    {
      for (int t2 = 1; t2 < MAX-1; t2++)
      {
        field[t][t2].y = (field[t+1][t2].y+field[t][t2-1].y+field[t-1][t2].y+field[t][t2+1].y)/4;

        if (cnt == 0)
        {
          if (field[t][t2].y < -1 && field[t][t2].y > -1-.5) field[t][t2].y -= .45, field[t][t2].y *= 2;
          else if (field[t][t2].y > -1 && field[t][t2].y < -1+.5) field[t][t2].y += .5, field[t][t2].y /= 5;
        } 
      }
    }
  }

It's sloppy code that I wrote about 10 years ago. Terra3D was a long learning process of experimentation and fumbling in the dark to produce the type of effects I was looking for. But maybe it'll help.

最冷一天 2024-08-13 02:12:11

我知道这是一个非常古老的问题,但我正在为未来像我一样寻找良好地形生成器的人回答这个问题。使用 World Machine 2 的免费版本。它是一个地形生成器,可以完全满足您的要求以及更多功能。它已被专业人士用来生成图像、3D 世界地形,甚至用于生成像您建议的那样的地图。请注意,免费版本仅适用于非商业用途。

I know this is a really old question but I'm answering this for future people searching for a good terrain generator, like I was. Use the free version of World Machine 2. It is a terrain generator that can do exactly what you are asking and more. It has been used by professionals to generate images, 3D world terrain, and even for maps like what you are suggesting. Note that the free version is only for non-commercial uses.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文