You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Blending mode Darken makes transparency solid black #6591
The alpha-correct versions of darken/lighten require an extra draw because they can't be expressed with a standard fixed-function blend. It's doable, but it's not just swapping in the correct the blend enum values.
It doesn’t only happen with Darken, Normal is also affected by this. I have a scene that contains a browser source with transparent background color (via custom CSS) and in older versions (pre-27, I think) that transparency was applied as expected when the scene was included in other scenes but since 27 (again, I think it was 27) I have to choose blend mode “Screen” to get the same effect.
This ticket is about a blend mode situation that OBS doesn't fully support. Your issue is likely that OBS had changed alpha blending to be performed linearly, which web browsers do not.
If you are on OBS 28, you can get "web" blending behavior by selecting Blending Method -> SRGB Off from the source context menu. If you need more help, this ticket probably isn't the place for it.
I've not given it too much thought, but you'd probably need to re-implement the blending equations in a fragment shader to overcome the limitations of trying to express this functionality with fixed-function blending - which would require an extra draw, and for both the source and the scene/background to be available for texture sampling. The latter would likely require a non-trivial rework of the scene rendering pipeline in order for the previously rendered parts of the background to be rendered to texture.
It looks like render to texture is already enabled for sources using non-default blending, but I'm not sure how you'd achieve the same for the scene/background.
cc @jpark37 In case they have any suggestions for how this could be achieved
It's pretty much what you would think. Need to modify obs-scene.c and friends to do the extra draw with a custom shader, perhaps modifying default.effect to add a new technique, and tweaking the blend state. It's more work than I want to bite off to implement and regression test for a feature that I'm not personally interested in on a project that's just a hobby for me.
I've not given it too much thought, but you'd probably need to re-implement the blending equations in a fragment shader to overcome the limitations of trying to express this functionality with fixed-function blending - which would require an extra draw, and for both the source and the scene/background to be available for texture sampling. The latter would likely require a non-trivial rework of the scene rendering pipeline in order for the previously rendered parts of the background to be rendered to texture.
It looks like render to texture is already enabled for sources using non-default blending, but I'm not sure how you'd achieve the same for the scene/background.
It's starting to sound like this is, for better or worse, "working as intended/designed" and that would make this a feature request rather than a bug.
I'd say there's still a bug here, given that users expect behaviour comparable to photoshop etc. when using the 'darken' blending mode on sources with transparency, but it's probably "working as expected" given the limitations of the current implementation.
Implementing blending in the way discussed in this thread makes the implementation of this feature a lot more complex (in comparison to my original PR, which was pretty tiny), and as far as i'm aware would only really benefit a narrow set of use cases.
it's probably "working as expected" given the limitations of the current implementation.
If it is working as designed/implemented, and I understand that that is the case, then I'm going to close this. It is unfortunate that user expectations, when compared to how this works in web browsers or other software, does not align with the functionality in OBS, but OBS is not a web browser. If someone wants to expand the implementation, they are free to do so and open a Pull Request.
Activity
jpark37 commentedon Jun 5, 2022
The alpha-correct versions of darken/lighten require an extra draw because they can't be expressed with a standard fixed-function blend. It's doable, but it's not just swapping in the correct the blend enum values.
From https://www.w3.org/TR/SVGCompositing/
Sca: Premultiplied source color component
Sa: Source opacity component
Dca: Premultiplied destination color component
Da: Destination opacity component
Darken
Ligthen
Bombe commentedon Oct 15, 2022
It doesn’t only happen with Darken, Normal is also affected by this. I have a scene that contains a browser source with transparent background color (via custom CSS) and in older versions (pre-27, I think) that transparency was applied as expected when the scene was included in other scenes but since 27 (again, I think it was 27) I have to choose blend mode “Screen” to get the same effect.
jpark37 commentedon Oct 16, 2022
This ticket is about a blend mode situation that OBS doesn't fully support. Your issue is likely that OBS had changed alpha blending to be performed linearly, which web browsers do not.
If you are on OBS 28, you can get "web" blending behavior by selecting Blending Method -> SRGB Off from the source context menu. If you need more help, this ticket probably isn't the place for it.
RytoEX commentedon Jan 27, 2023
cc @jw0z96 since they implemented the feature.
As far as I understand it, this would require implementing an extra render to texture to make this work as desired, and that work is non-trivial.
jw0z96 commentedon Feb 4, 2023
I've not given it too much thought, but you'd probably need to re-implement the blending equations in a fragment shader to overcome the limitations of trying to express this functionality with fixed-function blending - which would require an extra draw, and for both the source and the scene/background to be available for texture sampling. The latter would likely require a non-trivial rework of the scene rendering pipeline in order for the previously rendered parts of the background to be rendered to texture.
It looks like render to texture is already enabled for sources using non-default blending, but I'm not sure how you'd achieve the same for the scene/background.
cc @jpark37 In case they have any suggestions for how this could be achieved
jpark37 commentedon Feb 4, 2023
It's pretty much what you would think. Need to modify obs-scene.c and friends to do the extra draw with a custom shader, perhaps modifying default.effect to add a new technique, and tweaking the blend state. It's more work than I want to bite off to implement and regression test for a feature that I'm not personally interested in on a project that's just a hobby for me.
RytoEX commentedon Feb 6, 2023
It's starting to sound like this is, for better or worse, "working as intended/designed" and that would make this a feature request rather than a bug.
jw0z96 commentedon Feb 6, 2023
I'd say there's still a bug here, given that users expect behaviour comparable to photoshop etc. when using the 'darken' blending mode on sources with transparency, but it's probably "working as expected" given the limitations of the current implementation.
Implementing blending in the way discussed in this thread makes the implementation of this feature a lot more complex (in comparison to my original PR, which was pretty tiny), and as far as i'm aware would only really benefit a narrow set of use cases.
RytoEX commentedon Feb 13, 2023
If it is working as designed/implemented, and I understand that that is the case, then I'm going to close this. It is unfortunate that user expectations, when compared to how this works in web browsers or other software, does not align with the functionality in OBS, but OBS is not a web browser. If someone wants to expand the implementation, they are free to do so and open a Pull Request.
SuslikV commentedon Mar 1, 2023
Better to hide the feature from the user, than leave it faulty.
Few thoughts below.
The "Dark" - is only effect that has impact on transparency.
You can always add feature later.
q:
answ: