Why does mixing black and white at 50% opacity not produce 50% brightness grey?

notquitehadouke

New Member
Hello! I was trying to do an effect in OBS (motion extraction) when I stumbled across this
1723912362486.png

I have two color sources, one pure white and one pure black
1723912390432.png

And the black one has a color correction filter at 50% opacity
So I would expect them to average out and give me the color grey at 50% brightness, but instead it gives me #BCBCBC (73%), which is very annoying when trying to average two colors, and I don't know how to make it not.
It also does the same thing when you do it with the white on top of the black.
 
Last edited:

fkeb

New Member
hi, i tried to replicate this effect in OBS as well. it's infuriating, there seems to be some issues regarding colours. what i did:

you need to right-click on the upper-layer source and select blending method: sRGB off. also use 35.5XX% opacity (obviously there is an error). it won't be perfect though. this works for me, using two identical webcam inputs and i also put a delay and inversion on one of the sources. (bright red colours seem to be an issue though, so i guess there is some wrong math there...)
 

AaronD

Active Member
Hello! I was trying to do an effect in OBS (motion extraction) when I stumbled across this
View attachment 106965
I have two color sources, one pure white and one pure black
View attachment 106966
And the black one has a color correction filter at 50% opacity
So I would expect them to average out and give me the color grey at 50% brightness, but instead it gives me #BCBCBC (73%), which is very annoying when trying to average two colors, and I don't know how to make it not.
It also does the same thing when you do it with the white on top of the black.
The darkest part of your screenshot is nowhere near black. Might that have something to do with it?
 

fkeb

New Member
The darkest part of your screenshot is nowhere near black. Might that have something to do with it?
well, he just wrote, that the black layer is at 50% opacity, so it should be #808080 because it is on a white background.
 

Suslik V

Active Member
@fkeb here is some old remark I wrote at the time when filters were moved to linear math (grammar was poor... same as today):
https://github.com/obsproject/obs-studio/issues/5048#issuecomment-889840868 said:
...users don't understand that opacity slider/spinner is no longer linear when you look to it from the human's point of view. For example, when user sets 0.5 opacity it (filter) "should" do the gamma applied middle not the true middle. Because we looking at the screen by our own eyes and constantly comparing picture to the "feel" of the 0.5. So, in my opinion, some UI sliders/spinners should not go linear as they do now.
About code changes itself (linear math):

Other thing is the Filter's preview. There is bug in it, so you need to provide exact configuration of the scenes and filters, otherwise it will be impossible to say is it just preview bug or it is OK and you have "mistaken" in perception of the slider position. (The issue with the Filter's preview partially described in: https://obsproject.com/forum/threads/video-has-lower-opacity-with-green-screen.170323/post-627073 - observable "result" of the blending depends on UI theme of OBS)
 
Top