Skip to main content
Gray, rocky wall

Croissant - Real-Time Vulkan Renderer

Completed
ComputerGraphics Vulkan C++
altaltalt

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.

Render Samples

alt


s
alt
alt
alt
alt
alt

Features

  • 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.

Code 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 fro graphics software.
  • ImGui: GUI.
  • stb_image: Image encoding/decoding.
  • Tracy: Frame profiler.
  • Vulkan-Loader
  • Vulkan-Tools: Validation Layers.

Render Graph

alt

alt

Usage

/* 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

InputAction
RMB dragRotate Camera
Scroll wheelZoom 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

CompilerOperating SystemArchitecture
GCC 9.4.0Linux Ubuntu 20.04.4 with kernel 5.8.0-53x64

References

Included Assets

The following assets are bundled with the project:

HDRs

Models