Generating textures in Vulkan using compute shaders
We learned how to use basic compute shaders earlier in this chapter, in the Implementing instanced meshes with compute shaders recipe. It is time to go through a few examples of how to use them. Let’s start with some basic procedural texture generation. In this recipe, we implement a small program to display animated textures whose texel values are calculated in real time inside our custom compute shader. To add even more value to this recipe, we will port a GLSL shader from https://www.shadertoy.com to our Vulkan compute shader.
Getting ready
The compute pipeline creation code and Vulkan application initialization are the same as in the Implementing instanced meshes with compute shaders recipe. Make sure you read it before proceeding further. To use and display the generated texture, we need a textured full-screen quad renderer. Its GLSL source code can be found in data/shaders/Quad.vert
and data/shaders/Quad.frag...