Unity Ray Tracing 的实现和应用——助力移动端光追的落地实现

Unity的图形技术主管金晓宇在天玑开发者日上分享了关于UnityRayTracing的实现和应用,探讨了如何在移动端游戏开发中实现光线追踪。文章介绍了光线追踪技术在提升游戏画质和体验中的作用,Unity的RayTracingAccelerationStructure和RayTracingShaders的概念,以及InlineRayTracing作为RayTracingpipeline的替代方案,提供了更高的灵活性和性能优化的可能性。Unity正与MediaTek合作开发适用于移动端的InlineRayTracingdemo,并计划集成调试和性能分析工具。
近几年,光线追踪技术的兴起使主机游戏画质提升到了新高度,带给玩家更逼真的视觉效果和沉浸式的游戏体验,获得了广泛认可。 随着移动游戏的发展,玩家对在移动端开启更高帧率与更真实画质的体验需求越发强烈,Unity 也在探索助力开发者在移动端游戏开发中实现光线追踪的工具集和性能优化方案。
在2023年4月11日/4月13日举办的天玑开发者日—追光行动上,Unity 图形技术主管金晓宇分享了题为《Unity Ray Tracing 的实现和应用——助力移动端光追的落地实现》的演讲,介绍了 Unity 对光线追踪技术的理解、开发计划和方案。
大家好!我是来自 Unity 中国的金晓宇,主要在公司里负责图形渲染相关的方向,今天我分享的题目是 Unity 的 Ray Tracing 实现,助力移动端光追的落地实现。
Ray Tracing 是现代 API 提供的功能,比如 DXR 或者 Vulkan,旨在利用提供硬件加速的 GPU 进行光线追踪,通常作为光栅化的补充而不是替代。为什么需要 Ray tracing pipeline?首先,Ray Tracing 可以用来实现反射或折射,以渲染那些不在 camera view 中的对象;第二,Ray Tracing 可以作为现有一些方案的进化,像一些焦散、半透明物体、以及动态的全局光照,都可以用 Ray Tracing 做出更好的效果。
首先我们回顾一下基本的两个概念,一个是 Ray Tracing 的加速结构,这关系到我们在场景里面画什么东西。第二是 Ray Tracing Shaders,关系到如何在场景画物体。
加速结构(Acceleration Structure)是我们进行求交运算的空间结构。右图是这个场景的 AS 示例图,用于左图所示的 cornel box,我们可以看到它是由底层 BLAS 和顶层 TLAS 结构组成的。
底层的加速结构就是像球、棱柱、平面这些东西,为每个 mesh 定义一个 BLAS。有了这些东西之后,我们场景还有很多的不同材质,通过指向关联的 BLAS 并包括相关的 transform 和 material 信息来构建相对应的实例,可以看到有红色、绿色的墙,然后驱动程序将根据实例来创建 BVH 结构,最终生成顶层加速结构 (TLAS)。这都是由系统帮助我们来构建的。
在 Unity 中有这样一个东西,叫做 RayTracingAccelerationStructure,加入这样一个类,把加速结构进行封装。封装的加速结构功能可以有两种管理模式:一种是自动化的模式,一种是手动的模式。使用自动化的模式,所有符合条件的游戏对象都会在添加到场景时添加到 AS。如果使用手动模式,那么我们必须使用 AddInstance 显式地将 GameObjects 添加到 AS 并使用 UpdateInstanceTransform 更新 transform,其好处是可以手动管理加速结构的构建。在以上两种情况下,我们都可以在创建时指定 layer mask 以过滤哪些 game object 可以添加到加速结构中。
最后我们需要调用 BuildRayTracingAccelerationStructure 方法来更新或者重建加速结构,它会判断 transform 当前是不是有改变,自动判断是不是需要在 GPU 上更新或者重建加速结构。
For those that do not know me: My name is Jacco Bikker, also known as 'Phantom'. I work as '3D tech guy' at Overloaded, a company that develops and distributes games for mobile phones. I specialize at 3D Symbian games, which require highly optimized fixed-point, non-HW-accelerated 3D engines, crammed into 250Kb installers. So basically I'm having fun. As software rendering used to be my spare time activity, I was looking for something else. I tried some AI, which was great fun, and recently I dove into a huge pile of research papers on raytracing and related topics; such as global illumination, image based lighting, photon maps and so on. One document especially grabbed my attention. It's titled: "State-of-the-Art in Interactive Ray Tracing", and was written by Wald & Slusallek. I highly recommend this paper. Basically, it summarizes recent efforts to improve the speed of raytracing, and adds a couple of tricks too. But it starts with a list of benefits of raytracing over rasterization-based algorithms. And one of those benefits is that when you go to extremes, raytracing is actually faster than rasterizing. And they prove it: Imagine a huge scene, consisting of, say, 50 million triangles. Toss it at a recent GeForce with enough memory to store all those triangles, and write down the frame rate. It will be in the vicinity of 2-5. If it isn't, double the triangle count. Now, raytrace the same scene. These guys report 8 frames per second on a dual PIII/800. Make that a quad PIII/800 and the speed doubles. Raytracing scales linearly with processing power, but only logarithmically with scene complexity. Now that I got your attention, I would like to move on to the intended contents of this crash course in raytracing.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值