手里输入前空格_手里剑–世界粒子碰撞
手里输入前空格
With Unity 4.0 we are adding support for world particle collsion detection. It’s quite awesome and very fast.
借助Unity 4.0,我们增加了对世界粒子碰撞检测的支持。 很棒而且非常快。
We spent a lot of time optimizing world particle collisions and also did more than a few optimizations to Shuriken in general. Especially on mobile devices Shuriken got a very big performance boost.
我们花了很多时间优化世界粒子碰撞,并且对Shuriken进行了很多优化。 尤其是在移动设备上,手里剑的性能有了很大提高。
Multithreading
多线程
Shuriken is multithreaded and so is collision detection.
手里剑是多线程的,冲突检测也是。
Batching
批处理
The reason why particle world collision becomes slow is due to the sheer number of raycasts and complexity of the raycasts performed. We have done several optimizations to minimize this cost.
粒子世界碰撞变慢的原因是射线束的绝对数量和所执行的射线束的复杂性。 我们已进行了一些优化,以最大程度地降低此成本。
We added support for batching raycasts. So we first find all PhysX shapes that touch all particles in a particle system, perform very fast cache localized early out culling of raycasts against those shapes on a per particle basis. Only then do we perform any per collider raycasts. This dramatically increases performance because at any one time, very few particles actually need the full collision check.
我们增加了对批量射线广播的支持。 因此,我们首先找到所有接触粒子系统中所有粒子的PhysX形状,并针对每个粒子对这些形状执行非常快速的缓存本地化的早期筛选。 只有这样,我们才能进行任何对撞机射线广播。 这极大地提高了性能,因为在任何时候实际上只有很少的粒子需要完整的碰撞检查。
One side-effect of this approach is that creating small colliders that are axis aligned will give you a performance boost. For example if you have a corridor. It’s a good idea to separate the walls and the floor into separate colliders.This way when particles are simply flying through the corridor without colliding, Shuriken can quickly skip expensive computations. In almost all particle effects, most particles are not colliding during any single frame. Thus it always makes sense to create colliders with slim bounding volumes.
这种方法的一个副作用是,创建与轴对齐的小型对撞机可以提高性能。 例如,如果您有走廊。 将墙壁和地板分成单独的碰撞体是个好主意,这样,当粒子简单地在走廊中飞行而没有碰撞时,Shuriken可以Swift跳过昂贵的计算。 在几乎所有粒子效果中,大多数粒子在任何单个帧中都不会发生碰撞。 因此,创建边界体积较小的对撞机总是有意义的。
Approximate mode
近似模式
Yet when you create scenes with massive amounts of particles, for example performing 50,000 raycasts every frame, it can quickly become a bottleneck. Thus we added support for an approximate collision detection mode. It allows you to define an upper limit on the amount of raycasts performed each frame. This gives you complete control over the maximum time spent on raycast collision. Naturally this comes at the cost of particle collision accuracy. In some cases, particles might fall through surfaces or collide with non-existing geometry. In many cases, some particles falling through is invisible to the user since they will just disappear. Especially with a high particle density this becomes unnoticeable. A framerate drop due to lots of particle collision detection on the other hand can be very noticeable.
但是,当您创建包含大量粒子的场景时(例如,每帧执行50,000次射线广播),它很快就会成为瓶颈。 因此,我们增加了对近似碰撞检测模式的支持。 它允许您定义每个帧执行的射线广播数量的上限。 这使您可以完全控制在光线投射碰撞上花费的最大时间。 自然地,这是以粒子碰撞精度为代价的。 在某些情况下,粒子可能会掉落到表面或与不存在的几何体碰撞。 在许多情况下,一些掉进去的颗粒对于用户是不可见的,因为它们会消失。 特别是在高颗粒密度的情况下,这变得不明显。 另一方面,由于大量粒子碰撞检测而导致的帧速率下降可能非常明显。
In order to reduce quality degradation we store previous collisions in a cache, essentially in a voxel grid defined by space and velocity. Each grid has a single plane in the cache which is then reused for all particles that travel through this voxel. If the number of particles exceeds the budget, some particles will perform only cheap voxel lookups and reuse information in the cache. An almost free raycast.
为了减少质量下降,我们将先前的碰撞存储在缓存中,实质上是存储在由空间和速度定义的体素网格中。 每个网格在缓存中都有一个平面,然后可用于通过该体素的所有粒子。 如果粒子数量超过预算,则某些粒子将仅执行廉价的体素查找并重用缓存中的信息。 几乎免费的射线广播。
In the particle system you can choose High Quality (always performs full raycasts), Medium Quality (gets a portion of the raycast budget every frame) and Low quality (gets a portion of the budget every couple of frames). Generally speaking any effects that are chaotic in nature work extremely well with low and medium quality mode. Such as smoke, sparks, dust, and precipitation. Low and medium quality only casts against static geometry. And the cache will usually converge fairly quickly, at which point very few raycasts need to be performed while giving very good looking results.
在粒子系统中,可以选择“高质量”(始终执行完整的射线广播),“中等质量”(每帧获取一部分射线广播预算)和“低质量”(每两帧获取一部分预算)。 一般而言,在中低质量模式下,本质上任何混乱的效果都非常有效。 如烟,火花,灰尘和沉淀物。 中低质量仅针对静态几何体。 而且缓存通常会相当快地收敛,这时只需执行很少的光线投射,即可获得非常漂亮的效果。
翻译自: https://blogs.unity3d.com/2012/11/18/shuriken-world-particle-collision/
手里输入前空格