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

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

问题描述

我正在研究ARKit项目四个月了. 我注意到,当将一个孩子添加到场景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韧带的这种可预测行为尤其适用于采用7 nm工艺制造的处理器 A12 Bionic和 A13 Bionic的设备(以及当然,由于它们具有最新一代的神经引擎和强大的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),建议使用3D模型,每个模型的多边形总数不超过10K,并使用.blinn(不是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.

但是,值得一提的是,与VR游戏不同,AR游戏消耗的处理能力要大得多,因此需要仔细优化它们.因此,您是完全正确的,在使用节点之前先渲染它们,这在游戏编程中是正常现象.

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天全站免登陆