Source Blending Modes

jw0z

New Member
Hi All,

I've had an attempt at implementing blending modes for sources, which has been previously requested in these two threads:

I've implemented it in a way that makes use of the existing blending state set up for compositing a source texture onto the scene, so unfortunately it's not a 'plugin', but is effectively 'free' from a performance point of view (for sources that were already being rendered to their own texture). As such, I was somewhat limited to implementing blending modes which are representable by specific combinations of src/dst blend factors & blend ops - the list of implemented blending modes is:
  • Normal
  • Additive
  • Subtractive
  • Screen
  • Multiply
  • Lighten
  • Darken (works incorrectly for transparent images - but a workaround could be to re-export the transparent image with a white background.)
I've skipped some of the more esoteric ones that are possible with the blend factors / blend ops, such as difference/reverse-subtract and divide, but I can add them if they are of use to anyone. Some of the more complex blending modes such as 'soft-light', 'hard-light', and 'overlay', could only be implemented if this feature were to be implemented as a final shader pass on the source (similar to how scale filtering is handled currently?)

Here are some examples (for comparison to the blending modes defined here: https://www.w3.org/TR/compositing/#blendingseparable):
normal_blending.pngadditive_blending.pngsubtractive_blending.pngscreen_blending.pngmultiply_blending.pnglighten_blending.pngdarken_blending.pngdarken_blending_fix.png

So far I've only tested this on macOS, so I've been unable to test the d3d11 changes I've made. If anyone is willing to test, then I've put the changes here:
https://github.com/jw0z96/obs-studio/tree/source-blending-modes

If anyone has any advice for how these changes could be implemented as a plugin, rather than as changes to obs-studio's rendering backend, then I'm open to suggestions :)

Thanks!
 

jw0z

New Member
Hello! I'm new user, but i really need this functionality :D How can I test it on windows?
Hello!

Unfortunately, since this is not a plugin, you'll need to recompile obs-studio from source - the instructions for doing so are here: https://github.com/obsproject/obs-studio/wiki/Install-Instructions#windows-build-directions

You'll also need to make sure you compile from the fork & branch I've listed in the original post - you can do this by replacing the `git clone` step with:
git clone --recursive https://github.com/jw0z96/obs-studio.git

...and then checkout the branch with:
git checkout source-blending-modes

Please note that I've not tested these changes on Windows, as I don't have access to a d3d11 capable machine currently.

Good luck!
 

Archon816

New Member
Hello!

Unfortunately, since this is not a plugin, you'll need to recompile obs-studio from source - the instructions for doing so are here: https://github.com/obsproject/obs-studio/wiki/Install-Instructions#windows-build-directions

You'll also need to make sure you compile from the fork & branch I've listed in the original post - you can do this by replacing the `git clone` step with:
git clone --recursive https://github.com/jw0z96/obs-studio.git

...and then checkout the branch with:
git checkout source-blending-modes

Please note that I've not tested these changes on Windows, as I don't have access to a d3d11 capable machine currently.

Good luck!
Hmm, can someone do it for me?
 
Hello. I got brought here because I suggested ideas that would help make Anaglyph 3D easier.

Am I correct to assume that if I use a screen blending mode or additive blending mode that any pixel where red plus Cyan are together in the same physical space in an overlay would result in white? Because if it is, then that's exactly what I want. I got a black and red video as the left eye and a black and cyan video as the right eye.

Is that a setting on obs currently for the current obs?

By the way you said it works on Macintosh versions which I just so happen to have.

May I have instructions on how to "turn on" screen blend mode / additive blend mode on OBS for Mac?

By the way, do you know of a cheap VGA "screen blend curcuit" which takes 2 very slightly out of sync eyes and syncs then live (with a less than 1ms delay, I'm planning on streaming Virtual Boy, and the closest I got is with a passive Y cable of one screen slightly scrolling while the other is stable.

I don't have much money, and my video starts in VGA, which I though would be easiest to blend the red of left with the green and blue of the right. What should I search for on Ebay?
 

jw0z

New Member
Hello. I got brought here because I suggested ideas that would help make Anaglyph 3D easier.

Am I correct to assume that if I use a screen blending mode or additive blending mode that any pixel where red plus Cyan are together in the same physical space in an overlay would result in white? Because if it is, then that's exactly what I want. I got a black and red video as the left eye and a black and cyan video as the right eye.

Is that a setting on obs currently for the current obs?

By the way you said it works on Macintosh versions which I just so happen to have.

May I have instructions on how to "turn on" screen blend mode / additive blend mode on OBS for Mac?

By the way, do you know of a cheap VGA "screen blend curcuit" which takes 2 very slightly out of sync eyes and syncs then live (with a less than 1ms delay, I'm planning on streaming Virtual Boy, and the closest I got is with a passive Y cable of one screen slightly scrolling while the other is stable.

I don't have much money, and my video starts in VGA, which I though would be easiest to blend the red of left with the green and blue of the right. What should I search for on Ebay?
Yes - with an additive blending mode, the red and cyan pixels in your scenario would equal white once blended. (Red (1,0,0) + Cyan (0,1,1) = White (1,1,1))

Since this is not a plugin, you'll need to recompile OBS from source in order to test the changes I've implemented - a guide on doing so is here: https://github.com/obsproject/obs-studio/wiki/Install-Instructions#macos-build-directions

...and as above, you'll need to recompile from the branch with my changes:
git clone --recursive https://github.com/jw0z96/obs-studio.git;
git checkout source-blending-modes


If you've not compiled software from source before, this may be more effort than it's worth, but good luck! Perhaps if this feature is deemed useful enough / suitable for integrating into OBS, I could submit a pull request.
 
Top