Occlusion Culling 遮挡剔除

本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2018.2版本
参考链接:https://docs.unity3d.com/Manual/OcclusionCulling.html

Occlusion Culling is a feature that disables rendering of objects when they are not currently seen by the camera
because they are obscured (occluded) by other objects. This does not happen automatically in 3D computer graphics since most of the time objects farthest away from the camera are drawn first and closer objects are drawn over the top of them (this is called “overdraw”). Occlusion Culling is different from Frustum Culling. Frustum Culling only disables the renderers for objects that are outside the camera’s viewing area but does not disable anything hidden from view by overdraw. Note that when you use Occlusion Culling you will still benefit from Frustum Culling.
遮挡剔除是使对象在被其他物体遮挡,没有被相机看到时关闭渲染的功能。这在3D计算机图形学中不会自动发生,因为大多数情况下,离相机最远的物体会先被绘制出来,而离相机较近的物体会被绘制到它们的上方(这被称为“过度绘制(overdraw)”)。遮挡剔除不同于视锥体剔除。视锥体只会禁用在相机观察区域之外的对象渲染,但不会禁用通过overdraw隐藏的任何对象。注意,当你使用遮挡剔除时,你仍然可以从视锥体剔除中获益。
[外链图片转存失败(img-QMAjvR8O-1567752732651)(https://docs.unity3d.com/uploads/Main/OcclusionNoCulling.jpg)]
A maze-like indoor level. This normal scene view shows all visible Game Objects.
一个迷宫般的室内水平。这个正常的场景视图显示所有可见的游戏对象。

[外链图片转存失败(img-xHkT55B1-1567752732652)(https://docs.unity3d.com/uploads/Main/OcclusionFrustumCulling.jpg)]
Regular frustum culling only renders objects within the camera’s view. This is automatic and always happens.
常规视锥体剔除只渲染相机视野内的对象。这是自动的,总是发生的。


Occlusion culling removes additional objects from within the camera rendering work if they are entirely obscured by nearer objects.
如果被近距离物体完全遮挡,遮挡剔除会从相机渲染工作中移除额外的物体。

The occlusion culling process will go through the scene using a virtual camera to build a hierarchy of potentially visible sets of objects. This data is used at runtime by each camera to identify what is visible and what is not. Equipped with this information, Unity will ensure only visible objects get sent to be rendered. This reduces the number of draw calls and increases the performance of the game.
遮挡剔除过程将使用虚拟摄像机遍历场景,以构建潜在可见对象集的层次结构。运行时每个相机可使用这些数据来识别哪些是可见的,哪些是不可见的。有了这些信息,Unity将确保只有可见的对象被发送到渲染。这减少了DC的次数,并提高了游戏的性能。

The data for occlusion culling is composed of cells. Each cell is a subdivision of the entire bounding volume of the scene. More specifically the cells form a binary tree. Occlusion Culling uses two trees, one for View Cells (Static Objects) and the other for Target Cells (Moving Objects). View Cells map to a list of indices that define the visible static objects which gives more accurate culling results for static objects.
遮挡剔除的数据由单元格cell组成。每个单元格是整个包围体的细分的场景。更具体地说,这些单元格形成了一个二叉树。遮挡剔除使用两个树,一个用于视图单元格(静态对象),另一个用于目标单元格(移动对象)。视图单元格映射到定义可见静态对象的索引列表,这些索引为静态对象提供更准确的剔除结果。

It is important to keep this in mind when creating your objects because you need a good balance between the size of your objects and the size of the cells. Ideally, you shouldn’t have cells that are too small in comparison with your objects but equally you shouldn’t have objects that cover many cells. You can sometimes improve the culling by breaking large objects into smaller pieces. However, you can still merge small objects together to reduce draw calls and, as long as they all belong to the same cell, occlusion culling will not be affected.
在创建对象时记住这一点很重要,因为您需要在对象的大小和单元格的大小之间取得良好的平衡。理想情况下,不应该拥有与对象相比太小的单元格,但同样也不应该拥有覆盖许多单元格的对象。有时,您可以通过将大型对象分解为较小的部分来改进剔除。但是,您仍然可以将小对象合并在一起,以减少draw调用,并且只要它们都属于同一个单元,就不会影响遮挡剔除效果。

You can use the ‘overdraw’ scene rendering mode to see the amount of overdraw that is occuring, and the stats information pane in the game view to see the amount of triangles, verts, and batches that are being rendered. Below is a comparison of these before and after applying occlusion culling.
您可以使用“overdraw”场景呈现模式查看正在发生的overdraw数量,并在game view中的stats information窗格查看正在渲染的三角形、顶点和批处理数量。下面是应用遮挡剔除前后的比较。
[外链图片转存失败(img-NTCP2r9j-1567752732654)(https://docs.unity3d.com/uploads/Main/OcclusionCullingOverdrawNoCulling.jpg)]
Notice in the Overdraw scene view, a high density of overdraw as many rooms beyond the visible walls are rendered. These aren’t visible in the game view, but nonetheless time is being taken to render them.
请注意,在Overdraw场景视图中,渲染了一个高密度的Overdraw,在可见墙壁之外呈现了许多房间。这些在游戏视图中是不可见的,但是仍然需要时间渲染它们。

[外链图片转存失败(img-vc8xJ3J8-1567752732655)(https://docs.unity3d.com/uploads/Main/OcclusionCullingOverdrawReduced.jpg)]
With occlusion culling applied, the distant rooms are not rendered, the overdraw is much less dense, and the number of triangles and batches being rendered has dropped dramatically, without any change to how the game view looks.
随着遮挡剔除的应用,遥远的房间不会被渲染,渲染的密度也会大大降低,渲染的三角形和批次的数量也会大幅下降,而游戏视图的外观也不会发生任何变化。

Setting up Occlusion Culling 建立遮挡剔除
In order to use Occlusion Culling, there is some manual setup involved. First, your level geometry must be broken into sensibly sized pieces. It is also helpful to lay out your levels into small, well defined areas that are occluded from each other by large objects such as walls, buildings, etc. The idea here is that each individual mesh will be turned on or off based on the occlusion data. So if you have one object that contains all the furniture in your room then either all or none of the entire set of furniture will be culled. This doesn’t make nearly as much sense as making each piece of furniture its own mesh, so each can individually be culled based on the camera’s view point.
为了使用遮挡剔除,需要一些手动设置。首先,场景中几何体必须被分割成合理大小的碎片。这也有助于将你的场景布局成小的、定义良好的区域,这些区域被墙壁、建筑等大型物体相互遮挡。这里的想法是,每个单独的网格将基于遮挡数据被打开或关闭。所以如果你有一个对象包含了你房间里所有的家具,那么要么全部渲染,要么全部家具会被剔除。这并不像让每件家具都有自己的网格那么有意义,所以每件家具都可以根据相机的视角单独剔除。

You need to tag all scene objects that you want to be part of the occlusion to Occluder Static in the Inspector. The fastest way to do this is to multi-select the objects you want to be included in occlusion calculations, and mark them as Occluder Static and Occludee Static.
你需要标记所有你想让其成为遮挡剔除一部分的场景对象:在检查器中勾选Occluder Static。要做到这一点,最快的方法是多选希望包含在遮挡计算中的对象,并将它们标记为遮挡物静态和被遮挡静态。
[外链图片转存失败(img-SfX2rmgC-1567752732655)(https://docs.unity3d.com/uploads/Main/OcclusionStaticDropdown.png)]
Marking an object for Occlusion
标记用于遮挡剔除的对象

When should you use Occludee Static? Completely transparent or translucent objects that do not occlude, as well as small objects that are unlikely to occlude other things, should be marked as Occludees, but not Occluders. This means they will be considered in occlusion by other objects, but will not be considered as occluders themselves, which will help reduce computation.
什么时候应该使用被遮挡静态(Occludee Static)?完全透明或半透明物体,尤其是不太可能遮挡其他物体的小物体,都应该被标记为被遮挡物,而不是遮挡物。这意味着它们将被其他对象作为可被遮挡的物体,但它们本身不会遮挡其他物体,这将有助于减少计算量。

When using LOD groups, only the base level object (LOD0) may be used as an Occluder.
在使用LOD组时,只能使用初级对象(LOD0)作为遮挡物。

Occlusion Culling Window 遮挡剔除窗口

For most operations dealing with Occlusion Culling, you should use the Occlusion Culling Window (Window > Rendering > Occlusion Culling)
大部分遮挡剔除处理操作,是在其窗口上进行的(Window > Rendering > Occlusion Culling)

In the Occlusion Culling Window, you can work with occluder meshes, and Occlusion Areas.
可以操作 meshes,和 Occlusion Areas。

If you are in the Object tab of the Occlusion Culling Window and have a Mesh Renderer selected in the scene, you can modify the relevant Static flags:
如果在Object页签上,选择了有Mesh Renderer组件的对象,可以修改相关的 Static 标记。

If you are in the Object tab of the Occlusion Culling Window and have an Occlusion Area selected, you can work with relevant OcclusionArea properties (for more details go to the Occlusion Area section)
如果在Object页签上,选择了有Occlusion Area组件的对象,可以修改相关的 OcclusionArea 属性。

NOTE: By default if you don’t create any occlusion areas, occlusion culling will be applied to the whole scene.
注意:默认情况下,如果你不创建任何遮挡区域,遮挡剔除将应用于整个场景。

NOTE: Whenever your camera is outside occlusion areas, occlusion culling will not be applied. It is important to set up your Occlusion Areas to cover the places where the camera can potentially be, but making the areas too large incurs a cost during baking.
注意:当您的相机在遮挡区域之外时,将不应用遮挡剔除。设置遮挡区域以覆盖摄像机可能出现的位置是很重要的,但是过大的遮挡区域会在烘焙过程中产生成本。

Occlusion Culling - Bake 遮挡剔除-烘焙

The occlusion culling bake window has a “Set Default Parameters” button, which allows you to reset the bake values to Unity’s default values. These are good for many typical scenes, however you’ll often be able to get better results by adjusting the values to suit the particular contents of your scene.
遮挡剔除烘焙窗口有一个“设置默认参数”按钮,它允许你重置烘焙值到Unity的默认值。这些对于许多典型场景都很好,但是您通常可以通过调整值来适应场景的特定内容来获得更好的结果。

Properties

Property Function
Smallest Occluder The size of the smallest object that will be used to hide other objects when doing occlusion culling. Any objects smaller than this size will never cause objects occluded by them to be culled. For example, with a value of 5, all objects that are higher or wider than 5 meters will cause hidden objects behind them to be culled (not rendered, saving render time). Picking a good value for this property is a balance between occlusion accuracy and storage size for the occlusion data.
最小遮挡物 在进行遮挡剔除时可用来隐藏其他对象的最小对象大小。任何小于此大小的对象都不会遮挡掉其他对象。例如,当值为5时,所有大于或大于5米的对象都会导致它们后面的隐藏对象被剔除(不渲染,节省渲染时间)。为这个属性选择一个好的值是在遮挡精度和遮挡数据存储大小之间的平衡。
Smallest Hole This value represents the smallest gap between geometry through which the camera is supposed to see. The value represents the diameter of an object that could fit through the hole. If your scene has very small cracks through which the camera should be able to see, the Smallest Hole value must be smaller than the narrowest dimension of the gap.
最小的洞 该值表示摄像机应该通过几何图形看到的最小间隙。该值表示可以通过该孔看到物体的孔直径大小。如果你的场景有非常小的裂缝,摄像机应该能够看到,最小的洞值必须小于最窄的尺寸的差距。
Backface Threshold Unity’s occlusion uses a data size optimization which reduces unnecessary details by testing backfaces. The default value of 100 is robust and never removes backfaces from the dataset. A value of 5 would aggressively reduce the data based on locations with visible backfaces. The idea is that typically, valid camera positions would not normally see many backfaces - for example, the view of the underside of a terrain, or the view from within a solid object that you should not be able to reach. With a threshold lower than 100, Unity will remove these areas from the dataset entirely, thereby reducing the data size for the occlusion.
背面阈值 Unity的遮挡使用了一个数据大小的优化,通过测试背面来减少不必要的细节。默认值100是健壮的,从不删除背面的数据集。如果值为5,则会根据具有可见性背面的位置来大幅减少数据。通常情况下,有效的相机位置通常不会看到很多背面——例如,地形地面下的视图,或者一个你不应该到达的固体物体内部的视图。如果阈值低于100,Unity将从数据集中完全移除这些区域,从而减少遮挡的数据大小。

At the bottom of the bake tab is are the Clear and Bake buttons. Click on the Bake Button to start generating the Occlusion Culling data. Once the data is generated, you can use the Visualization tab to preview and test the occlusion culling. If you are not satisfied with the results, click on the Clear button to remove previously calculated data, adjust the settings, and bake again.
在底部的烘焙页签是清除和烘焙按钮。单击Bake按钮开始生成遮挡剔除数据。一旦生成数据,就可以使用Visualization选项卡预览和测试遮挡剔除。如果您对结果不满意,请单击Clear按钮删除先前计算的数据,调整设置,然后再次烘焙。

Occlusion Culling - Visualization 遮挡剔除-可视化

All the objects in the scene affect the size of the bounding volume so try to keep them all within the visible bounds of the scene.
场景中的所有对象都会影响到包围盒的大小,所以尽量将它们保持在场景的可见范围内。

When you’re ready to generate the occlusion data, click the Bake button. Remember to choose the Memory Limit in the Bake tab. Lower values make the generation quicker and less precise, higher values are to be used for production quality closer to release.
当您准备好生成遮挡数据时,单击Bake按钮。记住在Bake标签中选择内存限制。数值越低,生成速度越快,精度越低。数值越高,产品质量越接近发布版本。

Bear in mind that the time taken to build the occlusion data will depend on the cell levels, the data size and the quality you have chosen.
请记住,构建遮挡数据所花费的时间将取决于单元格级别、数据大小和您所选择的质量。

After the processing is done, you should see some colorful cubes in the View Area. The colored areas are regions that share the same occlusion data.
处理完成后,您应该在视图区域中看到一些彩色的立方体。彩色区域是共享相同遮挡数据的区域。

Click on Clear if you want to remove all the pre-calculated data for Occlusion Culling.
如果您想删除所有为遮挡剔除而预先计算的数据,请单击Clear。

Occlusion Area 遮挡区域
To apply occlusion culling to moving objects you have to create an Occlusion Area and then modify its size to fit the space where the moving objects will be located (of course the moving objects cannot be marked as static). You can create Occlusion Areas by adding the Occlusion Area component to an empty game object (Component -> Rendering -> Occlusion Area in the menus).
要对移动对象应用遮挡剔除,您必须创建一个遮挡区域,然后修改其大小,以适合移动对象所在的空间(当然,移动对象不能标记为静态对象)。您可以通过将遮挡区域组件添加到一个空游戏对象(组件->呈现-菜单中的>遮挡区域)来创建遮挡区域。

After creating the Occlusion Area, check the Is View Volume checkbox to occlude moving objects.
创建遮挡区域后,选中Is View Volume复选框来遮挡剔除移动的对象。

Property Function
Size Defines the size of the Occlusion Area.
大小 定义大小
Center Sets the center of the Occlusion Area. By default this is 0,0,0 and is located in the center of the box.
中心 盒子中心位置
Is View Volume Defines where the camera can be. Check this in order to occlude static objects that are inside this Occlusion Area.
是否在可视体 定义相机可以在哪里。为了在遮挡区域中遮挡静态对象检测

[外链图片转存失败(img-sZZH9ZXD-1567752732659)(https://docs.unity3d.com/uploads/Main/OcclusionCullingOcclusionArea.jpg)]

After you have added the Occlusion Area, you need to see how it divides the box into cells. To see how the occlusion area will be calculated, select Edit and toggle the View button in the Occlusion Culling Preview Panel.
在添加了遮挡区域之后,您需要了解它是如何将盒子划分为单元格的。要查看如何计算遮挡区域,请选择Edit并切换遮挡剔除预览面板中的视图按钮。
[外链图片转存失败(img-vtGQIVUD-1567752732659)(https://docs.unity3d.com/uploads/Main/OcclusionCullingViewVolumes.jpg)]
Testing the generated occlusion 测试生成的遮挡
After your occlusion is set up, you can test it by enabling the Occlusion Culling (in the Occlusion Culling Preview Panel in Visualize mode) and moving the Main Camera around in the scene view.
在你的遮挡设置完成后,你可以通过启用遮挡剔除(在可视化模式下的遮挡预览面板中)和在场景视图中移动主摄像机来测试它。

As you move the Main Camera around (whether or not you are in Play mode), you’ll see various objects disable themselves. The thing you are looking for here is any error in the occlusion data. You’ll recognize an error if you see objects suddenly popping into view as you move around. If this happens, your options for fixing the error are either to change the resolution (if you are playing with target volumes) or to move objects around to cover up the error. To debug problems with occlusion, you can move the Main Camera to the problematic position for spot-checking.
当你移动主摄像头时(不管你是否处于游戏模式),你会看到各种各样的物体都在禁用自己。您在这里寻找的是遮挡数据中的任何错误。如果您在移动时看到对象突然出现在视图中,您将识别错误。如果发生这种情况,修复错误的选项要么是更改分辨率(如果正在处理目标体),要么是移动对象以掩盖错误。要调试遮挡问题,可以将主摄像机移动到有问题的位置进行现场检查。

When the processing is done, you should see some colorful cubes in the View Area. The blue cubes represent the cell divisions for Target Volumes. The white cubes represent cell divisions for View Volumes. If the parameters were set correctly you should see some objects not being rendered. This will be because they are either outside of the view frustum of the camera or else occluded from view by other objects.
处理完成后,您应该在视图区域中看到一些彩色的立方体。蓝色方块表示目标体的单元格划分。白色的方块表示观察体的单元格划分。如果参数设置正确,您应该看到一些对象没有被渲染。这是因为它们要么在相机的视锥体外,要么被其他对象遮挡剔除在外。

After occlusion is completed, if you don’t see anything being occluded in your scene then try breaking your objects into smaller pieces so they can be completely contained inside the cells.
在遮挡完成后,如果你没有看到任何东西被遮挡剔除在你的场景中,那么试着把你的物体分成更小的部分,这样它们就可以完全被包含在单元格中。

Occlusion Culling 遮挡剔除 相机系列5相关推荐

  1. Unity Occlusion Culling 遮挡剔除研究

    本文章由cartzhang编写,转载请注明出处. 所有权利保留.  文章链接:http://blog.csdn.net/cartzhang/article/details/52684127  作者:c ...

  2. Occlusion(遮挡剔除)

    Occlusion 1.视锥体剔除(Frustum Culling) 根据摄像机的视见体的范围对场景模型进行剔除操作,在视见体以外的物体不被渲染,但是在视见体中的物体会以离摄像机最远的物体开始渲染,逐 ...

  3. Culling 渲染剔除

    文章目录 剔除 视锥体frustum裁剪 遮挡剔除 摄像机距离剔除 遮挡剔除 Occlusion Culling 建立遮挡剔除 遮挡剔除窗口 遮挡剔除烘焙 - bake Occlusion Area ...

  4. Unity 3D 遮挡剔除(仅专业版) Occlusion Culling (Pro only)

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! Occl ...

  5. Occlusion culling

    遮挡剔除(仅专业版) Occlusion Culling (Pro only) Date:2013-04-25 11:50 Occlusion Culling is a feature that di ...

  6. [HSR算法-Occlusion Culling]

    作者:Siney 现在的HSR算法基本上可以分为四种:backface culling.frustum culling.portal culling.occlusion culling.它们的作用分别 ...

  7. Unity_7 如何使用遮挡剔除Occlusion Culling

    什么是Occlusion Culling(遮挡剔除) 当一个物体被其他物体遮挡住而不在摄像机的可视范围内时不对其进行渲染. 在绝大多数情况下离 camera 最远的物体首先被渲染,靠近摄像机的物体后渲 ...

  8. Occlusion Culling(遮挡剔除)

    Occlusion Culling(遮挡剔除) 本文转载自:https://www.jianshu.com/p/d15eeae757a3 什么是Occlusion Culling(遮挡剔除)? 遮挡剔 ...

  9. (转) Occlusion Culling(遮挡剔除)

    转自 作者:JervieQin 链接:https://www.jianshu.com/p/d15eeae757a3 什么是Occlusion Culling(遮挡剔除)? 遮挡剔除, 当一个物体被其他 ...

最新文章

  1. layDate的使用
  2. torch.Tensor和torch.tensor的区别
  3. LeetCode Remove Duplicates from Sorted List II
  4. RFI远程文件包含的漏洞
  5. 计算机组成原理与接口技术 pdf,计算机组成原理与接口技术课件 7-Datapath(2).pdf...
  6. python函数返回none_Python 函数默认返回None的原因
  7. python库快速安装_python的pip快速安装代码
  8. Windows11怎么设置时间?Win11时间设置教程
  9. 特斯拉股价,真的“血崩”!
  10. c++11 数值类型和字符串的相互转换
  11. 在Linux中如何使用gdb调试C程序
  12. java中经典的题目_java经典题目(一)
  13. linux嵌入式ARM系统开发实战教程从入门到精通
  14. 202019 大战360弹窗广告
  15. 用于SAO Utils桌面网页挂件的Live2D看板娘
  16. win8 桌面显示计算机图标不见了怎么办,win8开始屏幕桌面图标不见了怎么办
  17. gmx genion命令
  18. 《秘密》· 东野圭吾
  19. [可联网]ps4共享屏幕到笔记本
  20. 虚拟机安装pycharm

热门文章

  1. 孩子为什么不能玩抖音精彩回答,共勉
  2. CSS复合选择器---后代选择器、子选择器、并集选择器、伪类选择器
  3. 大学计算机实验五实验六实验报告表,北京理工大学计算机实验六
  4. 生死看淡,不服就GAN(七)----用更稳定的生成模型WGAN生成cifar
  5. 人工智能基础——知识的表示方法,语义网络表示方法
  6. #腾讯云·未来开发者云梯计划#第三期上线啦!全国5000个免费云认证培训考试名额开放报名中!
  7. 数据库系统概念 - 数据模型,关系模型,关系,候选码,主码,外码
  8. 中山大学农学院袁超磊课题组博士后招聘
  9. jenkins 出现“Error 403 No valid crumb was included in the request ”的解决方案
  10. linux 运行QQ /Tim(超简单)