Is it possible to make colors of text opposite of background?

gianmarco2712

New Member
I want to make an effect for text that makes text's color opposite of color, like this:
1701483304907.png


As you may probably see, the text is the opposite color of the background.
How can I achieve this effect?
 

AaronD

Active Member
You might play with different settings of this (right-click the source), and different colors of the text to make the selected option do different things:
1701527071065.png
 

AaronD

Active Member
This does set it to the opposite color, but not the opposite color of the background, just the object's opposite color
There are 7 different options there, at least for me. And the entire range of colors to feed it. The text color in this case is no longer a color per se, but a modifier for the selected option to play with.

It makes more sense if you convert the visuals to math, play with the math, then convert the result back to visuals.
 

upgradeQ

Member
Create scene_x; Add text source to scene_x. Do not change color, if it is not white, set it to white color #FFFFFF.
Create scene_y; Add background image. Add scene_x to scene_y. scene_x should be at the top of the in the sources list. Set scene_x "Blending Mode" - "Darken".
Create scene_z; Add background image. Add scene_y to scene_z. scene_y should be at the top of the in the sources list. Add an invert color shader as a filter to scene_y, use obs-shaderfilter plugin and this code as "User-defined shader".
C-like:
float4 mainImage(VertData v_in) : TARGET
{
  float4 i = image.Sample(textureSampler, v_in.uv);
  i.rgb = 1 - i.rgb;
  return i;
}
P.S There are subtle graphical artefacts due to the way alpha blending works in OBS Studio 30.0.0, see this issue for details(not fixed).
 
Last edited:

upgradeQ

Member
An update to the previous post, with the latest Advanced Masks plugin I found that you don't get graphic artifacts, i.e. if you add scene_y to scene_z it blends correctly and has no grey pixels when no shader effects are applied, basically you get the same image.

Create scene_x, add text/or other scene items masks, color does not matter.
Create scene_y, create a group inside scene_y, add your target source inside this group.
Apply the "Advanced Mask" filter to this group. Set the following settings : Mask Effect - Alpha Mask, Mask Type - Source, Source - scene_x, leave rest as default.
Then you can apply "User-defined shader" to this group.
Create scene_z, add scene_y, add your target source, you can use an existing one because the filter applied to it is set to the group scene item.
 
Top