Creating a sampler
Samplers define a set of parameters that control how image data is loaded inside shaders (sampled). These parameters include address calculations (that is, wrapping or repeating), filtering (linear or nearest), or using mipmaps. To use samplers from within shaders, we first need to create them.
How to do it...
- Take a handle of a logical device and store it in a variable of type
VkDevice
namedlogical_device
. - Create a variable of type
VkSamplerCreateInfo
namedsampler_create_info
and use the following values for its members:VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO
value forsType
nullptr
value forpNext
0
value forflags
- The desired magnification and minification filtering mode (
VK_FILTER_NEAREST
orVK_FILTER_LINEAR
) formagFilter
andminFilter
- The selected mipmap filtering mode (
VK_SAMPLER_MIPMAP_MODE_NEAREST
orVK_SAMPLER_MIPMAP_MODE_LINEAR
) formipmapMode
- The selected image addressing mode for image U, V, and W coordinates outside of the
0.0 - 1.0
range (VK_SAMPLER_ADDRESS_MODE_REPEAT...