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

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

Occlusion Culling is a feature that disables rendering of objects when they are not currently seen by the camera because they are obscured 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图形计算中并不是自动进行的。因为在绝大多数情况下离 camera 最远的物体首先被渲染,靠近摄像机的物体后渲染并覆盖先前渲染的物体(这被称为重复渲染"overdraw"). 遮挡剔除不同于视锥体剔除. 视锥体剔除只是不渲染摄像机视角范围外的物体而对于被其他物体遮挡但依然在视角范围内的物体,则不会被剔除. 注意当你使用遮挡剔除时你依然受益于视锥体剔除(Frustum Culling).


The scene rendered without Occlusion Culling 场景渲染无遮挡剔除


The same scene rendered with Occlusion Culling 场景渲染带遮挡剔除

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.

遮挡剔除的运行将通过在场景中使用一个虚拟的摄像机来创建一个物体潜在可视性状态(set)的层级。 这些数据可以实时让每个摄像机来确定什么能看见什么看不见。通过这些数据,Unity 将确定只把可以看见的物体送去渲染。这将降低 绘制调用(draw calls) 的数量并增加 游戏的运行效率。

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.

遮挡剔除的数据由单元格(cells)组成, 每个单元格是在整个场景的包围体积的一部分,单元格来自一个二叉树( binary tree),遮挡剔除使用两棵树, 一个给 View Cells (静态物体) ,另一个给 Target Cells (移动物体)。 View Cells 映射到一个定义静态可视物体的索引列表 (精确剔除后的静态物体)。

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. The collection of cells and the visibility information that determines which cells are visible from any other cell is known as a PVS (Potentially Visible Set).

非常重要的一点是在创建你的物体时要随时注意,因为你需要在物体的大小和单元格的大小间取得一个好的平衡. 理想情况下,不应该有相比于物体,太小的单元格,但同样,物体不应该覆盖许多单元格.有时你可以通过将大的物体拆成几个部分来改进遮挡剔除效果. 然而,你仍然能够将小的物体合并在一起,来降低绘制调用次数(draw calls), 在它们都属于同一个小单元格的时候, 遮挡剔除将不起作用。单元格的集合和可视信息确定哪些单元格是可见的,被认为是 PVS (潜在可视集合Potentially Visible Set)。

Setting up Occlusion Culling 设置遮挡剔除

In order to use Occlusion Culling, there is some manual setup involved. First, your level geometry must be broken into

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值