基于体素的地形的适当密度函数?

发布于 2025-01-07 16:20:44 字数 264 浏览 4 评论 0原文

我已经成功地用 C# 实现了 Marching Cubes 算法。到目前为止,我已经尝试过渲染球体的算法。这是一个简单的问题,因为密度函数的编码并不是很复杂。

但现在我想让算法更进一步,为游戏渲染一些有趣的地形。所以我需要适当的密度函数来完成这项任务。 我首先想到的是体积柏林噪声。没关系,但我正在寻找没有凸形状的地形,我的意思是,目前没有洞穴和类似的几何形状。

好的,我知道一个简单的高度图可以完成这项工作,但我想要一个体素生成的地形。我需要什么类型的密度函数或伪代码来实现它们?

I've managed to implement the Marching Cubes algorithm in C#. Up to now I've tried the algorithm to render a sphere. That's an easy one because the density function is not very complex to code.

But now I want to get the algorithm to go further and render some interesting terrains for games. So I would need proper density functions for this task.
First thing that comes to my head is a Volumetric Perlin Noise. That's ok but I am looking for a terrain without convex shapes, I mean, no caves and similar geometries by the moment.

Ok, I know that for that a simple height map can do the job, but I want a voxel-generated terrain. What type of density function o pseudocode would I need to implement them?

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

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

发布评论

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

评论(1

つ可否回来 2025-01-14 16:20:44

您可以轻松地将高度图转换为体素地形。高度图中的每个像素对应于体素世界中的一列体素。对于高度图中的给定像素,读取高度。然后迭代相应列中的每个体素,如果它小于您的参考高度,则将其设置为“实心”;如果它大于您的参考高度,则将其设置为“空”。

这是一些使用 示例代码 href="http://www.volumesoffun.com/polyvox-about/" rel="nofollow">PolyVox 库。

You can easily convert a heightmap into voxel terrain. Each pixel in your heightmap corresponds to a column of voxels in your voxel world. For a given pixel in the heightmap read the height. Then iterate over each voxel in the corresponding column and set it to 'solid' if it is less than your reference height or 'empty' if it is more than your reference height.

Here is some sample code using the PolyVox library.

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