有人可以描述 Ken Silverman 的 Voxlap 引擎使用的算法吗?

发布于 2024-09-24 14:07:28 字数 248 浏览 9 评论 0原文

据我收集的信息,他使用了稀疏体素八叉树和光线投射。他似乎没有使用 opengl 或 direct3d,当我查看 Voxelstein 游戏时,似乎实际上正在绘制微型立方体,而不仅仅是一堆 2d 正方形。这让我措手不及,我不确定他在没有 opengl 或 direct3d 的情况下是如何做到这一点的。

我尝试通读源代码,但我很难理解发生了什么。我想实现类似的东西,并希望算法能够这样做。

我对他如何执行渲染、剔除、遮挡和照明感兴趣。任何帮助表示赞赏。

From what I gathered he used sparse voxel octrees and raycasting. It doesn't seem like he used opengl or direct3d and when I look at the game Voxelstein it appears that miniature cubes are actually being drawn instead of just a bunch of 2d square. Which caught me off guard I'm not sure how he is doing that without opengl or direct3d.

I tried to read through the source code but it was difficult for me to understand what was going on. I would like to implement something similar and would like the algorithm to do so.

I'm interested in how he performed rendering, culling, occlusion, and lighting. Any help is appreciated.

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

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

发布评论

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

评论(2

猛虎独行 2024-10-01 14:07:28

该算法比光线追踪更接近光线投射。您可以在这里得到 Ken Silverman 本人的解释:

https://web.archive.org/web/20120321063223/http://www.jonof.id.au/forum/index.php?topic=30.0

简而言之:在网格上,存储每个 x,y 体素堆栈的表面体素 rle 列表(如果 z 表示“向上”)。假设有 4 个自由度,针对屏幕上的每条垂直线进行光线投射,并维护一个可见跨度列表,该列表在绘制每个立方体时被剪裁。对于 6 个自由度,执行类似的操作,但使用在屏幕空间中倾斜的扫描线。

The algorithm is closer to ray-casting than ray-tracing. You can get an explanation from Ken Silverman himself here:

https://web.archive.org/web/20120321063223/http://www.jonof.id.au/forum/index.php?topic=30.0

In short: on a grid, store an rle list of surface voxels for each x,y stack of voxels (if z means 'up'). Assuming 4 degrees of freedom, ray-cast across it for each vertical line on the screen, and maintain a list of visible spans which is clipped as each cube is drawn. For 6 degrees of freedom, do something similar but with scanlines which are tilted in screenspace.

眼趣 2024-10-01 14:07:28

我没有查看算法本身,但我可以根据屏幕截图判断以下内容:

看起来实际上是在绘制微型立方体,而不仅仅是一堆二维正方形

正方形是的,这就是光线追踪的工作原理。它不绘制二维正方形,而是追踪光线。如果您将光线追踪到许多微型立方体,您会看到许多微型立方体。该场景由许多微型立方体(体素)表示,因此当您近距离观察时您会看到它们。最好以某种方式实际平滑数据(跟踪平滑的能量函数)以使它们看起来更平滑。

我对他如何进行渲染感兴趣

通过光线追踪

进行渲染感兴趣

剔除

光线追踪时不需要剔除,特别是在体素场景中。当您沿着射线移动时,您仅检查射线相交的体素。

遮挡

体素-体素遮挡是通过光线追踪自然处理的;它将返回第一个体素命中,这是最接近的。如果您绘制精灵,您可以使用光线追踪器生成的 Z 缓冲区。

和灯光

通过查看附近的单元格并查看哪些被占用、哪些未被占用,可以近似局部法线。然后进行光照计算。或者,每个体素可以存储法线及其颜色或其他材料属性。

I didn't look at the algorithm itself, but I can tell the following based off the screenshots:

it appears that miniature cubes are actually being drawn instead of just a bunch of 2d square

Yep, that's how ray-tracing works. It doesn't draw 2d squares, it traces rays. If you trace your rays against many miniature cubes, you'll see many miniature cubes. The scene is represented by many miniature cubes (voxels), hence you see them when you look up close. It would be nice to actually smoothen the data somehow (trace against smoothed energy function) to make them look smoother.

I'm interested in how he performed rendering

by ray-tracing

culling

no need for culling when ray-tracing, particularly in a voxel scene. As you move along the ray you check only the voxels that the ray intersects.

occlusion

voxel-voxel occlusion is handled naturally by ray-tracing; it would return the first voxel hit, which is the closest. If you draw sprites you can use a Z-buffer generated by the ray-tracer.

and lighting

It's possible to approximate the local normal by looking at nearby cells and looking which are occupied and which are not. Then performing the lighting calculation. Alternatively each voxel can store the normal along with its color or other material properties.

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