How it works...

We start this recipe by loading and preparing buffers for two models: the first being the one simulating our main scene (reflective/refractive model); and second being used to draw the environment itself (a skybox). We need to copy vertex data using staging buffers to both vertex buffers.

Next, we need to create a cubemap. We do this by creating a combined image sampler. The image must be of a 2D type, must have six array layers, and must support VK_IMAGE_USAGE_SAMPLED_BIT and VK_IMAGE_USAGE_TRANSFER_DST_BIT usages. The format of the image depends on the case, but usually a VK_FORMAT_R8G8B8A8_UNORM would be a good choice. The created sampler must use a VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE addressing mode for all sampling ...

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.