Skip to content

Real-Time Vulkan Renderer with features like PBR, IBL, and more.

Notifications You must be signed in to change notification settings

SaferGo/CroissantVulkanRenderer

Repository files navigation

Croissant - Real-Time Vulkan Renderer

Real-time, Physically based renderer built with Vulkan and modern C++17.

About

The aim of this project was to create a properly functioning render graph that would allow me to learn and experiment with Vulkan, as well as provide an opportunity to learn graphics techniques.

Disclaimer

This project is under development, expect API changes, bugs and missing features.

Render Samples

1gg 3c t2 Screenshot from 2023-02-20 15-12-01 t5 t6

Features

Renderer

  • Physically based rendering(Cook–Torrance BRDF)
  • Image based lighting
  • Forward rendering
  • Multisample anti-aliasing (MSAA)
  • HDRI skymap loading
  • Compute shaders
  • Shadow mapping
  • Normal mapping
  • Different light types (directional, point and spot lights)
  • Texture mipmaps
  • Arcball camera
  • GUI

Other Features

  • Multi-threaded texture asset importing
  • Model loading

Repository structure

Croissant
|
|-- assets              
|   |-- models              # Meshes and textures
|   `-- skybox              # HDR files with their generated irradiance, prefiltered env. and BRDFlut textures
|
|-- bin                     # Contains the executable files
|
|-- build                   # CMake compile
|
|-- include                 # Project header files
|   `-- Settings            # All user tweakable settings files(scene, camera, pipeline, etc)
|
|-- libs                    # Dependencies
|   |-- ASSIMP
|   |-- GLFW
|   |-- GLI
|   |-- GLM
|   |-- Dear imgui           
|   |-- stb_image
|   |-- tracy
|   |-- Vulkan-Loader            
|   `-- Vulkan-Tools
|
|-- shaders
|
|-- src                     # C++ implementation files
|   |-- Buffer
|   |-- Camera
|   |-- Command
|   |-- Computation
|   |-- Descriptor
|   |-- Device
|   |-- Features
|   |-- Framebuffer
|   |-- GUI
|   |-- Image
|   |-- Math
|   |-- Model
|   |-- Pipeline
|   |-- Queue
|   |-- Renderer
|   |-- RenderPass
|   |-- Scene
|   |-- Shader
|   |-- Swapchain
|   |-- Texture
|   |-- VkInstance
|   `-- Window
|   
`-- CMakeLists.txt          # CMake build script

Third party libraries

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

  • ASSIMP: Mesh and material loading.
  • GLFW: A multi-platform library for window and input.
  • GLI: Image library(used to generate the BRDFlut texture).
  • GLM: Mathematics library for graphics software.
  • ImGui: GUI.
  • stb_image: Image loading/decoding.
  • Tracy: Frame profiler.
  • Vulkan-Loader
  • Vulkan-Tools: Validation Layers.

Render Graph

Render Graph (5) Render Graph (6)

Usage

Warning

  • The renderer currently only works with a dedicated graphics card, but I will add compatibility with integrated GPUs in the future.
  • To start the renderer, you need to add one skybox, one directional light, and at least one model.
  • To add a model or skybox to the render, add the folder in 'assets'.
  • Modify the config.h file in 'Settings' to change a lot of parameters.
/* Commands:
*   
*   - addSkybox(fileName, folderName);
*   - addObjectPBR(name, folderName, fileName, position, rotation, size);
*   - addDirectionalLight(name, folderName, fileName, color, position, targetPosition, size);
*   - addSpotLight(name, folderName, fileName, color, position, targetPosition, rotation, size);
*   - addPointLight(name, folderName, fileName, color, position, size);
*
*   - demo1(); // Damaged Helmet
*   - demo2(); // AK 47
*   - demo3(); // Collier Flintlock Revolver
*   - demo4(); // Sponza day
*   - demo5(); // Sponza night
*   - demo6(); // Metal Rough Spheres
*/

int main()
{
   Renderer app;

   try
   {
      // Scene
      {
         app.addSkybox("fileName.hdr", "folderName");
         app.addObjectPBR(
               "name",
               "folderName",
               "fileName",
               glm::fvec3(0.0f), // Position
               glm::fvec3(0.0f), // Rotation
               glm::fvec3(1.0f)  // Size
         );
         app.addDirectionalLight(
               "name",
               "folderName",
               "fileName",
               glm::fvec3(1.0f), // Color
               glm::fvec3(0.0f), // Position
               glm::fvec3(1.0f), // Target Position
               glm::fvec3(1.0f)  // Size
         );
      }

      app.run();

   } catch (const std::exception& e)
   {
      std::cerr << e.what() << "\n";

      return 0;
   }

   return 0;
}

Controls

Input Action
RMB drag Rotate camera
Scroll wheel Zoom in/out

Dependencies

  • cmake >= 3.9.1
  • gcc >= 9.4.0
  • vulkan-validationlayers-dev
  • spirv-tools
  • glslc

Building on Linux

$ git clone --recurse-submodules https://github.com/SaferGo/CroissantVulkanRenderer.git
$ cd CroissantVulkanRenderer/build
$ bash buildReleaseMode.sh
// or buildDebugMode.sh

After a successful build, the resulting executable can be found in the bin directory.

Tested toolchains

Compiler Operating System Architecture
GCC 9.4.0 Linux Ubuntu 20.04.4 with kernel 5.8.0-53 x64
? Windows 11 (will be added soon) x64

References

Included assets

The following assets are bundled with the project:

- HDRs

- Models