GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - pezcode/Cluster: Clustered shading implementation with bgfx

BranchesTags
Open more actions menu

Latest commit

 

History

131 Commits
131 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
3rdparty
3rdparty
 
 
assets/fonts
assets/fonts
 
 
images
images
 
 
src
src
 
 
.clang-format
.clang-format
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
CMakeLists.txt
CMakeLists.txt
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 

Repository files navigation

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
    • diffuse RGB, roughness
    • encoded view-space normal (RG16F)
    • F0 RGB, metallic
    • emissive RGB, occlusion
  • 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)

  • metallic + roughness material support
  • tangent space normal mapping
  • Cook-Torrance microfacet specular BRDF
    • GGX normal distribution function
    • Smith-GGX geometric shadowing function
    • multiple scattering correction
  • Lambertian diffuse BRDF
  • specular antialiasing
  • windowed light attenuation

Tonemapping

HDR tonemapping postprocessing with different operators:

  • exponential
  • simple Reinhard
  • Reinhard (luminance only)
  • Uncharted 2
  • H.P. Duiker filmic curve
  • ACES
  • ACES (luminance only)

References

A few useful resources that helped with the implementation:

  • Clustered Shading:
    • A Primer On Efficient Rendering Algorithms & Clustered Shading by Angel Ortiz
    • Practical Clustered Shading by Emil Persson
    • The devil is in the details: idTech 666 by Tiago Sousa und Jean Geffroy
  • Physically Based Rendering:
    • Physically Based Rendering in Filament by Romain Guy and Mathias Agopian
    • Real Shading in Unreal Engine 4 by Brian Karis
    • Moving Frostbite to Physically Based Rendering by Sébastien Lagarde and Charles de Rousiers
  • Tonemapping:
    • Filmic Tonemapping Operators by John Hable

Compilation

CMake (>= 3.2) is required for building.

  1. Generate project files:

    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

  • bigg (bgfx + dear imgui + glfw + glm) for UI and rendering
  • IconFontCppHeaders for icon font support
  • assimp for model import
  • spdlog for logging

Assets

  • Sponza model
  • Roboto font
  • Fork Awesome icon font

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.

About

Clustered shading implementation with bgfx

Topics

bgfxclustered-shadingdeferred-shadinggraphicshdrpbrphysically-based-renderingshaderstone-mapping

Resources

Readme
MIT license
Activity

Stars

472 stars

Watchers

10 watching

Forks

33 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.