概述
unity5物理材质
We’d like to highlight some of the 3D physics changes you can look forward to in Unity 5.0.
我们想强调一些您可以在Unity 5.0中期待的3D物理变化。
We’ve been using PhysX 2.8.3 for a while now. We’ve not just used the plain stock PhysX, but extended it with numerous patches made by Unity engineers over the years. It’s been so long, and we say thanks to PhysX 2 for all the fish. As announced at GDC’14, Unity 5.0 features an upgrade to PhysX 3.3. Let’s give it a closer look.
我们已经使用PhysX 2.8.3已有一段时间了。 我们不仅使用普通的PhysX,而且还扩展了Unity工程师多年来开发的许多补丁。 已经很久了,我们要感谢PhysX 2的所有支持。 正如在GDC'14上宣布的那样,Unity 5.0对PhysX 3.3进行了升级。 让我们仔细看看。
PhysX SDK 3 is a radical redesign of the good old PhysX SDK 2.x. Basically, the PhysX team have taken the best ideas and best approaches from 2.x and rewritten the whole SDK from scratch. That means the entire codebase is different, all the interfaces are different and most of the functionality is different.
PhysX SDK 3是对旧版PhysX SDK 2.x的彻底重新设计。 基本上,PhysX团队采用了2.x的最佳创意和最佳方法,并从头开始重写了整个SDK。 这意味着整个代码库是不同的,所有接口都不同,并且大多数功能都不同。
Now let’s give you a taste of how it feels to use Unity 5.0 physics.
现在让我们来看看使用Unity 5.0物理的感觉。
To start with something simple, we’ve made the adaptive force switchable and off by default. Adaptive force is a special technique in PhysX to compensate for numerical errors when simulating stacks. However, feedback from Unity developers tells us that adaptive force contributes a lot to overall instability in game content. Expect your stack-like things to behave better in future.
首先,我们将自适应力默认设置为可切换和关闭。 自适应力是PhysX中的一种特殊技术,用于在模拟堆栈时补偿数值误差。 但是,来自Unity开发人员的反馈告诉我们,自适应力会导致游戏内容的整体不稳定。 希望将来类似堆栈的事情表现得更好。
移动静态碰撞器 (Moving Static Colliders)
Moving Static Colliders will be a lot less expensive. A Static Collider is just a gameobject with a collider component on it, but without a Rigidbody component. Previously, since the SDK assumed that Static Colliders aren’t moved, moving a Static Collider would trigger an expensive AABB tree rebuild that affected overall performance badly.
移动静态碰撞器将便宜很多。 静态对撞机只是带有对撞机组件的游戏对象,而没有刚体组件。 以前,由于SDK假定不移动“静态碰撞器”,因此移动“静态碰撞器”会触发昂贵的AABB树重建,从而严重影响整体性能。
In Unity 5, we’ll use the same data structure to handle the movement of both dynamic and static colliders. Unfortunately, we’ll lose the benefit of Static Colliders consuming less memory than dynamic ones. However, right now, the cost associated with moving Static Colliders is one of the top 3 causes of performance issues in Unity games. We wanted to change that.
在Unity 5中,我们将使用相同的数据结构来处理动态和静态碰撞器的运动。 不幸的是,我们将失去静态碰撞器比动态碰撞器消耗更少内存的好处。 但是,目前,与移动静态碰撞器相关的成本是Unity游戏中性能问题的三大原因之一。 我们想改变这一点。
碰撞检测 (Collision detection)
Continuous collision detection has been improved by an order of magnitude. Continuous collision detection is used to prevent fast-moving bodies from going through other bodies without any collisions detected. Imagine a bullet shot at a piece of paper, or a game of pool where some balls will move faster than others.
连续碰撞检测已提高了一个数量级。 连续碰撞检测用于防止快速移动的物体穿过其他物体而未检测到任何碰撞。 想象一下子弹击中一张纸,或者打一场台球,其中有些球的移动速度会比另一些更快。
In Unity 5.0, the SDK generates all the data required to handle fast movement. You just enable continuous collision detection and it works. PhysX3 features an algorithm used to detect whether the expensive CCD simulation is actually needed given the current body velocity or a default discreet would do just fine. It’s activated once you enable the CCD.
在Unity 5.0中,SDK会生成处理快速移动所需的所有数据。 您只需启用连续碰撞检测即可。 PhysX3具有一种算法,该算法可用于检测在当前体速或默认谨慎情况下是否确实需要昂贵的CCD仿真。 一旦启用CCD,它就会被激活。
广义上的刚体 (Rigidbodies on the broadphase)
PhysX3 supports more Rigidbodies on the broadphase. In fact, you’ll be able to have several hundred thousand bodies on a single frame on desktop and desktop-like platforms. Previously, there was a fixed 64k limit on bodies. That wasn’t a constant that we could easily increase – it was a consequence of saving a lot on bits all over the SDK. Some console targets, such as PlayStation 3 will still have this limitation. There’s also a limit on physics materials: at the time of writing, you can’t have more than 64k of materials on any platform.
PhysX3在广泛阶段支持更多的刚体。 实际上,在台式机和类似台式机的平台上,您可以在一个框架上拥有数十万个实体。 以前,车身的固定限制为64k。 这不是一个我们可以轻易增加的常数-这是因为在整个SDK上节省了大量的位。 某些控制台目标(例如PlayStation 3)仍将具有此限制。 物理材料也有限制:在撰写本文时,任何平台上的材料不得超过64k。
缩放网格碰撞器是免费的(或多或少) (Scaling Mesh Colliders is free (more or less))
In Unity 5.0 we’ve reduced the cost of scaling Mesh Colliders. Previously, when scaling a Mesh Collider, you would have to create a new mesh with scale baked into the vertices, and that required valuable time and memory. With PhysX3 we are able to support non-negative scaling without any baking. It’s basically free.
在Unity 5.0中,我们降低了缩放网格碰撞器的成本。 以前,在缩放网格对撞机时,必须创建一个新的网格,并将缩放比例烘焙到顶点中,这需要宝贵的时间和内存。 借助PhysX3,我们无需任何烘烤即可支持非负缩放。 它基本上是免费的。
Next, let’s take a look at two subsystems that differ so much from the Unity 4.x version that you can think of them as new: the cloth and vehicles modules.
接下来,让我们看一下两个子系统,它们与Unity 4.x版本有很大不同,您可以将它们视为新的子系统:衣服和车辆模块。
布成分 (Cloth component)
Let’s start with cloth. In Unity 4 cloth simulation is supported via InteractiveCloth and SkinnedCloth components. InteractiveCloth has a cloth-like mesh behaviour i.e. “physical cloth” that interacts with other physics bodies, can apply forces and so on. InteractiveCloth is computationally expensive, so Unity 4 has another one, SkinnedCloth, for character clothing.
让我们从布料开始。 在Unity 4中,通过InteractiveCloth和SkinnedCloth组件支持布料模拟。 InteractiveCloth具有类似于布的网格行为,即“物理布”,它可以与其他物理物体相互作用,可以施加力等。 InteractiveCloth在计算上非常昂贵,因此Unity 4还有另一个用于角色服装的SkinnedCloth。
Since SkinnedCloth is decoupled from the main simulation pipeline, it is able to perform better than InteractiveCloth. The main problem with cloth is that both components were quite unstable and cost a lot. With PhysX3 integration coming, we have decided to drop support for InteractiveCloth and only have one cloth component, called simply Cloth, designed with character clothing in mind.
由于SkinnedCloth与主仿真管道分离,因此它的性能比InteractiveCloth更好。 布的主要问题是两个组件都非常不稳定并且成本很高。 随着PhysX3集成的到来,我们决定放弃对InteractiveCloth的支持,而只考虑一种服装组件(简称为Cloth),其设计考虑了角色服装。
In Unity 5.0, Cloth no longer reacts to all colliders in a scene, nor does it apply forces back to the world. Instead, we have a faster, multithreaded, more stable character clothing solution. When you add it the new Cloth component no longer reacts to any bodies at all.
在Unity 5.0中,布料不再对场景中的所有对撞机做出React,也不会向世界施加力量。 相反,我们有一个更快,多线程,更稳定的角色服装解决方案。 当您添加它时,新的Cloth组件将不再对任何物体产生React。
Thus, Cloth and the world do not recognise or see each other until you manually add colliders from the world to the Cloth component. Even after that, the simulation is still one-way: cloth reacts to those bodies but doesn’t apply forces back. Additionally, you can only use three types of colliders with cloth: a sphere, a capsule, and conical capsule colliders, constructed using two sphere colliders. These changes have all been introduced to boost performance.
因此,在您手动将来自世界的碰撞器添加到Cloth组件之前,Cloth和世界不会彼此识别或看到。 即使在那之后,模拟仍然是单向的:布料会对那些物体做出React,但不会向后施加力。 此外,您只能在布上使用三种类型的对撞机:一个球体,一个胶囊和一个由两个球体对撞器构造的圆锥形胶囊对撞机。 引入了所有这些更改以提高性能。
The authoring interface in Unity 5.0 is similar to the SkinnedCloth one, and we are working hard on improving that in 5.x. Expect to see things like integration with Mecanim avatars added during the 5.x cycle.
Unity 5.0中的创作界面与SkinnedCloth相似,我们正在努力在5.x中进行改进。 希望看到在5.x周期中添加了与Mecanim头像集成等功能。
The new Cloth component supports the GPU via CUDA internally, but we’ve decided to release this later in the 5.x cycle for several reasons. Firstly, CUDA only works on Windows on NVIDIA hardware, and we have a big presence on Mac & Linux. Secondly, we really want to focus our bug fixing efforts on core stuff first and move on to integrate fancy things after that.
新的Cloth组件内部通过CUDA支持GPU,但是出于以下几个原因,我们决定在5.x周期中发布它。 首先,CUDA仅可在NVIDIA硬件上的Windows上运行,而在Mac和Linux上我们占有很大的份额。 其次,我们真的很想先将错误修复工作集中在核心内容上,然后再将其整合到奇特的东西上。
新车SDK (New Vehicle SDK)
Now, a few words about vehicles. PhysX3 has a shiny new Vehicle SDK which we’ve used to implement our WheelCollider component. The new component delivers much more realistic suspension and tire friction. Plus, it fixes a number of other long-standing issues.
现在,关于车辆的几句话。 PhysX3有一个闪亮的新Vehicle Vehicle SDK,我们已经使用它来实现Wheelwheel组件。 新组件提供了更加逼真的悬架和轮胎摩擦。 此外,它还解决了许多其他长期存在的问题。
In Unity 5.0, the new component can be used out of the box to generate a simple behaviour. I only expect developers to go for vehicle packages on the Asset Store when they want something that is already fine-tuned, realistic or advanced, like Edy’s Vehicle Package.
在Unity 5.0中,可以立即使用新组件来生成简单的行为。 我只希望开发人员在需要诸如Edy's Vehicle Package之类已经微调,逼真的或高级的产品时,就在Asset Store上购买车辆包装 。
Look at what I’ve been able to set up in a couple of hours using a free mesh downloaded from the web (most of that time was spent in Blender preparing the model):
看一下我使用从网上下载的免费网格在几个小时内就能完成的设置(大部分时间都花在Blender准备模型中):
And here is one of the SUVs from Edy’s Vehicle Package:
这是Edy's Vehicle Package中的SUV之一:
Edy is currently working on the new version of his package which will bring more amazing stuff. Contact him directly for more details.
Edy目前正在开发其软件包的新版本,它将带来更多令人惊奇的东西。 直接联系他以获取更多详细信息。
The are a lot of fantastic technical details about vehicles I’d like to share with you, but, for now, let’s just take a look at the new WheelCollider gizmos. This will give you an idea of how suspension is going to work as well.
我想与您分享有关车辆的许多神奇的技术细节,但是,现在,让我们看一下新的WheelCollider小发明。 这将使您了解暂停也将如何工作。
In the above picture the wheel circle and wheel diameter are marked in green, the suspension travel segment in orange and the force application point sphere in green. On the suspension travel segment, there are marks for maximum compression position, maximum droop position and target position.
在上图中,轮圈和轮径标记为绿色,悬架行程段为橙色,施力点球体为绿色。 在悬架行程段上,有最大压缩位置,最大下垂位置和目标位置的标记。
As you’d expect, the wheel can only travel between the max compression and max droop positions. The target position (also referred to as the rest position in technical talks) is located exactly where the sprung weight is balanced by the spring force; i.e. the position where the wheel is located when the vehicle is just standing on a flat surface. It might seem tricky to tune, but, actually, the max compression position is where your wheel is located originally in the mesh.
如您所料,轮子只能在最大压缩位置和最大下垂位置之间移动。 目标位置(在技术讲座中也称为静止位置)恰好位于簧重平衡于弹力的位置; 也就是说,当车辆正好站在平坦表面上时,车轮所在的位置。 调整似乎有些棘手,但实际上,最大压缩位置是您的轮子最初位于网格中的位置。
Next, you specify the suspension distance and target position as a fraction of suspension distance. Just two floats to rule them all, not a big deal! Have I told you that the new wheel gizmo now updates the rotation and position from the simulation data out of the box? You don’t even have to add actual wheel geometry and write the wheel positioning code to preview your settings. It’s all just built in.
接下来,将悬挂距离和目标位置指定为悬挂距离的一部分。 只需两个浮标即可将其全部统治,没什么大不了的! 我是否已经告诉过您,新的车轮Gizmo现在可以立即从仿真数据中更新旋转和位置? 您甚至不必添加实际的车轮几何形状并编写车轮定位代码即可预览设置。 全部都是内置的。
性能 (Performance)
PhysX3 is now prepared to run on multicores as the internal computation model is organised in tasks that can be executed on different cores. The SDK does all the multithreading, taking care of all the dependencies itself and granting optimal job decomposition.
PhysX3现在准备在多核上运行,因为内部计算模型是按可以在不同核上执行的任务组织的。 该SDK执行所有多线程处理,同时照顾所有依赖项并授予最佳作业分解。
From what we’ve seen so far, it’s reasonable to expect a doubling in performance generally just as a result of having a better code base and improved multithreading. In some instances, the improvement is dramatic, with up to tenfold improvements.
从到目前为止我们已经看到的情况来看,可以合理地预期性能通常会提高一倍,这是因为有了更好的代码库和改进了多线程。 在某些情况下,这种改进是惊人的,最多可以提高十倍。
Performance ninjas interested in more data should visit Pierre Terdiman’s blog. He’s the core developer behind the PhysX SDK.
对更多数据感兴趣的高性能忍者应该访问Pierre Terdiman的博客 。 他是PhysX SDK的核心开发人员。
兼容性 (Compatibility)
The new functions look and feel Unity-like, but there are still cases where the behaviour is different, parameters mean different things or, in some cases, old behaviours are no longer supported. Thus, Unity 5.0 physics is not 100% compatible with Unity 4.x. Be prepared to retune your old projects and rewrite some of your physics code when migrating from previous Unity releases.
新功能看起来像Unity,但是在某些情况下行为是不同的,参数表示不同的东西,或者在某些情况下,不再支持旧的行为。 因此,Unity 5.0物理特性与Unity 4.x并非100%兼容。 从Unity以前的版本进行迁移时,请准备好调整旧项目并重写一些物理代码。
There are many more details about physics in Unity 5 than I can share in this post. Please feel free to ask questions in the comments, or if you’re visiting our Unite 2014 developer conference this year, catch my in-depth talk on physics in Unity 5.0 and come say hi and have a chat.
我在这篇文章中无法分享有关Unity 5中物理的更多细节。 请随时在评论中提出问题,或者如果您正在今年访问我们的Unite 2014开发者大会,请收听我在Unity 5.0中有关物理的深入讨论,并打个招呼并聊天。
More about Unity 5
有关Unity 5的更多信息
翻译自: https://blogs.unity3d.com/2014/07/08/high-performance-physics-in-unity-5/
unity5物理材质
最后
以上就是可耐柚子为你收集整理的unity5物理材质_Unity 5中的高性能物理学的全部内容,希望文章能够帮你解决unity5物理材质_Unity 5中的高性能物理学所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复