Setting blend constants states dynamically
Blending is a process that mixes a color stored in a given attachment with a color of a processed fragment. It is often used to simulate transparent objects.
There are multiple ways in which a fragment's color and a color stored in an attachment can be combined--for the blending, we specify factors (weights) and operations, which generate the final color. It is also possible that an additional, constant color is used by these calculations. During the pipeline creation, we can specify that components of the constant color are provided dynamically. In such a case, we set them with a function recorded in a command buffer.
How to do it...
- Take the handle of a command buffer and use it to initialize a variable of type
VkCommandBuffer
namedcommand_buffer
. - Create a variable of type
std::array<float, 4>
namedblend_constants
. In the array's four elements, store the red, green, blue, and alpha components of the constant color used during the blending...