How it works...

To render a skybox we need to load or prepare a geometry forming a cube. Only positions are required as they can also be used for texture coordinates.

Next, we load six cubemap images and create a combined image sampler with a cube image view:

 InitVkDestroyer( LogicalDevice, CubemapImage ); InitVkDestroyer( LogicalDevice, CubemapImageMemory ); InitVkDestroyer( LogicalDevice, CubemapImageView ); InitVkDestroyer( LogicalDevice, CubemapSampler ); if( !CreateCombinedImageSampler( PhysicalDevice, *LogicalDevice, VK_IMAGE_TYPE_2D, VK_FORMAT_R8G8B8A8_UNORM, { 1024, 1024, 1 }, 1, 6, VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, VK_IMAGE_VIEW_TYPE_CUBE, VK_IMAGE_ASPECT_COLOR_BIT, VK_FILTER_LINEAR, VK_FILTER_LINEAR, ...

Get Vulkan Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.