Previous topicNext topic

"Add Black Background" option

Suggestions for new features for Magic.
Post Reply
sachismo
Posts: 7
Joined: Sat Jan 10, 2015 9:17 pm

"Add Black Background" option

Post by sachismo »

Hi,

I use Magic a lot for sending visuals directly to LED strips through Processing.

Processing has good libraries for both spout and syphon, but they have a quirky behavior if they receive video with a transparent background. They will have trails and get stuck because all the pixels do not update with each frame, it only updates the pixels that change.

You can fix this in the Processing sketches by adding a black background to each frame, but this also dulls the entire signal for some reason. Dim images will no longer show up.

The fix in Magic I've found is to always have a black polygon covering the whole bottom layer. This way everything comes up as it should.

Resolume has a simple checkbox for each output to add a black background. This fixes things the same way without having to add an extra layer.

So I figured this may be an easy thing to add to Magic as well so that things can work easier right of the gate without having to add a workaround.

A small issue, but one that also should be easy to implement! :)
Sadler
Posts: 1139
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: "Add Black Background" option

Post by Sadler »

Use this GLShader to remove the alpha:

Code: Select all

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
	vec2 uv = fragCoord.xy / iResolution.xy;
    vec4 tex = texture(iChannel0,uv);
	fragColor = vec4(tex.xyz, 1.0);
}
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: "Add Black Background" option

Post by Magic »

So I figured this may be an easy thing to add to Magic as well so that things can work easier right of the gate without having to add a workaround.
Yup that sounds easy enough :).
sachismo
Posts: 7
Joined: Sat Jan 10, 2015 9:17 pm

Re: "Add Black Background" option

Post by sachismo »

Thanks both for the responses!

Question for Sadler: I'm still a little confused on implementing your fix. But I'd like to try it.. Where do you place that function?
Sadler
Posts: 1139
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: "Add Black Background" option

Post by Sadler »

Save the code into a text file (e.g. RemoveAlpha.txt) and load the text file into the GLShader module.
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: "Add Black Background" option

Post by Magic »

Sadler's suggestion definitely works, though your black polygon idea is also perfectly reasonable (and may be slightly faster).
Post Reply