Implementing Blend Modes Between Sources

CrashKoeck

New Member
I'm new to scripting for OBS (just started today) I'm trying to figure out how to apply blend modes between sources within a scene. The specific blend mode I'm trying to accomplish is screen blend. I am able to take an image from my hard drive and apply it to a source or scene and get the proper blend effect, but I want to be able to select a scene and choose 1 source within that scene as the base and another source as the one that will have the blend effect applied to it. Or, better yet, have it so that a filter is applied to a source you want to apply the blend mode to and it blends with the layers below it in the list, just like in Photoshop.

This is what I have that works for the screen blend mode on a source/scene using a static image from my hard drive:
Code:
uniform texture2d image_from_hdd;

float4 mainImage(VertData v_in) : TARGET
{
    float4 blend = image_from_hdd.Sample(textureSampler, v_in.uv);
    float4 base = image.Sample(textureSampler, v_in.uv);
    return (1 - (1 - base) * (1 - blend));
}

What I would love to be able to do would be something like this:
Code:
float4 mainImage(VertData v_in) : TARGET
{
    float4 blend = source_001.Sample(textureSampler, v_in.uv);
    float4 base = source_002.Sample(textureSampler, v_in.uv);
    return (1 - (1 - base) * (1 - blend));
}

With the structure within OBS looking something like:
Code:
main_scene
|---source_001
|---source_002

I know the code of what I'm looking for above is just a Frankenstein thing that doesn't make sense, but hopefully it conveys what I'm trying to accomplish. If anyone has any ideas, I'd really appreciate feedback.

Thanks!
 

wafflescience

New Member
I started looking for a tool for this today and your post is the only thing I found. I'm not an experienced enough coder to feel confident building a plugin myself, but I know a way it could be made. the program GIMP has most common blending modes including screen, so I'm going to pul the source code and try to figure out how to port it.
 
Top