百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
I

Indirect-Rendering-With-Compute-Shaders

> 编程语言
开源

使用 Unity3D、计算着色器和 Graphics.DrawMeshInstancedIndirect 绘制大量实例的示例,其中包含 Frustum & Occlusion 回收和 LOD 处理。

770 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

使用 Unity3D、计算着色器和 Graphics.DrawMeshInstancedIndirect 绘制大量实例的示例,其中包含 Frustum & Occlusion 回收和 LOD 处理。

Indirect Rendering With Compute Shaders

An example of rendering numerous instances in Unity3D using Compute shaders for culling and LOD'ing and Graphics.DrawMeshInstancedIndirect to draw.

Features

  • Tested on Metal (Mac) and D3D11.
  • Quasirandom squences to place the instances
  • Draw things using Graphics.DrawMeshInstancedIndirect
  • GPU Sorting with Bitonic sorting
  • Compute shader: Frustum and shadow caster culling
  • Compute shader: Occlusion culling with HierarchicalZBuffer
  • Compute shader: Detail (Screen Size) Culling
  • Compute shader: LOD objects using the distance from camera to object
  • Simple shadow mode: Only use one shadow mesh for each instance type to lower setpass calls

Project Setup

  • "_Example.cs" script on the "Example" game object:
    • Creates the instance data and sends it to the Indirect Renderer class.
  • "IndirectRenderer.cs" on the "MainCamera" game object:
    • Is the main class in the project. It initializes all the buffers and compute shaders and then dispatches the compute shaders and draws the objects when Unity calls the PreCull() function.
  • "HiZBuffer.cs" script on the "OccluderCamera" game object:
    • Creates a hierarchial Z-Buffer texture that contains the depth texture and shadow map which are used when doing frustum and occlusion culling

TODO

  • Add reprojection of last frame’s depth to the Hi-Z (See "GPU-Driven Rendering Pipelines" below)
  • Improve the instance sorting:
    • On my Macbook pro (mid 2014) sorting takes approx 50% of the GPU time
    • The GPU sorting must support instance numbers that are not in the non power of two
    • Find a better performant approach for the CPU Sorting
  • Create the Hi-Z Texture with compute shaders
  • Try out Raster Occlusion instead of Hi-Z (See "NVidia Siggraph 2014" & "Github - nvpro-samples" below)

Resources

The Unreasonable Effectiveness of Quasirandom Sequences

Kostas Anagnostou - GPU Driven Rendering Experiments

Kostas Anagnostou - Experiments in GPU-based occlusion culling

Kostas Anagnostou - Experiments in GPU-based occlusion culling part 2

Ulrich Haar & Sebastian Aaltonen - GPU-Driven Rendering Pipelines

Sakib Saikia - Going Indirect on UE3

RasterGrid - Hierarchical-Z map based occlusion culling

StackOverflow - Hierachical Z-Buffering for occlusion culling

Daniel E - Hierarchical Z-Buffer Occlusion Culling with multiple samples

bazhenovc - GPU Driven Occlusion Culling in Life is Feudal

NVIDIA - Siggraph 2014 - Scene Rendering Techniques

Github - nvpro-samples/gl_occlusion_culling

GPU Gems 2 - Hardware Occlusion Queries Made Useful

ARM Developer Center - hiz_cull.cs

L. Spiro - Tightly Culling Shadow Casters for Directional Lights (Part 1)

L. Spiro - Tightly Culling Shadow Casters for Directional Lights (Part 2)

nonoptimalrobot - Shadow Volume Culling

Stephen Hill and Daniel Collin - Practical, Dynamic Visibility for Games

zeuxcg.org - View frustum culling optimization - Representation matters

License

Copyright (C) 2017-2018 Elvar Orn Unnthorsson

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言