Coder Social home page Coder Social logo

quaidtseng / clusteredshadingfork Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pezcode/cluster

0.0 0.0 0.0 2.25 MB

Clustered shading implementation with bgfx

License: MIT License

Shell 14.44% C++ 66.32% C 1.37% Scala 9.04% SuperCollider 5.57% CMake 3.28%

clusteredshadingfork's Introduction

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:

    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.

clusteredshadingfork's People

Contributors

pezcode avatar alekseyt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.