Giter Site home page Giter Site logo

angelo1211 / hybridrenderingengine Goto Github PK

View Code? Open in Web Editor NEW
1.1K 29.0 118.0 430.27 MB

Clustered Forward/Deferred renderer with Physically Based Shading, Image Based Lighting and a whole lot of OpenGL.

License: MIT License

CMake 4.76% C++ 65.28% GLSL 27.21% C 2.75%
rendering-engine 3d-graphics prototype opengl physically-based-rendering graphics-programming sdl2 c-plus-plus graphics shaders

hybridrenderingengine's Introduction

HRE :: Hybrid (Clustered Forward/Deferred) Rendering Engine

GitHub license GitHub issues

HRE was a real-time, Physically based, Clustered renderer built with OpenGL and based on the techniques described on the paper Clustered Deferred and Forward shading by Ola Olsson, Markus Billeter and Ulf Assarsson. The aim of this project is to build a testing framework to showcase deferred and forward graphics techniques (hence the hybrid part) and to examine the strengths of Clustered shading. I wrote a lengthy blog post full of cool animations that can serve as an introduction to efficient rendering algorithms as well as a detailed guide of my implementation of Clustered Shading, so make sure to check it out here!

This algorithm was selected for its two major benefits over traditional deferred/tiled solutions: it allows for more freedom to choose forward or deferred shading paths as desired and is a better long term fit for the modern GPU performance trends. It has already been succesfully implemented in some of the best looking games of the last couple of years, with some notable examples being: DOOM 2016, Just Cause 3 and Detroit: Become Human.

Project is now on hold :(

Unfortunately this project is no longer maintained. I got hired to work at Rockstar Games as a Graphics Programmer shortly after posting this and don't have the time to work on a sideproject of this size anymore. I plan on keeping it up (as well as my other major graphics project SSGE) so others can see what it took me to break into the industry. I will still be helping anyone who runs into any issues with it or has any questions about it. Feel free to reach me here or at my twitter about this or any other GFX topic you'd like to talk about! Thanks to everyone who checked this project out! :D

Download

Stable builds can be found on the HRE releases page.

Currently only Windows platforms are supported.

Render Samples

helmetcrop

waterbottlefixed

metallicspheres

sponza correct colors

Cluster z slices

Main Features

Rendering

  • Clustered Forward/Deferred Renderer
  • Physically Based shading
  • Image Based Lighting
  • Metallic workflow
  • Cook-Torrance specular BRDF (w/ lambert diffuse)
  • Ambient Occlusion & Emissive mapping
  • Tangent space normal mapping
  • HDR/linear lighting
  • HDR/LDR skyboxes
  • Exposure based tone mapping
  • Bloom
  • Multisample Anti-aliasing (MSAA)
  • Directional & point light sources
  • Compute shader based light culling
  • Alpha tested foliage (sponza atrium)
  • Directional light dynamic shadow mapping
  • Static Omnidirectional Shadow Mapping for Point Lights
  • Forward, Tiled Forward and Deferred rendering implementations
    • Located in other branches of the repo. Only clustered rendering is actively being developed.

Engine

  • OpenGL 4.5+
  • SDL2 backend
  • JSON Parsing via Nlohmann: JSON for C++
  • Model Loading via ASSIMP (OBJ, FBX, gLTF2.0 etc)
  • Scene contents clearly outlined in JSON file
  • Multiple image loading paths via stb-image and GLI
  • Immediate mode GUI for debugging via ImGUI
  • Fully commented for future referencing
  • Environment map generation on load for IBL and skyboxes
  • Free flight camera

Development Timeline & Planned Features

Alas, I am unfortunately unable to work on this project anymore and won't be updating it any time soon. I am still keeping this section in here as a record in case I ever do return and as proof of my naive optimism. Thanks to everyone who checked out this project! :)

The first development cycle began September 2018 and concluded December 2018 with the inclusion of Image Based Lighting and the release of the first stable version: HRE 0.01 "Aachen". For the next couple of months I'll be tackling the issues outlined in the Projects section beginning with fixes for the remaining non-critical bugs and then moving on to a major re-write of the material system. The following is a a list of the engine features I aim to include over the coming months, it's obviously subject to change and all that stuff.

Update #1: Materials & Shadow Mapping

  • Full material system re-write to decouple mesh & textures.
  • Implementing a shadow mapping atlas and automatic shadow map reuse.
  • Fix some unneccessary STL calls.

Update #2: Deferred / Screen Space Effects

  • Rewriting screen space fragment shaders as compute shaders
  • Screen Space Ambient Occlusion
  • Screen Space Reflections
  • Temporal AA
  • Improved Color Grading & Tone Mapping

Update #3: Cluster Optimizations

  • Large amounts of lights via BVH construction
  • Advanced environment mapping
  • View Frustum culling
  • Compute shader based particles
  • Include Approaching Zero Driver Overhead (AZDO) principles

I'll be writing accompanying blog posts at the end of each major milestone, outlining the new features and their implementations and any complications I found along the way. Meanwhile, Here's the first post which contains an overview of other traditional rendering algorithms and builds the case for Clustered rendering.

Repository structure

Hybrid Rendering Engine
|-- assets              
|   |-- models              # Meshes and textures
|   |-- scenes              # Scene description files in JSON format
|   |-- shaders             
|   |   |-- computeShaders  # Compute shaders for clustered forward
|   |   |-- OldShaders      # Shaders not currently in use
|   |   `-- currentShaders  # Shaders for the current rendering pipeline
|   `-- skyboxes            # Skyboxes in either cubemap or equirectangular map form
|-- build                   # CMake compile  
|-- include                 # Project header files
|-- libs                    # Check dependencies section for descriptions & links
|   |-- ASSIMP               
|   |-- Dear imgui           
|   |-- Glad 
|   |-- Json c++            
|   |-- GLI 
|   |-- GLM 
|   |-- stb_image 
|   `-- SDL2 
|-- modules                 # CMake lib setup scripts
|-- src                     # C++ implementation files
`-- CMakeLists.txt          # CMake build script

Dependencies

In my previous project, SSGE, I made an effort to reduce the amount of dependencies to a minimum. This time however, the pendulum has swung the other way and I've made no restriction whatsoever (within reason) as to what libraries I could include in the project. I did this because I wanted to get more comfortable with the process of including and working with external libraries in C++.

Here's a list of the libraries currently included in the project:

Here's a list of the libraries not included:

  • CMake: Build generation.
  • OpenGL: All things GPU & graphics.

All included libraries are represented here under their respective licenses which can be found in the links above or in the licenses.txt doc in the libs folder.

References

There's a comprehensive indexed list of references for the project that I keep more or less up to date in this page of the wiki. However, I find myself constantly returning to a subset of them for further reading or when I need inspiration, so I've added links below to share them and spread the word of their awesomeness. Check them out!

Acknowledgements

Models & Textures

Thank you to all the 3D & texture artists who have made their assets free to use and so beautiful to look at. If it weren't for you guys I'd probably still be staring at the same old boring utah teapot all damn day!

If I've mis-acknowledged, misattributed, or missed any references, please, create a new GitHub issue or send me a DM on Twitter and I'll make sure to fix it immediately.

Graphics Programming Community <3

Shout-out to Kostas Anagnostou and Eric Arnebäck for taking the time to answer all of my questions for the last couple of months, your explanations made understanding every daunting topic so much easier!

License

MIT License

Copyright (c) 2018 Angel Ortiz

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.

hybridrenderingengine's People

Contributors

angelo1211 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hybridrenderingengine's Issues

Rewrite shadow mapping to use virtual texturing.

Dynamic shadow mapping is currently the most expensive operation on the renderer, yet it still looks pretty awful. It's also implemented in a way that does not scale well at all and causes way too many API calls. It would be worth it to attempt to implement a more robust system like virtual texturing as seen here:

http://www.adriancourreges.com/blog/2016/09/09/doom-2016-graphics-study/

It would be also worth it to research shadow mapping techniques that leverage the Cluster shading algorithm like the one in the Emil Persson and Ola Olsson talk.

Hi, very nice work!!! Can u help me this bug?

it's not a bug, I just donlt know how to show it

build ‹master*› » ./hybridRenderer
Vendor:   NVIDIA Corporation
Renderer: NVIDIA GeForce RTX 2060 SUPER/PCIe/SSE2
Version:  4.6.0 NVIDIA 470.103.01

Beginning Scene load, checking scene description file:
Cannot access ../assets/scenes/Sponza.json
Cannot find scene descriptor file for Sponza 
Could not load default sponza scene. No models succesfully loaded!
Failed to initialize scene manager.
HRE could not initialize successfully. Shutting down.
Closed input manager.
Closed renderer manager.
Closed scene manager.
Closed display manager.

Any help?

the json file just there...

Add formatting checks for scene JSON description file.

Currently, if the scene file is missing some component that the renderer deems necessary it will just crash. This is inconvenient. We should add a warning that lets the user know that something is missing, then load a default value if possible and continue.

More json

This is a wonderful project, so I wanderer whether there is more Jsons that can achieve the effect in Render samples, it means a lot to me. Appreciate!

Could not run the release

Vendor:   NVIDIA Corporation
Renderer: GeForce GTX 750 Ti/PCIe/SSE2
Version:  4.6.0 NVIDIA 442.19

Beginning Scene load, checking scene description file:
Cannot access ../assets/scenes/Sponza.json
Cannot find scene descriptor file for Sponza
Could not load default sponza scene. No models succesfully loaded!
Failed to initialize scene manager.
HRE could not initialize successfully. Shutting down.
Closed input manager.
Closed renderer manager.
Closed scene manager.
Closed display manager.

The json is right there, so I dont understand, even tried with admin rights

Build failed. Error C2593 on scene.cpp

Severity Code Description Project File Line Suppression State
Error C2593 'operator =' is ambiguous hybridRenderer C:\Users\DEMO\source\repos\HybridRenderingEngine-0.1\src\scene.cpp 397

Evaluate how hard it would be to port to linux.

Given that I have been using CMAke for building, SDL2 for the hardware abstraction layer and OpenGL it might not be too awful to port the project to linux. This is not super high priority however.

Blog post on first release.

Describing the work done until now, laying out implementation detail and outlining the work that is yet to be done.

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
ASSIMP_LIBRARY_DEBUG
linked by target "hybridRenderer" in directory C:/src/HybridRenderingEngine
ASSIMP_LIBRARY_RELEASE
linked by target "hybridRenderer" in directory C:/src/HybridRenderingEngine

image

Reduce very large VRAM footprint.

Currently the project uses nearly 700MB of VRAM because of the many framebuffers I'm using. Find a way to reduce it, possibly by freeing frame buffers that are only used during initialization?

Crash during shader load.

Attempted to launch the hybridRenderer.exe, the console window shows Loading Complete!..., but the Hybrid Rendering Engine window is unresponsive and stays blank white while using ~18% CPU, 0% GPU and ~124MB memory.

Windows 10, i7 5930k, 32GB RAM, 1080ti with 416.94 driver using the v0.1 release.

Full text from console is
Vendor: NVIDIA Corporation
Renderer: GeForce GTX 1080 Ti/PCIe/SSE2
Version: 4.6.0 NVIDIA 416.94

Beginning Scene load, checking scene description file:
../assets/scenes/Sponza.json is a valid file
Loading camera...
Loading models...
../assets/models/Sponza/Sponza.gltf is a valid file
Loading skybox...
Loading lights...
Loading directional light...
Loading point light...
Generating environment maps...
Reticulating splines...
Loading Complete!...

Occasionally on load, the entire scene is just red or black

image

The skyboxes are unaffected when this happens, so it must be one of the other shaders (like the BRDF lut or something). The exact cause is unknown though, because it's a random chance to occur on every boot. Even though I'm familiar with the codebase at this point, I have no idea what causes it

cmake failed

Hi, I am interested in this project, but cmake failed
123

Remove unnecessary STL calls to vector.h

Mesh, Model and Scene classes use vector.h as a container in cases where it might not be necessary at all. Evaluate if this is the case and come up with alternative.

Decouple material system from mesh & models classes.

Currently texture are loaded and stored directly in the model class with each mesh object containing a list of references to textures that it will use. This is inconvenient since it impedes material reuse beyond the model layer and limits the types of material possible by the texture slots it has. Working on this would allow for simpler shaders and would be an opportunity to implement run-time material switching.

Automatic shadow mapping & caching.

Currently the directional light shadow map is updated every frame so that users can play with the GUI controls for it but there is no real reason it should be updating every frame if no change in the static or dynamic geometry has occurred.

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.