简体   繁体   English

克隆节点和性能、几何和性能; IOS场景包

[英]Cloning nodes and performance, geometry, and performance; IOS Scenekit

I'm writing a app using Scenekit where the client wishes to push the limits of animation in IOS.我正在使用 Scenekit 编写一个应用程序,客户端希望在 IOS 中推动动画的极限。 This particular app has requirements where I"m pushing out to the screen over 1,500 redraws. Even with this many redraws, I've locked down the FPS to 60, which is great, but when I add all elements the client wants, the redraws are pushed to 7,500 redraws (and yes, this isn't a mistake or a joke, this is the redraw number even though it's almost 50-80 times more than most redraw times I've seen with scenekit). At this level of redrawing, the screen contains 1.7 million vertices, and around 800k polygons. This is aa lot of stuff, and it's really too much stuff for this app to be useful to anyone because now my FPS drops to 15-30FPS which is expected from drawing over 3K geometry elements on screen. What I've done so far:这个特定的应用程序要求我将超过 1,500 次重绘推到屏幕上。即使有这么多重绘,我也将 FPS 锁定为 60,这很好,但是当我添加客户想要的所有元素时,重绘被推到 7,500 次重绘(是的,这不是错误或笑话,这是重绘次数,尽管它几乎是我在 Scenekit 中看到的大多数重绘次数的 50-80 倍)。在这种重绘级别, 屏幕包含 170 万个顶点和大约 800k 个多边形。这是很多东西,这个应用程序对任何人都有用的东西太多了,因为现在我的 FPS 下降到 15-30FPS,预计会超过 3K屏幕上的几何元素。到目前为止我所做的:

  1. I clone all nodes, cloning allows me to push the limits of Scenekit.我克隆了所有节点,克隆允许我突破 Scenekit 的极限。 I was able to fit on screen over 1.5k constant CAAnimations with over 1.8K unique geometries placed in different locations across the screen.我能够在屏幕上放置超过 1.5k 个恒定 CAAnimations,并将超过 1.8k 个独特的几何图形放置在屏幕的不同位置。

  2. I've forced all windows, views, and screens in app to be opaque by looping through all windows and setting their opaque property to yes.我通过循环遍历所有窗口并将它们的 opaque 属性设置为 yes 来强制应用程序中的所有窗口、视图和屏幕都是不透明的。

Question is this, I can deal with the performance issues, but I'm having a problem with the node cloning.问题是这样,我可以处理性能问题,但是我遇到了节点克隆问题。 Well, the node cloning works, but the problem is that each geometry that is pushed to the screen must have a different size and it seems like there is no way to change the geometry of each separate clone.好吧,节点克隆有效,但问题是推送到屏幕的每个几何体必须具有不同的大小,并且似乎无法更改每个单独克隆的几何体。 I know that I can change the geometry of a "copied" node (SCNNode *node = [masterNode copy];), and I know I can change the materials property of a cloned node, but is there a way to change the geometry of the cloned node?我知道我可以更改“复制”节点的几何形状(SCNNode *node = [masterNode copy];),并且我知道我可以更改克隆节点的材料属性,但是有没有办法更改克隆节点? Apple doesn't give any insight about the geometry being changed, but they do talk about changing the materials. Apple 没有提供任何有关更改几何形状的信息,但他们确实谈到了更改材料。 Am I to assume that I can't change the size of the geometry of the clone?我是否假设我无法更改克隆几何体的大小? I can change the transform, pivot, rotation, animation, position, etc, of the clone, but the size of the geometry won't change.我可以更改克隆的变换、枢轴、旋转、动画、位置等,但几何体的大小不会改变。 For my purposes, I just need the "height" variable of a cylinder to be changeable, I have everything else in good order, AND, there's no other way to push over 2k redraws to a screen without node cloning, I've tried it without cloning and FPS drops to less than 10 with just 300 redraws when declaring each geometry and node with geometry as it's own unique variable.出于我的目的,我只需要一个圆柱体的“高度”变量是可变的,我把其他一切都安排得井井有条,而且,没有其他方法可以在没有节点克隆的情况下将 2k 重绘推到屏幕上,我试过了没有克隆和 FPS 下降到小于 10,只有 300 次重绘时,将每个几何图形和节点声明为几何图形,因为它是自己的唯一变量。

Lastly, given this same scenario, how much of a performance increase should I expect by moving from Scenekit to Metal.最后,考虑到同样的场景,从 Scenekit 迁移到 Metal 后,我应该期待多少性能提升。 I'm not worried about the math, the level of detail, the time consuming operations of setting up the rendering pipeline or whatever else might come my way, I'm merely trying to find the BEST solution for my problem here, and I've not used Metal yet because I'm not sure I'd get different results given how many polygons, vertices, and redraws are required.我不担心数学、细节水平、设置渲染管道的耗时操作或其他任何可能出现的问题,我只是想在这里为我的问题找到最佳解决方案,我”我还没有使用过 Metal,因为我不确定考虑到需要多少多边形、顶点和重绘,我会得到不同的结果。 Thanks.谢谢。

is there a way to change the geometry of the cloned node有没有办法改变克隆节点的几何形状

I believe you can change the baked geometry itself, but not the parametric one (not the SCNCylinder).我相信您可以更改烘焙几何体本身,但不能更改参数几何体(不是 SCNCylinder)。 So you can (to change the height):所以你可以(改变高度):

  • Scale the node缩放节点
  • Change the Transformation Matrix (so scaling too, just a different way to)更改转换矩阵(因此也可以缩放,只是一种不同的方式)
  • Add a Geometry Shader modifier that moves the points up/down on the axis you want添加几何着色器修改器,在您想要的轴上向上/向下移动点

Changing the actual geometry kind of defeats the whole purpose of cloning, so I don't think there is a way around that.改变实际的几何形状会破坏克隆的整个目的,所以我认为没有办法解决这个问题。

Lastly, given this same scenario, how much of a performance increase should I expect by moving from Scenekit to Metal.最后,考虑到同样的场景,从 Scenekit 迁移到 Metal 后,我应该期待多少性能提升。

A lot.很多。 Around 30% from what I've seen, but again it will depend on your setup.我所看到的大约 30%,但这同样取决于您的设置。 Metal comes with iOS 9, and you won't have to do anything to get it for your scene, so just update one of your devices and try it there, to see if it helps! Metal 随 iOS 9 一起提供,您无需执行任何操作即可为您的场景获取它,因此只需更新您的一台设备并在那里试用,看看是否有帮助!

Out of curiosity: why do you need so much cylinders?出于好奇:你为什么需要这么多钢瓶? Could you not cheat the way they are rendered?你不能欺骗他们的渲染方式吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM