#Pipeline color blend attachment - src & dst alpha blend factor is simply being ignored

58 messages · Page 1 of 1 (latest)

wheat thicket
#

Hi all!

I've noticed that setting the src and dst alpha blending factor in VkPipelineColorBlendAttachmentState is being ignored, and alpha is passed to the framebuffer unmodified (color blending is however working as expected).

I had thought it was my error, but upon setting both alpha factors to VK_BLEND_FACTOR_ZERO (which should result in zero alpha - so fully transparent) in https://github.com/PAMinerva/LearnVulkan/ (specifically 02A-VkAlphaBlending chapter) and other tutorials, the result was the same - everything was visible as if alpha wasn't modified. The swapchain format is sRGB with an alpha channel and the fragment shader is outputting a vec4 color.

Software rendering, renderdoc and a different machine (both running linux) confirm this behavior. Therefore should I assume this is valid behavior, or am I missing a flag?

Thank you very much for any responses and your time!

GitHub

Learning Vulkan from code samples - Tutorial series - PAMinerva/LearnVulkan

modern walrus
#

did you remember to enable blending?

wheat thicket
modern walrus
#

also, just noticed it's specifically alpha

#

have you confirmed with renderdoc?

wheat thicket
#

Yep... color blending works okay, but just alpha does not

wheat thicket
modern walrus
#

and confirmed that alpha's not 0 in the texture?

wheat thicket
modern walrus
#

hmm, you're doing additive blending... that might make a difference

modern walrus
wheat thicket
modern walrus
#

so check the output texture

#

this is what happens when alpha 0 gets written to the framebuffer

#

(note the sky)

#

it rendered fine in-game, but screenshots broke

#

oh, and the background to the parts-picker

wheat thicket
#

Okay that makes sense - I can try setting the src alpha to ZERO & dst alpha to ONE and see if that does anything

modern walrus
#

right-click on the pixels in the output image

wheat thicket
#

Yeah alpha is zero

modern walrus
#

oh, right, forgot. my transparent pass uses an OIT buffer

#

yeah, thought so, so set dst to 1 to confirm whether it works

#

(I expect it does, but...)

#

why -1?... oh, right

wheat thicket
#

Ah right it is ONE (and drawing)!

modern walrus
#

normally, alpha 0 doesn't prevent a framebuffer being visible

#

it's only when that framebuffer is composited over something else that alpha kicks in

#

and then only if the compositing supports alpha blending

wheat thicket
#

Gotcha, had it been like a tiny bit larger than 0, it would have applied it?

modern walrus
#

no, just no affect

#

ie, alpha is ignored

#

the reson for the alpha blend factors is for doing multi-pass blending

#

there was a cool article on it, I'll see if I can find it

wheat thicket
#

Interesting... but why is it that when I do src=SRCALPHA, dst=ZERO, it returns the same effect as src=ONE,dst=ZERO? (And in this case the alpha of the say, gray plane shouldn't be one, right?)

modern walrus
#

because you're not using the alpha later on

wheat thicket
modern walrus
#

meaning why you saw things no matter what the output alpha was

#

and yeah, your blend settings don't use dst alpha for the color blend

wheat thicket
#

Ahhh I see, so the alpha doesn't actually change the color at all (only with color blending) - if it is scaled, it'll only ever matter for compositing (or other elements with alpha in the scene, which will be used for color blending)

modern walrus
#

if your settings did use dst alpha for color, you might have seen something

wheat thicket
#

Okay I understand now, thanks so much @modern walrus :))) much appreciated!

#

You've cleared up the misunderstanding! Thanks again :)

modern walrus
#

glad I could help

#

looking for that pdf on compositing

wheat thicket
modern walrus
#

(hmm, and is that Duff as in Duff's device?)

#

@wheat thicket yeah, that's the one I was thinking of

wheat thicket
modern walrus
#

I'm glad I found it: I'd lost the pdf and coudln't remember how I found it the first time round

#

there happened to be a link on a wikipedia page 🙂

wheat thicket
#

Ohhh I see. It's very helpful. Thanks for going through the trouble :)