{
  "schemaVersion": "0.11.0",
  "canonical": "https://www.pystone.net/notes/unity-culling-techniques/",
  "atlas": "https://www.pystone.net/?node=unity-culling-techniques#knowledge-atlas",
  "markdown": "https://www.pystone.net/notes/unity-culling-techniques.md",
  "context": "https://www.pystone.net/notes/unity-culling-techniques.context.json",
  "knowledgeVersion": "224c990773de.5fa8af6e39fa",
  "build": {
    "siteCommit": "224c990773de166d23a886306577dd90379529ce",
    "notesCommit": "5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a",
    "builtAt": "1970-01-01T00:00:00.000Z",
    "version": "224c990773de.5fa8af6e39fa"
  },
  "id": "note:unity-culling-techniques",
  "slug": "unity-culling-techniques",
  "title": "Unity中Culling相关技术",
  "type": "note",
  "visibility": "public",
  "idStability": "rename-stable",
  "author": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "publisher": {
    "name": "Perrin Yong",
    "profile": "https://www.pystone.net/profile/"
  },
  "aliases": [],
  "summary": "Unity中Culling相关技术",
  "contentRole": "unspecified",
  "isMoc": false,
  "mocRecognition": "none",
  "generated": false,
  "attribution": "unspecified",
  "domain": "10-计算机、信息技术与工程",
  "tags": [],
  "mocs": [],
  "contentHash": "b1062ec3821d03e12ce55908fe08edf2f57b770c498f953400340043c38cf9d0",
  "assets": [],
  "headings": [
    {
      "depth": 1,
      "text": "Unity中Culling相关技术",
      "anchor": "unity中culling相关技术",
      "citation": "https://www.pystone.net/notes/unity-culling-techniques/#unity%E4%B8%ADculling%E7%9B%B8%E5%85%B3%E6%8A%80%E6%9C%AF"
    },
    {
      "depth": 2,
      "text": "Frustum Culling",
      "anchor": "frustum-culling",
      "citation": "https://www.pystone.net/notes/unity-culling-techniques/#frustum-culling"
    },
    {
      "depth": 3,
      "text": "Builtin管线",
      "anchor": "builtin管线",
      "citation": "https://www.pystone.net/notes/unity-culling-techniques/#builtin%E7%AE%A1%E7%BA%BF"
    },
    {
      "depth": 3,
      "text": "SRP的Culling",
      "anchor": "srp的culling",
      "citation": "https://www.pystone.net/notes/unity-culling-techniques/#srp%E7%9A%84culling"
    },
    {
      "depth": 2,
      "text": "Occlusion Culling",
      "anchor": "occlusion-culling",
      "citation": "https://www.pystone.net/notes/unity-culling-techniques/#occlusion-culling"
    },
    {
      "depth": 2,
      "text": "Camera.layerCullDistance",
      "anchor": "cameralayerculldistance",
      "citation": "https://www.pystone.net/notes/unity-culling-techniques/#cameralayerculldistance"
    },
    {
      "depth": 2,
      "text": "CullingGroup API",
      "anchor": "cullinggroup-api",
      "citation": "https://www.pystone.net/notes/unity-culling-techniques/#cullinggroup-api"
    },
    {
      "depth": 2,
      "text": "ref",
      "anchor": "ref",
      "citation": "https://www.pystone.net/notes/unity-culling-techniques/#ref"
    }
  ],
  "claims": [],
  "outgoing": [],
  "incoming": [
    {
      "id": "note:game-graphics-and-runtime",
      "title": "游戏图形与运行时",
      "url": "https://www.pystone.net/notes/game-graphics-and-runtime/",
      "atlas": "https://www.pystone.net/?node=game-graphics-and-runtime#knowledge-atlas",
      "label": "游戏图形与运行时",
      "origin": "explicit",
      "humanReviewed": true,
      "context": "Unity中的“Unity中Culling相关技术”导航项",
      "citation": "https://www.pystone.net/notes/game-graphics-and-runtime/#unity"
    }
  ],
  "contentMarkdown": "# Unity中Culling相关技术\n\n> 创建时间：2021/4/23 21:40\n\n  * Unity中Culling相关技术\n    * Frustum Culling\n      * Builtin管线\n      * SRP的Culling\n    * Occlusion Culling\n    * Camera.layerCullDistance\n    * CullingGroup API\n    * ref\n\n## Frustum Culling\n\n剔除被其他物体遮挡的，摄像机不可见(但在视锥体内)的渲染物体。使用 Occlusion Culling 需要手动设置，并在 Occlusion Culling Window 中通过 Bake 计算剔除数据。\n<https://docs.unity3d.com/Manual/OcclusionCulling.html>\n\n### Builtin管线\n\n视锥体剔除 - 视锥体剔除是引擎自己做的，在给GPU提交数据进行渲染前，会执行视锥体剔除，决定哪些可见哪些不可见。经过剔除之后，Renderer的isVisible值就表示相应物体的可见性，不过此时已经在这帧的Update之后了。在Update当中取IsVisible属性获取的实际上是上一帧的可见性。 至于视锥体剔除的实现方法我们不清楚，可能引擎底层会有一些优化，使用kd-tree进行空间划分等等。\n\n### SRP的Culling\n\n  1. SRP的Culling可以自己写\n\n  2. URP的管线相对比较固定，可定制化程度低，Culling不太好自己写\n\nOcclusion 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.\n\n## Occlusion Culling\n\n在移动端使用的比较少，属于用 CPU时间换一定的CPU时间和一定的GPU时间的操作。使用方法是：预先烘焙遮挡剔除信息（对于一定的区域，哪些物体被遮挡），在游戏运行时，经过视锥体剔除之后，对于视锥体内的物体，相机到了一定的位置，会去取预先烘焙的信息，来判断哪些物体被遮挡，对相应的物体进行剔除，进而节省被遮挡的物体提交渲染进行、在GPU端进行绘制的时间。\n\n## Camera.layerCullDistance\n\nFor performance reasons, you might want to cull small objects earlier. For example, small rocks and debris could be made invisible at much smaller distance than large buildings. To do that, put small objects into a separate layer and set up per-layer cull distances using Camera.layerCullDistances script function.\n<https://docs.unity3d.com/ScriptReference/Camera-layerCullDistances.html>\n\n## CullingGroup API\n\nCullingGroup offers a way to integrate your own systems into Unity’s culling and LOD pipeline.The CullingGroup will calculate visibility based on frustum culling and static occlusion culling only. It will not take dynamic objects into account as potential occluders.\n<https://docs.unity3d.com/Manual/CullingGroupAPI.html>\n\nUnity的CullingGroup API是纯逻辑的东西，不影响渲染。其使用方法是：在逻辑代码中定义CullingGroup，Group中加入一些球体(位置与半径，是逻辑上的球体，实际是不可见的)，并加入要检测的相机，渲染时，Unity会判断这些球体是否可见，进而判断CullingGroup的可见性。在渲染之后，可以在代码中获取该Group的可见性，进而据此控制一些逻辑。如果不用代码去取CullingGroup的信息，那么它就是没有用的。\n\n## ref\n\n<https://blog.csdn.net/kenight/article/details/82760667>\n"
}
