This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

遮挡剔除

Object culling allows you not to render objects which are not presented in the viewing frustum. The particular cases of occlusion culling are the following:对象剔除允许您不渲染在视锥中未显示的对象。遮挡剔除的特殊情况如下:

注意
As the object's bounding box is used for occlusion culling (it is checked if the bounding box is visible or not), it is recommended to export objects from 3D computer graphics software in local coordinates to make bounds of the mesh closer to geometry.由于对象的边界框用于遮挡剔除(检查边界框是否可见),建议从3D计算机图形软件中以本地坐标导出对象,以使网格的边界更接近几何

Occluders
封堵器#

Occluders allow culling geometry that isn't visible behind them. There are 2 types of occluders:遮挡物允许剔除隐藏在其后面的几何图形。封堵器有2种类型:

The type of occluder to be used is defined by geometry to be culled.要使用的封堵器类型由要剔除的几何定义。

Occluders can be very effective in case of complex environments where there are many objects that occlude each other and are costly to render (they have a lot of polygons and/or heavy shaders).在复杂的环境中,当许多物体相互遮挡并且渲染成本很高(它们有很多多边形和/或较重的着色器)时,遮挡器可能会非常有效。

注意
Using occluders to cull large objects with a few surfaces may cause additional performance loss. Moreover, occluders aren't effective in scenes with flat objects, or when a camera looks down on the scene from above. So, when using the occluders, you should take into account peculiarities of objects to be culled.使用封堵器剔除表面较小的大物体可能会导致其他性能损失。此外,遮挡物在带有平坦物体的场景中或摄像机从上方俯视场景时无效。因此,在使用封堵器时,应考虑要剔除的对象的特殊性。

Before using occluders, check the following:在使用封堵器之前,请检查以下内容:

  • Rendering of occluders is enabled: in the Menu Bar, Rendering -> Occlusion Culling -> Occluders is toggled on.启用遮挡物渲染:在菜单栏中,启用了Rendering -> Occlusion Culling -> Occluders
  • Rendering of shadows from the occluded objects is disabled: in the Menu Bar, choose Rendering -> Occlusion Culling and toggle Shadows Culling on.
    注意
    You can leave shadows rendering enabled, if necessary.You can leave shadows rendering enabled, if necessary.
    You can leave shadows rendering enabled, if necessary.
    禁用了遮挡对象的阴影渲染:在菜单栏中,选择Rendering -> Occlusion Culling并启用Shadows Culling
    注意
    You can leave shadows rendering enabled, if necessary.如有必要,可以启用阴影渲染。

Usage of occluders is shown in the Content Optimization video tutorial. Usage of occluders is shown in the Content Optimization video tutorial.

Using a Box-Shaped Occluder
使用盒形封堵器#

The occluder is a box shape that culls objects' surfaces, bounds of which aren't visible behind it. This is the simplest type of occluders that should be used together with box-shaped objects that block off other objects. For example, you can add an occluder the shape of which coincides with the bounds of a building to avoid rendering of objects behind this building. occluder是一个框形形状,用于剔除对象的表面,其后部的边界不可见。这是最简单的封堵器,应与阻挡其他物体的箱形物体一起使用。例如,您可以添加一个遮挡物,遮挡物的形状与建筑物的边界重合,以避免在该建筑物后面渲染对象。

Box-shaped occluder inside building建筑物内的盒形封堵器

To create a box-shaped occluder, perform the following:要创建盒形封堵器,请执行以下操作:

  1. In the Menu Bar, choose Create -> Optimization -> Occluder and add the occluder as a child to the node that should occlude other objects.在菜单栏中,选择Create -> Optimization -> Occluder并将遮挡物作为子项添加到应该遮挡其他对象的节点上。
  2. In the Common section of the Node tab in the Parameters window, set the position of the occluder to the parent one.

    Parameters窗口的Node选项卡的Common部分中,将遮挡物的位置设置为父遮挡物的位置。

  3. In the World Occluder section of the Node tab, click Edit Size to enable the editing mode for the occluder. Resize the occluder by using the colored rectangles on the occluder box sides so that it coincides with the parent node size.
    注意
    You can also use the Size parameter to set the size along the axes.You can also use the Size parameter to set the size along the axes.

    You can also use the Size parameter to set the size along the axes.
    Node选项卡的World Occluder部分中,单击Edit Size以启用封堵器的编辑模式。通过使用阻塞器框两侧的彩色矩形来调整阻塞器的大小,使其与父节点大小一致。
    注意
    You can also use the Size parameter to set the size along the axes.您还可以使用Size参数设置沿轴的大小。

  4. Specify the Distance between the camera and the occluder, at which the occluder doesn't occlude anything and, therefore, should be disabled to avoid negative impact on the performance.

    在摄像机和遮挡件之间指定Distance,在该位置遮挡件不会遮挡任何东西,因此应将其禁用以避免对性能造成负面影响。

To check how the occluder works, disable the parent node and then try to toggle the occluder on and off:要检查阻塞器如何工作,请禁用父节点,然后尝试打开和关闭阻塞器。

By default, the front faces of the occluder are used to cull objects. However, if the camera is inside the occluder (e.g. inside the building), occlusion culling won't be performed. To avoid such situation, enable the Back Face parameter in the World Occluder section of the Node tab. 默认情况下,封堵器的正面用于剔除对象。但是,如果摄像机位于遮挡物内部(例如建筑物内部),则不会执行遮挡剔除。为避免这种情况,请在NodeBack Face选项卡的World Occluder部分中启用参数。

Using a Mesh-Based Occluder
使用基于网格的遮挡物#

The occluder mesh is based on an arbitrary mesh that culls objects' surfaces, bounds of which aren't visible behind it. The occluder mesh is used together with the geometry that cannot be approximated with a box. occluder网格 是基于任意网格的,该网格对对象的表面进行剔除,其边界在后面不可见它。封堵器网格与无法用框近似的几何一起使用。

To create a mesh-based occluder, perform the following:

  1. Prepare a low-poly mesh to be used for the occluder.
    注意
    It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.

    It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.
    Prepare a low-poly mesh to be used for the occluder.
    注意
    It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.

  2. In the Menu Bar, choose Create -> Optimization -> Occluder Mesh and specify the prepared mesh.
    注意
    You can load a new mesh for the occluder at any time.You can load a new mesh for the occluder at any time.
    You can load a new mesh for the occluder at any time.
    In the Menu Bar, choose Create -> Optimization -> Occluder Mesh and specify the prepared mesh.
    注意
    You can load a new mesh for the occluder at any time.You can load a new mesh for the occluder at any time.
  3. Add the occluder as a child to the node that should occlude other objects.Add the occluder as a child to the node that should occlude other objects.
  4. In the Common section of the Node tab in the Parameters window, set the position of the occluder to the parent one.

    In the Common section of the Node tab in the Parameters window, set the position of the occluder to the parent one.

  5. Specify the Distance between the camera and the occluder, at which the occluder doesn't occlude anything and, therefore, should be disabled to avoid negative impact on the performance.

    Specify the Distance between the camera and the occluder, at which the occluder doesn't occlude anything and, therefore, should be disabled to avoid negative impact on the performance.

Prepare a low-poly mesh to be used for the occluder.
注意
It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.

It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.In the Menu Bar, choose Create -> Optimization -> Occluder Mesh and specify the prepared mesh.
注意
You can load a new mesh for the occluder at any time.You can load a new mesh for the occluder at any time.
You can load a new mesh for the occluder at any time.Add the occluder as a child to the node that should occlude other objects.In the Common section of the Node tab in the Parameters window, set the position of the occluder to the parent one.

Specify the Distance between the camera and the occluder, at which the occluder doesn't occlude anything and, therefore, should be disabled to avoid negative impact on the performance.

要创建基于网格的遮挡件,请执行以下操作:

  1. Prepare a low-poly mesh to be used for the occluder.
    注意
    It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.

    It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.
    准备要用于封堵器的低多边形网格。
    注意
    It isn't recommended to use the same detailed mesh that is used for the node that should occlude other objects: the mesh for the occluder should be as simple as possible to avoid performance loss.不建议使用与应该阻塞其他对象的节点相同的详细网格:阻塞器的网格应尽可能简单,以避免性能损失。

  2. In the Menu Bar, choose Create -> Optimization -> Occluder Mesh and specify the prepared mesh.
    注意
    You can load a new mesh for the occluder at any time.You can load a new mesh for the occluder at any time.
    You can load a new mesh for the occluder at any time.
    在菜单栏中,选择Create -> Optimization -> Occluder Mesh并指定准备的网格。
    注意
    You can load a new mesh for the occluder at any time.您可以随时为咬合器加载新的网格物体
  3. Add the occluder as a child to the node that should occlude other objects.将阻塞器作为子对象添加到应该阻塞其他对象的节点上。
  4. In the Common section of the Node tab in the Parameters window, set the position of the occluder to the parent one.

    Parameters窗口的Node选项卡的Common部分中,将遮挡物的位置设置为父遮挡物的位置。

  5. Specify the Distance between the camera and the occluder, at which the occluder doesn't occlude anything and, therefore, should be disabled to avoid negative impact on the performance.

    在摄像机和遮挡件之间指定Distance,在该位置遮挡件不会遮挡任何东西,因此应将其禁用以避免对性能造成负面影响。

Hardware Occlusion Queries
硬件遮挡查询#

One more option to cull geometry that is not visible in the camera viewport is to use a hardware occlusion query. It allows skipping rendering of objects, the bounding boxes of which are covered by another solid geometry. As a result, the number of rendered polygons is reduced and the performance grows.剔除在摄影机视口中不可见的几何的另一种选择是使用硬件遮挡查询。它允许跳过对象的渲染,这些对象的边界框被另一个实体几何覆盖。结果,减少了渲染多边形的数量,并提高了性能。

To run the hardware occlusion test for the scene before sending data to the GPU, toggle the Rendering -> Occlusion Culling -> Occlusion Query flag on in the Menu Bar.要在将数据发送到GPU之前对场景进行硬件遮挡测试,请在菜单栏中打开Rendering -> Occlusion Culling -> Occlusion Query标志。

注意
Culling will be performed for all objects with the Culled by Occlusion Query flag set in the Node tab of the Parameters window.将对在ParametersCulled by Occlusion Query窗口的Node选项卡中设置了标志的所有对象执行剔除。

To run the hardware occlusion test, perform the following:要运行硬件遮挡测试,请执行以下操作:

  1. In the Menu Bar, toggle the Rendering -> Occlusion Culling -> Occlusion Query flag on to enable testing for the scene before sending data to the GPU.

    在菜单栏中,将Rendering -> Occlusion Culling -> Occlusion Query标志打开,以启用对场景的测试,然后再将数据发送到GPU。

  2. For all objects, that should be culled, enable the Culled by Occlusion Query flag in the Node tab of the Parameters window.
    注意
    Only nodes with this flag set are tested on the hardware occlusion culling.Only nodes with this flag set are tested on the hardware occlusion culling.

    Only nodes with this flag set are tested on the hardware occlusion culling.
    对于所有应该剔除的对象,在ParametersCulled by Occlusion Query窗口的Node选项卡中启用标志。
    注意
    Only nodes with this flag set are tested on the hardware occlusion culling.仅对设置了此标志的节点进行硬件遮挡剔除测试。

When culling is enabled for the object, an occlusion query box is rendered for it.为对象启用剔除后,将为其呈现遮挡查询框

Material ball and its occlusion query box Material ball及其遮挡查询框
注意
To visualize such boxes, toggle the Helpers -> Occlusion Queries option on.要显示此类框,请打开Helpers -> Occlusion Queries选项。

The occlusion query box coincides with the size of the object's bounding box. When this box is overlapped (i.e. it isn't in the camera viewport), it is highlighted red, which means the occlusion test is not passed and the mesh will not be drawn.遮挡查询框与对象边界框的大小一致。当此框重叠时(即不在相机视口中),将突出显示红色,这意味着未通过遮挡测试并且将不会绘制网格。

Occlusion query test passed遮挡查询测试通过
Occlusion query test failed, material ball isn't rendered遮挡查询测试失败,未显示实物球
注意
Hardware occlusion queries should be used only for objects that use heavy shaders. Otherwise, performance will decrease instead of increasing. It is recommended to enable queries for water or objects with reflections.硬件遮挡查询仅应用于使用较重着色器的对象。否则,性能将下降而不是提高。建议启用对具有反射的水或对象的查询。

You can check the effect of this technique by enabling the second wireframe mode to see all triangles in the scene. Type render_show_triangles 2 in the console and check the way the occluded polygons act.您可以通过启用第二个线框模式以查看场景中的所有三角形来检查此技术的效果。在控制台中输入 render_show_triangles 2 并检查遮挡的多边形的作用方式。

An example of using hardware occlusion queries is also available in the Content Optimization video tutorial.“内容优化”视频教程中也提供了使用硬件遮挡查询的示例。内容优化 视频教程.

最新更新: 2024-12-13
Build: ()