金属射线追踪 – SceneKit 或 RealityKit

发布于 2025-01-18 06:39:43 字数 234 浏览 1 评论 0原文

下面的wwdc21演讲显示了如何“用金属射线跟踪”

如何将金属射线跟踪添加到Scenekit或RealityKit应用程序中?

任何基本的示例或参考代码都将不胜感激!

The WWDC21 talk below shows how to "Enhance your app with Metal ray tracing".

How can I add Metal ray tracing to a SceneKit or RealityKit app?

Any basic example or reference code would be hugely appreciated!

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

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

发布评论

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

评论(1

方觉久 2025-01-25 06:39:43

我花了一些时间为您和对此主题感兴趣的其他人准备示例应用程序。这些应用程序是纯 Swift with Metal,目前设计为在 iOS 平台上运行。 (我个人推荐一个快速的设备)

在这里你可以找到第一个“简单”的默认Apple RayTracer:

https:// github.com/philvanza/SceneKit-RayTracing

这里同一个应用程序带有一个额外的、更复杂的 RayTracer,支持 BSDF(双向散射分布函数),它允许您光线追踪 i.Ex。透明玻璃:

https://github.com/philvanza/SceneKit-RayTracing-Advanced

基本上您需要以下内容来实现光线追踪:

  • 从您想要进行光线追踪的 SceneKit 节点中提取几何数据
  • 构建三角形加速结构(特定于 Metal)
  • 准备要在 GPU 上执行的缓冲区
  • 将整个内容发送到RayTracer
  • 随着时间的推移累积输出图像

让 RayTracer 运行的时间越长,结果就越好。

在这里添加太多代码,所以我准备了这个存储库。如果您对 RayTracers 有何看法,请随时给我留言。

玩得开心!

示例图像来自简单的光线追踪器

来自高级 RayTracer 的示例图像

It took me some time to prepare example apps for you and anyone else interested in this topic. The apps are pure Swift with Metal and are currently designed to run on iOS platforms. (I personally recommend a fast device)

Here you can find the first "simple" default Apple RayTracer:

https://github.com/philvanza/SceneKit-RayTracing

And here the same app with an additional, more complex RayTracer that supports BSDF (Bidirectional Scattering Distribution Function) which allows you to RayTrace i.Ex. transparent glass:

https://github.com/philvanza/SceneKit-RayTracing-Advanced

Basically you need the following to achive RayTracing:

  • Extract the geometry data from the SceneKit node you want to RayTrace
  • Build a triangle acceleration structure (Metal specific)
  • Prepare the buffers to execute on the GPU
  • Send the whole stuff to the RayTracer
  • Accumulate the output image over time

The longer you let the RayTracer run, the better the result becomes.

It would take too much code to add here, so I prepared this repositories. Feel free to leave me a comment on whatever you think about the RayTracers.

Have fun!

Exaple Image from the Simple RayTracer

Exaple Image from the Advanced RayTracer

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