将子项添加到场景 ARKit/SceneKit 时 FPS 下降 [英] FPS drop when adding child to a scene ARKit/SceneKit

查看:21
本文介绍了将子项添加到场景 ARKit/SceneKit 时 FPS 下降的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在从事 ARKit 项目已有 4 个月了.我注意到在我的场景 rootNode 中添加一个孩子时,FPS 会下降.设备冻结不到一秒钟.我做了很多研究和试验,注意到所有 Apple 的代码示例在放置对象时也有这个 FPS 下降.节点是直接添加(scene.rootNode.addChild(child))还是在不同阶段(didUpdateAtTime、didApplyAnimations 等)添加到渲染器循环中都没有关系.我发现一旦一个对象被添加到场景中,下一个添加的对象将立即渲染.我使用在 SceneKit 编辑器中创建的 3D 模型,在将它们添加为子节点之前克隆它以生成我的不同节点.我在放置对象之前做这个加载工作.

I'm working on an ARKit project for 4 months now. I noticed that when adding a child to my scene rootNode, there is a FPS drop. The device freezes for less than a second. I did a lot of research and trials, noticed that all Apple's code examples have this FPS drop too when placing an object. It does not matter if the node is added directly (scene.rootNode.addChild(child)) or if it's added in the renderer loop at different phases (didUpdateAtTime, didApplyAnimations etc...). I found that once an object has been added to a scene, the next added object will render immediately. I use a 3D model created in SceneKit editor, clone it to generate my different nodes before adding them as child. I do this loading work before placing the objects.

仪器显示渲染器循环在冻结期间很忙.

Instruments shows that the renderer loop is busy for the duration of the freeze.

我找到的唯一解决方案是在开始整个体验之前将我的节点添加到加载屏幕后面的场景中.

The only solution that I found is to add my nodes to the scene behind a loading screen before starting the whole experience.

在使用节点之前渲染节点是游戏编程中的正常行为吗?

Is that a normal behavior in game programming to render nodes before using them ?

谢谢各位

推荐答案

随着 ARKit 3.0 及其卫星 - RealityKit(具有优化渲染引擎的框架和更改场景的层次结构,它是用 Swift 编写的,因此它没有 Objective-C 绑定),当添加一个孩子时,丢帧被减少到一个不可察觉的值.

With the release of ARKit 3.0 and its satellite – RealityKit (framework with optimised rendering engine and changed scene's hierarchy, that was written in Swift hence it has no Objective-C binding), a drop-frame, when adding a child, is reduced to an imperceptible value.

ARKit3/RealityKit 韧带的这种可预测行为对于具有 A12 仿生和 A13 仿生采用 7 纳米工艺制造(当然,因为它们拥有上一代神经引擎和强大的 GPU).

And such a predictable behaviour of ARKit3/RealityKit ligament is especially true for devices with processors A12 Bionic and A13 Bionic manufactured on 7 nm process (and, of course, due to the fact they have last-gen neural engines and powerful GPUs).

对于处理器功能较弱的设备(A9、A10、A11),建议使用每个模型的多边形总数不超过 10K 的 3D 模型,并使用诸如 .blinn 之类的常用着色器.phong(不是 PBR).

For devices with a less powerful processors (A9, A10, A11), it is advisable to use 3D models with a total number of polygons of no more than 10K per model, and with usual shaders like .blinn or .phong (not PBR).

我相信对于使用游戏引擎的游戏和应用程序来说,在使用它们之前首先将所有必要的游戏资产(如 3D 模型、纹理、声音文件等)加载(​​或缓存)到 RAM 中是一种非常普遍的做法.有关更多详细信息,请阅读这篇文章这个文章.

I believe it's quite a common practice for games and apps that use game engines, to firstly load (or cache) all the necessary game assets (like 3D models, textures, sound files, etc) into RAM before using them. For further details please read this article and this article.

但是,值得一提的是,AR 游戏与 VR 游戏不同,需要更多的处理能力,因此需要对其进行仔细优化.所以,在使用节点之前渲染节点是绝对正确的,这是游戏编程中的正常行为.

However, it’s worth saying that AR games, unlike VR games, consume considerably more processing power, therefore they need to be carefully optimised. So, you're absolutely right, rendering nodes before using them and it's a normal behaviour in game programming.

这篇关于将子项添加到场景 ARKit/SceneKit 时 FPS 下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆