How it works...

To use normal mapping in our application, we need to prepare an image, in which normal vectors are stored. We must load the image's contents, create an image, and copy the data to the image's memory. We also need to create a sampler that, along with the image, will form a combined image sampler:

 int width = 1; int height = 1; std::vector<unsigned char> image_data; if( !LoadTextureDataFromFile( "Data/Textures/normal_map.png", 4, image_data, &width, &height ) ) { return false; } InitVkDestroyer( LogicalDevice, Sampler ); InitVkDestroyer( LogicalDevice, Image ); InitVkDestroyer( LogicalDevice, ImageMemory ); InitVkDestroyer( LogicalDevice, ImageView ); if( !CreateCombinedImageSampler( PhysicalDevice, *LogicalDevice, VK_IMAGE_TYPE_2D, ...

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.