image mask/blend broken as of v27

msx2plus

New Member
hey there - i'm aware linear color blending change from version 27 onwards, but this seems to have rendered the image mask/blend completely useless. this is regardless of the file format being used on the mask/blend. when set to multiply it always renders lighter than intended, and when set to add on black it also gets washed out. a perfect multiply/add are therefore not possible any more.

yes, i have saved the images properly as noted here https://github.com/obsproject/obs-studio/wiki/Linear-Color-Blending - this happens regardless of color format, image format.

attached is a capture of a gif beside a white color source with a gif set to multiply on top of it. it displays as intended in all versions up to 27.0
 

Attachments

  • test.gif
    test.gif
    857 KB · Views: 197
Last edited:

Suslik V

Active Member
As workaround, you can add filter Color Correction with the Gamma: -1.25 in the end of the processing to emulate the previous behavior of OBS (to make the resulting image a bit darker).

For example, from the given description I don't understand what is "broken" here. The black remains black, white - white, both Add/Multiply equals on dark/white backgrounds.

Let's clarify it!
Do you want to say that when (16, 16, 16) RGB color Add_ed to the (0, 0, 0) background OBS renders the result as the (71, 71, 71) ? Is this what you are complaining about? So, Image Mask/Blend filter Type of blending: Multiply / Addition / Subtraction goes wrong here, yeah?
 

msx2plus

New Member
what i mean is that the previous method is how multiply works everywhere - if i were to multiply 35,35,35 onto 255,255,255 i would get a block of 35,35,35 - this is true in every application (photoshop, clip studio, gimp, etc) except for OBS. this makes designing masks that match other graphical elements pretty bad, as i have to compensate with color correction every time i use them. i don't feel like this new behavior is correct - we should at least have an option to revert to the old math, the math used by just about every graphic authoring tool.

to be clear, this is not about the images themselves or how they are rendered, it is the image mask/blend filter. attached is another example - a tree, and then the tree multiplied onto a white surface. they should look identical (and do when multiplied in any other application), and no amount of gamma adjustment comes up with a perfect match.
 

Attachments

  • Clipboard01.png
    Clipboard01.png
    106.3 KB · Views: 36

Suslik V

Active Member
Man, the path is long... There is huge mess of premultiplied alpha blending and linearization of RGB in people's heads. Programmer's of the OBS said that fixing all the rendering bugs will take a lot of time and needs a lot of efforts. ( https://github.com/obsproject/obs-studio/issues/3055#issuecomment-641752308 ).

For example, getting the premultiplied alpha image from the PNG is not that simple. Because you need to: 1) get linear RGB (don't touch alpha); 2) multiply linear RGB to alpha value; 3) apply gamma back to the RGB only (not to alpha). Now you can use this image for GPUs processing... So, it is hard to find the simple fix and not to ruin everything else that already was written bugged.
The related issue (about the Image Mask/Blend filter Type of blending: Multiply / Addition / Subtraction) now is here:

Side note.
Blending has better explanation here:
https://shawnhargreaves.com/blog/premultiplied-alpha.html (despite the author uses integer [0;255] values in examples, the math itself was done for normalized [0.0; 1.0] float).
 
Top