Need help with Cluster?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

pezcode
179 Stars 13 Forks MIT License 125 Commits 0 Opened issues

Description

Clustered shading implementation with bgfx

Services available

!
?

Need anything else?

Contributors list

# 50,038
vulkan
Lua
D
directx...
116 commits
# 601,294
Shell
Android
C++
C
4 commits

Cluster

Implementation of Clustered Shading and Physically Based Rendering with the bgfx rendering library.

Render result

Cluster light count visualization

Currently bgfx's OpenGL, DirectX 11/12 and Vulkan backends are supported. I've only tested on Windows 10 with an Nvidia GTX 1070. Other hardware or operating systems might have subtle bugs I'm not aware of.

Functionality

Live-switchable render paths

  • forward, deferred and clustered shading
  • output should be near-identical (as long as you don't hit the maximum light count per cluster)

Clustered Forward Shading

  • logarithmical depth partition
  • compute shader for cluster generation
  • compute shader for light culling
    • AABB test for point lights
  • cluster light count visualization

Deferred Shading

  • G-Buffer with 4 render targets
  • light culling with light geometry
    • axis-aligned bounding box
    • backface rendering with reversed depth test
    • fragment position reconstructed from depth buffer
  • final forward pass for transparent meshes

Forward Shading

Very simple implementation, might be useful to start reading the code

Physically Based Rendering (PBR)

Tonemapping

HDR tonemapping postprocessing with different operators:

References

A few useful resources that helped with the implementation:

Compilation

CMake (>= 3.2) is required for building.

  1. Generate project files: ```bash mkdir build cd build

    e.g. VS 2019, compile for x64 platform

    cmake -G "Visual Studio 16 2019" -A x64 .. cd .. ```

  2. Build. Open the project files with your IDE/build tool, or use CMake:

    cmake --build build/ --parallel --config Release
    

You can also grab a compiled copy for Windows with the Sponza model from the Releases page.

Libraries

Assets

License

This software is licensed under the MIT License. Basically, you can do whatever you want with it, as long as you don't remove the license and copyright notice from relevant pieces of code.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.