比例对象时FPS掉落。如何修复? Unity Android

发布于 2025-02-11 20:22:02 字数 437 浏览 0 评论 0原文

有一个空的场景,其中一个标准立方体。如果将其比例更改为(5; 5; 1),则FPS不会下降。 但是,如果我将其更改为(5; 10; 1)我的FPS降至〜30。

如果我用比例(5; 10; 1)将相机从立方体移开,则FPS再次为60。 也许我有错误的相机设置或其他方式。

如何在不移开相机的情况下实现高FPS?

PS FPS不会落入编辑器中。只有在Android上发射之后。 Unity版本2020.3.18F1。尝试了另一个版本相同的问题。

cube带有比例(5; 5; 1)

​=“ nofollow noreferrer”>具有比例(5; 10; 1)和相机遥远的立方体

There is an empty scene with one standard cube. If you change its scale to (5;5;1), then the fps does not drop.
But if I change it to (5; 10; 1) my fps drops to ~30.

If I move the camera away from the cube with the scale (5;10;1), then the fps is again 60.
Maybe I have wrong camera settings or something else.

How to achieve high fps without moving the camera away?

p.s. The fps does not drop in the editor. Only after launching on android.
Unity version 2020.3.18f1. Tried on another version same problem.

cube with scale(5;5;1)

cube with scale(5;10;1)

cube with scale(5;10;1) and camera is distant

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

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

发布评论

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

评论(2

无需解释 2025-02-18 20:22:03

问题可能是由于呈现对象扩展时渲染更多像素(每次执行片段着色器)的事实。另一个暗示是,当您将摄像机移开远离对象时,帧速率随着渲染对象的产生较少的像素而增加。

正如您提到的那样,该程序在Android上运行,将常规着色器更改为移动着色器可能会提高性能。

The problem may be due to the fact that more pixels is rendered (fragment shader is executed for every one) when the object is scaled up. The other hint is that when you move the camera far from the object the frame rate is increased as the rendered object generates fewer pixels.

As you mentioned that the program runs on Android, changing a regular shader to mobile shader may improve the performance.

深空失忆 2025-02-18 20:22:03

从unity上的某些统一文档

绩效问题和不均匀缩放的局限性
非均匀缩放是在变换中的尺度具有不同的x,y和z的值时;例如(2、4、2)。相反,均匀缩放的x,y和z具有相同的值。例如(3、3、3)。在几种选择的情况下,不均匀缩放可能很有用,但应尽可能避免。

非均匀缩放对渲染性能有负面影响。为了正确地转换顶点:我们在CPU上转换网格并创建额外的数据副本。通常,我们可以在图形内存中的实例之间共享网格,但是在这种情况下,您同时支付CPU和每个实例的内存成本。

在这种情况下,我不确定您的Z量表是否重要,因为您只是渲染XY平面。当您增加相机距离时,我无法确定为什么降低性能命中率。我怀疑Unity具有一些智能的顶点操纵,以简化遥远对象的渲染,从而节省了CPU成本。

话虽如此,请尽量避免缩放。原语通常仅应用作占位符。

From some of Unity's documentation on transforms

Performance Issues and Limitations with Non-Uniform Scaling
Non-uniform scaling is when the Scale in a Transform has different values for x, y, and z; for example (2, 4, 2). In contrast, uniform scaling has the same value for x, y, and z; for example (3, 3, 3). Non-uniform scaling can be useful in a few select cases but should be avoided whenever possible.

Non-uniform scaling has a negative impact on rendering performance. In order to transform vertex normals correctly, we transform the mesh on the CPU and create an extra copy of the data. Normally we can keep the mesh shared between instances in graphics memory, but in this case you pay both a CPU and memory cost per instance.

I'm not certain if your Z's scale matters in this case, because you're only rendering the x-y plane. I can't comment for certain on why the performance hit is reduced as you increase your camera distance. I suspect Unity has some intelligent vertex manipulation going on to simplify rendering of distant objects, saving you on CPU cost.

That being said, try to avoid non-uniform scaling. Primitives should typically only be used as placeholders.

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