Unity 4.3中的遮挡剔除:最佳实践

The following blog post was written by Jasin Bushnaief of Umbra Software to explain the updates to occlusion culling in Unity Pro 4.3.

以下博客文章由Umbra Software的Jasin Bushnaief撰写,解释了Unity Pro 4.3中遮挡剔除的更新。

This is the second post in a three-post series. In the previous post, I discussed how the new occlusion culling system works in Unity 4.3. I went over the basic usage and parameters that you need to know in order to get the best out of occlusion culling. In case you missed it, check it out here.

这是三篇文章系列中的第二篇。 在上一篇文章中,我讨论了新的遮挡剔除系统如何在Unity 4.3中工作。 我仔细阅读了您需要了解的基本用法和参数,以便从遮挡剔除中获得最大的收益。 如果您错过了它,请在此处查看

This post gives you a list of general recommendations and tips that should help you get the best results out of occlusion culling.

这篇文章为您提供了一般建议和技巧列表,这些建议和技巧应有助于您从遮挡剔除中获得最佳效果。

良好的咬合质量 (Good quality occlusion)

It may seem obvious, but of course the first thing to make sure is that your scene actually contains meaningful occlusion. Moreover, the occlusion should preferably consist of good, large occluders if possible, as opposed to fine details that only accumulate as occluders when looking at from a certain angle. Umbra will generally not be able to perform occluder fusion, so even if your lush forest with lots of foliage will occlude something behind it, it will do so only once the individual occluders are “accumulated”. So in this sense, the trees and forests in general will be pretty bad occluders from Umbra’s point of view. On the other hand, a mountain is a good occluder and Umbra will certainly be able to capture it into the occlusion data as expected.

看起来似乎很明显,但是首先要确定的是您的场景实际上包含有意义的遮挡。 此外,如果可能的话,闭塞最好应由良好的大型闭塞器组成,而不是细微的细节,当从某个角度看时,这些细微的闭塞器只会作为闭塞器而积累。 本影一般无法进行封堵融合,所以即使你的茂密的森林,有很多树叶的遮挡将它背后的东西,它会做这样一次单独的封堵器是“积累”。 因此,从这个意义上说,从Umbra的角度来看,树木和森林通常是非常糟糕的遮盖物。 另一方面,山峰是一个很好的遮挡物,Umbra当然可以按预期将其捕获到遮挡数据中。

01_good_vs_bad_occluder

对象标志 (Object flags)

There are two main types of objects Umbra cares about: occluders and occludees. The former are just geometry and Umbra treats them basically as a single, solid model. The latter are the ones whose visibility Umbra actually tests using the occlusion data. Occluders consist of pretty much all geometry that have the “Occluder static” flag set, and unsurprisingly, occludees that have the “Occludee static” flag, respectively.

Umbra关心的对象主要有两种:遮挡物和遮挡物。 前者只是几何,Umbra基本上将它们视为单个实体模型。 后者是Umbra实际使用遮挡数据测试可见度的对象。 遮挡件由几乎所有设置了“遮挡件静态”标志的几何组成,并且毫不奇怪,分别具有“遮挡件静态”标志的遮挡件。

02_object flags

But also, if your object contains very small holes (consider e.g. a cheese grater or a bushy plant) that you wish to see through, but reducing the value of smallest hole globally doesn’t make sense (see the previous post as to why), simply removing the occluder flag from the renderer is the correct thing to do.

而且,如果您的对象上包含您希望透视的很小的Kong(例如,奶酪刨丝器或浓密的植物),但是在全局范围内减小最小Kong的值是没有意义的(有关原因,请参见一篇文章 ) ,只需从渲染器中删除occluder标志是正确的做法。

Furthermore, because occluders are considered solid, correct culling can typically be guaranteed if the camera doesn’t intersect an occluder. This means that if e.g. the collision system cannot prevent the camera from flying inside an occluder, you should probably remove the occluder flag in order to get meaningful results.

此外,由于遮挡物被认为是坚固的,因此如果相机不与遮挡物相交,通常可以保证正确的剔除。 这意味着,例如,如果碰撞系统无法阻止相机在遮挡件内飞行,则可能应移除遮挡件标志才能获得有意义的结果。

对象粒度 (Object granularity)

Given the fact that Umbra does object-level occlusion culling, it doesn’t make a whole lot of sense to have objects of several kilometers in size. Such massive objects are very hard to cull, as some part of the object is almost always visible, especially combined with Umbra’s conservative culling. So, splitting up e.g. the terrain into multiple patches is typically a good idea, unless you want the entire terrain to always be visible.

鉴于Umbra会进行对象级遮挡剔除,因此拥有几公里大小的对象没有任何意义。 如此庞大的物体很难被剔除,因为物体的某些部分几乎总是可见的,特别是结合了Umbra的保守剔除技术。 因此,将地形分成多个小块通常是个好主意,除非您希望整个地形始终可见。

In terms of occlusion culling, typically the best object subdivision is a natural one, meaning that naturally distinct objects should probably kept separate in culling as well. So chunking objects too aggressively typically doesn’t help. One should group only objects that are similar in terms of visibility. On the other hand, too fine-grained subdivision may introduce some unnecessary per-object overhead. In reality, this becomes a problem only once there are tens of thousands of occludees in the scene.

在遮挡剔除方面,通常最好的对象细分是自然的细分,这意味着自然不同的对象也可能在剔除中也应保持分开。 因此,过于积极地对对象进行分块通常无济于事。 应该只将可见性相似的对象分组。 另一方面,细粒度的细分可能会引入一些不必要的按对象开销。 实际上,仅当场景中有成千上万的遮挡物时,这才成为问题。

Maybe it should be emphasized that only the object subdivision of occludees matters. Occluders are considered to be a single big bowl of polygon soup anyway.

也许应该强调的是, 只有对象细分才是最重要的 。 无论如何,封堵器被认为是一大碗多边形汤。

水密型号 (Watertight models)

In the previous post, I briefly described how Umbra first voxelizes the occluding geometry, groups these voxels into cells and then connects the cells with portals. In the process, Umbra is always conservative, meaning that in various cases Umbra considers the occluders slightly smaller than what they are in reality, or conversely, the empty areas slightly larger.

一篇文章中 ,我简要介绍了Umbra如何首先对遮挡几何体进行体素化,将这些体素分组为单元,然后将单元与门户连接。 在此过程中,Umbra始终是保守的,这意味着在各种情况下,Umbra会将封堵器视为比实际封堵器小,或者相反,将空白区域稍大。

This means that if there happens to be an unintentional hole in your occluding geometry, one which rather than getting patched up is retained by voxelization, there’s a good chance it’ll become somewhat magnified in the final output data. This may lead to surprising “leaks” in occlusion. The camera may be looking at a seemingly solid wall, but things behind the wall don’t get occluded because there’s some unnoticeably small crack somewhere.

这意味着,如果在您的遮挡几何中碰巧出现了一个无意的Kong,而该Kong没有被修补而通过体素化得以保留,则很有可能在最终输出数据中将其放大。 这可能会导致意外的咬合“泄漏”。 相机可能正在看似看似坚固的墙壁,但墙壁后面的东西并没有被遮挡,因为某处有些明显的小裂缝。

So, while voxelization does patch a lot of unintentional cracks and gaps in the occluding geometry, it’s still highly important to try to model the geometry as water-tightly as possible. In the next post, I’ll describe the Visibility Lines visualization which may help you debug these kinds of issues.

因此,尽管体素化确实会修补闭塞几何图形中的许多意外裂纹和间隙,但尝试尽可能不漏水地对几何图形进行建模仍然非常重要。 在下一篇文章中,我将介绍可视化线可视化,它可以帮助您调试此类问题。

寻找正确的参数值 (Finding the right parameter values)

Admittedly the hardest part of using Umbra is finding the right parameter values. The default values in Unity do a good job as a starting point, assuming that one Unity unit maps into one meter in your game, and the game’s scale is “human-like” (e.g. not modeled on a molecular level, nor is your typical object a planet or a gigantic killer-mech-robot).

诚然,使用Umbra的最困难的部分是找到正确的参数值。 Unity的默认值可以很好地作为起点,假设一个Unity单位在您的游戏中映射成一米,并且游戏的比例是“类人”的(例如,不是在分子水平上建模,也不是典型的反对行星或巨大的杀手级机械人)。

03_occlusion_ui
smallest hole, for instance, the larger value you can use, the swifter is the bake process. Thus, you should tune it down only if/when you start experiencing culling artifacts, i.e. false negatives. Similarly, starting with a relatively large value for 最小的Kong的情况下,可以使用较大的值,较快的是烘烤过程。 因此,仅当/当您开始遇到剔除伪影(即假阴性)时,才应调低它。 类似地,从 smallest occluder typically makes sense. 最小封堵器的较大值开始通常是有意义的。

Then you can start adjusting it downward and see how Umbra culls better. Stop when culling starts taking up too much time and/or the occlusion data becomes too large.

然后,您可以开始向下调整它,看看Umbra如何更好地剔除它。 当淘汰开始占用过多时间和/或遮挡数据变得太大时,请停止。

As for backface threshold, start with 100. If your occlusion data is too large, or if you happen to get weird results when the camera is very, very  close or possibly even intersects an occluder, try using 90 or even a smaller value. More on this in the next post.

至于背面阈值 ,请从100开始。如果遮挡数据太大,或者在相机非常非常接近或什至与遮光器相交时碰巧得到奇怪的结果,请尝试使用90或更小的值。 在下一篇文章中对此有更多的了解。

未完待续… (To be continued…)

In the next and final post, go over some common issues people tend to run into when using Umbra. In the meantime, go check out www.umbrasoftware.com for more information!

在下一篇也是最后一篇文章中 ,介绍一些人们在使用Umbra时往往会遇到的常见问题。 同时,请访问www.umbrasoftware.com了解更多信息!

04_Umbra3_Logo_V1_bgW_RGB

翻译自: https://blogs.unity3d.com/2013/12/26/occlusion-culling-in-unity-4-3-best-practices/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值