Custom spot color post-processing
An Apex custom post process step that operates on spot components.
A CCustomSpotPostProcessSpec
represents a custom post process step that operates on the spot components of a render using an externally supplied Vulkan fragment shaders, (optional) textures and (optional) push constants.
Currently, Apex will invoke this step with spot components provided four at a time.
This step must provide a
CShaderParams
for each invocation that this represents. For example, if a render has nine retained spot colors then threeCShaderParams
must be provided. The first for the first four spots, the second for the next four spots, and the third for the last remaining spot. The same shader can be used for all three, if appropriate.
The shader is ultimately invoked over the entire image. However, Apex may break rendering into multiple tiles, in which case the draw operation may occur multiple times.
The input to each shader is a four-component UNORM
image, with R
representing the first spot in the invocation, G
for the second, B
for the third, and A
for the fourth.
The same is true for the output.
ℹ️ Please note that all the input and output images are in additive form. That is, the components are stored with 0.0 being 100% ink and 1.0 being 0% ink. This mirrors the PDF transparency compositing methods. So take care when interpreting these colors in the shader.
ℹ️ Please also note that if the current render is retaining alpha, then the alpha has not yet been applied to the spot values. If alpha is being retained, then the alpha image will be supplied to the shader as the next input after the spot input.
Push constants may be provided to the shader. However, in addition to any supplied push constants, Apex will push an additional two integer values after these push constants representing the top-left offset of the tile being rendered. This, in conjunction with the GLSL gl\_FragCoord
variable, allows the shader to discover the current coordinate on the final page render, should this be needed.
The size of the push constant buffer is limited, and may differ from GPU to GPU. Vulkan guarantees a minimum of 128 bytes, but remember that Apex will push eight additional bytes for tile coordinates, and therefore the minimum guarantee is 120 bytes. In practice, most GPUs will allow significantly more.
Please see: https://vulkan.gpuinfo.org/displaydevicelimit.php?name=maxPushConstantsSize for supported sizes for current GPUs.
The shader and textures may be created by IApexRenderer::createFragmentShader()
and IApexRenderer::uploadImage()
.
Any textures are provided to the shader after the input images.
For example, consider a custom step where:
alpha is being retained
two textures are provided
a single floating point value for a push constant is provided
The shader would have a structure such as the following: