Hi All,
I've had an attempt at implementing blending modes for sources, which has been previously requested in these two threads:
obsproject.com
ideas.obsproject.com
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:
Here are some examples (for comparison to the blending modes defined here: https://www.w3.org/TR/compositing/#blendingseparable):
![normal_blending.png normal_blending.png](https://obsproject.com/forum/data/attachments/75/75068-a3f7e74191ef1c419531336749c0d6f4.jpg)
![additive_blending.png additive_blending.png](https://obsproject.com/forum/data/attachments/75/75069-4fab585d62c27e9e691481ed2b8cc67a.jpg)
![subtractive_blending.png subtractive_blending.png](https://obsproject.com/forum/data/attachments/75/75070-24da373a81c3cd5dffea934d9c7da8e6.jpg)
![screen_blending.png screen_blending.png](https://obsproject.com/forum/data/attachments/75/75071-fa639e0b656f95318f12563f103ddaa9.jpg)
![multiply_blending.png multiply_blending.png](https://obsproject.com/forum/data/attachments/75/75072-32e9759fd314a0b241dbc84a1d460620.jpg)
![lighten_blending.png lighten_blending.png](https://obsproject.com/forum/data/attachments/75/75073-e927acc7f8063e87ac21770c2bbef505.jpg)
![darken_blending.png darken_blending.png](https://obsproject.com/forum/data/attachments/75/75074-67206f64b7c5bf292afc548beb98ae8d.jpg)
![darken_blending_fix.png darken_blending_fix.png](https://obsproject.com/forum/data/attachments/75/75076-b05175e4ddea24cc1872ecacba47da37.jpg)
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!
I've had an attempt at implementing blending modes for sources, which has been previously requested in these two threads:
Blend modes for sources
I searched around the web and these forums a bit but couldn't find any mentions of this. Seems like something that might've been mentioned or requested before, but I don't see anything. For anyone who uses Photoshop, blend modes will probably be familiar. The wikipedia page for it explains it...
![ideas.obsproject.com](https://ideas.obsproject.com/static/images/logos/c4ca4238a0b923820dcc509a6f75849b.png?size=200)
Add blend modes for dynamic sources · OBS Studio Ideas and Suggestions
Adding this option will give a lot of new creative possibilities to OBS users. Although such an option already exists as an Image Mask Filter (it has
![ideas.obsproject.com](https://ideas.obsproject.com/static/favicon/logos/c4ca4238a0b923820dcc509a6f75849b.png?size=64)
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.)
Here are some examples (for comparison to the blending modes defined here: https://www.w3.org/TR/compositing/#blendingseparable):
![normal_blending.png normal_blending.png](https://obsproject.com/forum/data/attachments/75/75068-a3f7e74191ef1c419531336749c0d6f4.jpg)
![additive_blending.png additive_blending.png](https://obsproject.com/forum/data/attachments/75/75069-4fab585d62c27e9e691481ed2b8cc67a.jpg)
![subtractive_blending.png subtractive_blending.png](https://obsproject.com/forum/data/attachments/75/75070-24da373a81c3cd5dffea934d9c7da8e6.jpg)
![screen_blending.png screen_blending.png](https://obsproject.com/forum/data/attachments/75/75071-fa639e0b656f95318f12563f103ddaa9.jpg)
![multiply_blending.png multiply_blending.png](https://obsproject.com/forum/data/attachments/75/75072-32e9759fd314a0b241dbc84a1d460620.jpg)
![lighten_blending.png lighten_blending.png](https://obsproject.com/forum/data/attachments/75/75073-e927acc7f8063e87ac21770c2bbef505.jpg)
![darken_blending.png darken_blending.png](https://obsproject.com/forum/data/attachments/75/75074-67206f64b7c5bf292afc548beb98ae8d.jpg)
![darken_blending_fix.png darken_blending_fix.png](https://obsproject.com/forum/data/attachments/75/75076-b05175e4ddea24cc1872ecacba47da37.jpg)
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!