可播放的高度图

发布于 2024-09-28 15:59:30 字数 236 浏览 5 评论 0原文

我有一个具有无限程序生成地形的游戏。我使用 1/f 噪声作为高度(我认为这是柏林噪声?)。无论如何,它看起来不错,但可玩性不太好,因为它实际上没有平坦的区域。仅减小振幅是行不通的,因为我仍然想要高度变化很大。有谁知道我可以将过滤器应用于高度图,以鼓励平坦区域,同时保持大范围的高度?

用 C# 编写

编辑:我意识到我想要的是让陡峭的梯度变得更陡,让平坦的梯度变得更平坦。对于 FPS 来说,地形不必是真实的,只要“有趣”即可。

I have a game with infinity procedually generated terrain. I'm using 1/f noise for the height (I think this is perlin noise?). Anyway it looks nice, but its not very playable since it doesn't really have flat areas. Just decreasing the amplitude won't work since I still want a large variation in height. Does anyone know of a filter I can apply to the heightmap to encourage flat areas while keeping a large range of heights?

Written in C#

EDIT: I've realised that what I want is for steep gradients to become steeper, and for flat gradients to become flatter. The terrain needn't be realistic, just "fun" for an FPS.

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

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

发布评论

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

评论(7

半窗疏影 2024-10-05 15:59:31

不确定这是否有帮助,但您可以将函数的范围很有可能转换为平面。例如,0.1 到 0.3 之间的所有结果有 80% 的概率最终为 0.1 表面。通过这种方式,您可以鼓励平坦的表面,但保持您想要的高可变性。

Not sure if this would help, but you could make that a range of your function is transformed into a flat surface with a high probability. For example all results between 0.1 and 0.3 have a 80% probability of end as a 0.1 surface. This way you encourage flat surfaces but keep the high variability you want.

雾里花 2024-10-05 15:59:31

简单的噪声不足以生成漂亮的地形。这只是更复杂过程中的中间步骤之一。你需要模拟一些现实世界的现象:温度、侵蚀、降水等等。通常,这是一个占用大量 CPU 资源的进程,但非常值得付出努力。这里有一些有趣的链接:

地下城联盟 - 阅读全部内容。很棒的东西。

关于《Doryen 编年史》的世界一代文章:

(你也可以下载生成器,但它是用 C++ 编写的)

Simple noise is not enough to generate a good looking terrain. It's just one of the intermediate steps in a way more complicated process. You need to simulate some real world phenomena: temperature, erosion, precipitation, that sort of thing. It's a CPU-heavy process, usually, but well worth the effort. Here are some interesting links:

Dungeon League - read all of it. Great stuff.

World generation articles on The Chronicles of Doryen:

(You can download the generator too, but it's written in C++)

情话墙 2024-10-05 15:59:31

您需要一个“主随机生成器”来决定新区域的外观,并以您选择的频率进行。对于山,选择你已有的。对于公寓,选择噪音较小的。

You need a "master random generator" that will decide what a new area should look like, with a frequency of your choosing. For mountains choose what you have already. For flats choose less noise.

拒绝两难 2024-10-05 15:59:31

然后您可以通过中值过滤器进行过滤。它会使你的表面变平。但它会摧毁山脉。这对于相对平坦的区域(例如凹陷和高原)来说非常有用。如果您想要陡峭的山脉(具有快速且大的高度差异),您应该有选择地应用此过滤器。

You can filter by median filter then. it will flatten your surface. But it will destroy mountains. This is fine for relatively flat areas like hollows and plateaus. If you want sharp mountains (with fast and big height diff) you should apply this filter selectively.

一个人的旅程 2024-10-05 15:59:31

您应该寻找更多材质,特别是程序纹理和噪音方面的材质。这三者有很多关联。您应该考虑使用多个具有不同参数的噪声函数,并使用不同的函数或运算符将它们组合起来。

为了帮助您解决问题,您可以使用一个函数来生成高频噪声,然后将其乘以低频噪声。这将导致低频噪声接近 1 时出现峰值,接近 0 时出现平坦。某种平滑/腐蚀算法也很酷。但您仍然需要大量的试验和错误,并微调参数才能至少获得可用的结果。

一些更复杂的地形可能需要超过 10 个带有 alpha 混合或平滑等的噪声函数。不要以为应用简单的过滤器就能得到漂亮的地形。

You should look for more materials especialy on procedural textures and noise. Those three are related a lot. You should think about using more than one noise function with different parameters and combine them using different functions or operators.

To help your case, you can use one function to generate high-frequency noise and then multiply it by low-frequency noise. This will result in peaks where low-frequency noise is closer to 1 and flats where it is close to 0. Some kind of smoothing/erosion algorithm is cool too. But you will still need lot of trial and error and fine tuning your parameters to get at least usable results.

Some more complex terains may need over 10 noise functions with alpha blending or smoothing and such. Dont think you will get nice looking terrain from aplying simple filter.

呆萌少年 2024-10-05 15:59:31

对于一个简单且看起来不错的解决方案,您可以做的是使用自定义曲线函数评估从噪声图获得的高度。

例如,您可以将曲线图噪声点设置为从 0.1-0.3 到 0.1-0.15,然后从 0.3-1.0 到 0.15-1.0。

这样,您仍然可以保持地形的实际粗糙度,但使其变得更平坦。

What you can do for an easy and ok looking solution is to Evaluate the height you get from your noise map with a custom curve function.

For example you can make your curve map noise points from 0.1-0.3 to 0.1-0.15 and then from 0.3-1.0 to 0.15-1.0.

This way you still keep the actual roughness of the terrain but make it flatter.

浪漫之都 2024-10-05 15:59:30

我相信您需要使用平滑函数来消除地形的锯齿状,如果这似乎是您的问题。

我只浏览了此页面,但这可能是一个不错的指南: http://www.float4x4.net/index.php/2010/06/geneating-realistic-and-playable-terrain-height-maps/

I believe you need to use a smoothing function to get rid of the jaggedness of the terrain, if that seems to be your problem.

I only glanced through this page, but it may be a decent guide: http://www.float4x4.net/index.php/2010/06/generating-realistic-and-playable-terrain-height-maps/

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