Setting depth bias states dynamically
When rasterization is enabled, each fragment that is generated during this process has its own coordinates (position on screen) and a depth value (distance from the camera). Depth value is used for the depth test, allowing for some opaque objects to cover other objects.
Enabling depth bias allows us to modify the fragment's calculated depth value. We can provide parameters for biasing a fragment's depth during the pipeline creation. But when depth bias is specified as one of the dynamic states, we do it through a function call.
How to do it...
- Take the handle of a command buffer that is being recorded. Use the handle to initialize a variable of type
VkCommandBuffer
namedcommand_buffer
. - Store the value for the constant offset added to the fragment's depth in a variable of type
float
namedconstant_factor
. - Create a variable of type
float
namedclamp
. Use it to provide the maximal (or minimal) depth bias that can be applied to an unmodified depth. - Prepare a...