Correct blending for premultiplied alpha
Closed this issue · 3 comments
Describe the bug
The option for accepting premultiplied alpha textures currently works by applying the OBS_EFFECT_PREMULTIPLIED_ALPHA
effect. This effect internally converts premultiplied alpha to regular transparency alpha and then applies that as per OBS_EFFECT_DEFAULT
. While this produces acceptable results, it also removes the benefits usually gained by premultiplied alpha. Applying premultiplied alpha in this way makes it impossible to create additive blending effects using transparency (e.g. bloom or light effects may actually darken the background they are overlaid upon).
The image source in OBS actually applies alpha as premultiplied for some reason and can be used as a point of comparison.
To Reproduce
Load an image of a bright but very premultiplied alpha light into OBS as an image source and through Spout capture and compare the results on a bright background.
Additional context
A possible fix would be to copy the image_source_render
function and call it from win_spout_source_render
when the render mode is set to premultiplied alpha. Alternatively a new premultiplied alpha option could be added that does this while the old option is renamed to "Converted premultiplied alpha", which would avoid possibly breaking existing setups.
I can try making a PR for this, but it would be good to first know which way would be preferred.
Hi @emilianavt thanks a lot for bringing this to our attention and taking the time to investigate this properly. If you did have time to do a PR, our preference would be for the second option to maintain backwards compatibility with peoples existing setups.
Let us know if you need any help setting up the development environment. If it helps we are usually around here https://discord.gg/EqR7FYjqPs - the #spout-obs
channel would be the place to start a conversation about that. Thanks!
Thank you, with a bit of fiddling I got it set up. I've posted a PR: #39
Closed with #39