Project 5

Multiple Render Passes

Often in computer graphics, multiple render passes are required to create cool effects.

(For example, the next project uses multiple render passes to implement a reflecting mirror ^^)

In this project, we're just going to render the scene from the previous project to a texture, and then render that texture onto a plane.

Render Passes

In most graphics APIs, we have the ability to render to textures in addition to rendering to the screen. When one render is dependent on another render being finished, we call that a "render pass". In Vulkan, we also have the ability to create multiple "subpasses" per render pass, but those are more helpful when rendering the same scene from the same perspective multiple times.

In the previous project, this is what the render loop looked like:

We prerecord our draw calls for the scene, and then for each frame, we just update uniform buffer objects.

A vulkan semaphore was required to wait for a scene to be drawn to a swapchain image before being submitted to the present queue for presenting.

With multiple render passes, this is how things have changed:

We're still prerecording our draw calls, but some draw calls are recorded to a non-swapchain command buffer, and are associated with a "subscene" renderpass.

We create an additional semaphore that forces the main scene draw calls to wait for the "subscene" draw commands to finish. We can't render the plane with the texture of a 3D scene on it if we haven't rendered that subscene first!

Program controls

  • esc closes the window
  • R resets the camera position
  • Click and drag to move the camera
  • Control + Click and drag to move the light
  • Alt + Click and drag to move the subscene camera
  • Control + alt + Click and drag to move the subscene light
  • Arrow keys move the camera
  • +/- zoom in and out

Build instructions

  1. If you don't have it already, download cmake
  2. Download and install the Vulkan SDK from here: https://www.lunarg.com/vulkan-sdk/
  3. Clone the project: https://github.com/n8vm/InteractiveComputerGraphics
  4. Generate the project with CMake
  5. Build and run any targets in the project

Resources Used

C++, Visual Studio 2017, CMake, Vulkan, GLFW, GLM

Hardware

Intel HD Graphics 620, Intel Core i7 - 8500U CPU @ 4.0GHz, 16GB of memory

Nvidia GTX 1070