NOTE: I say glistening to not be confused with bloom, glow or emissive, which are well defined blending techniques.
I have emulated 2D lighting by simply blending an offscreen image over the final image. What I get is actually what should be expected, and it looks correct:
But I want to blending that looks as in Halfway (this is a snippet of a screenshot):
How can I achieve that hazy blooming glow effect with just blending?
This is what I've tried so far:
Light quads are rendered to an offscreen image with these blending settings:
srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
dstColorBlendFactor = VK_BLEND_FACTOR_ONE;
colorBlendOp = VK_BLEND_OP_ADD;
srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
alphaBlendOp = VK_BLEND_OP_ADD;
If it's relevant, the offscreen buffer has the same format as the final image, which is on this dev machine VK_FORMAT_R8G8B8A8_SRGB
(but it may change on other client machines).
The offscreen image is then overlayed on the final image with this shader:
outColor = inAmbientLight + texture(lightImageSampler, inUV);
The pipeline for this step has following blending settings:
srcColorBlendFactor = VK_BLEND_FACTOR_DST_COLOR;
dstColorBlendFactor = VK_BLEND_FACTOR_ZERO;
colorBlendOp = VK_BLEND_OP_ADD;
srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
alphaBlendOp = VK_BLEND_OP_ADD;
Also, I wonder, are if()
and discard
still very expensive in shaders? I've seen some hardlight shaders which use if()
. I'd rather avoid these.
I've also tried to use the VK_BLEND_OP_HARDLIGHT_EXT
, but I can't make the VK_EXT_blend_operation_advanced
extension work. Is this maybe the right way to go?
Also, do I maybe need HDR (or 16 bit color channels)? Note that I don't want to use a bloom/glow shader. The result should be achievable by simply "emulating" blur through simple blending, but with "overexposure", as if the final overlay would "overdrive" colors beyond the 0-255 range and thus boost into white glistening lights.
I'm okay with pointers to a tutorial or just terms to search, I don't expect others to solve my problems. I just need a nudge in the right direction! Thanks for every bit of help!
Corrections such as better title or tags are also welcome.