Preparing a render pass and a framebuffer with color and depth attachments
Rendering a 3D scene usually involves not only a color attachment, but also a depth attachment used for depth testing (we want further objects to be occluded by the objects closer to the camera).
In this sample recipe, we will see how to create images for color and depth data and a render pass with a single subpass that renders into color and depth attachments. We will also create a framebuffer that will use both images for the render pass attachments.
Getting ready
As in earlier recipes from this chapter, in this recipe we will use a custom structure of type SubpassParameters
(refer to the Specifying subpass descriptions recipe).
How to do it...
- Create a 2D image and image view for it with a
VK_FORMAT_R8G8B8A8_UNORM
format,VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT
usage and aVK_IMAGE_ASPECT_COLOR_BIT
aspect. Choose the rest of the image's parameters. Store the created handles in variables of type...