Alpha Mask shader for the GLSLShader module

Mon Sep 15, 2014 10:23 pm

EDIT: In Magic 1.6, the Alpha Mask is now included in the main installation (via the Mask module). I've left this tutorial here just in case anyone's curious or wants more information.
---

Magic 1.5's GLSLShader module introduces some powerful new functionality that makes it really easy to achieve cool effects.

Here's a new Alpha Mask shader I wrote pretty quickly:
Code: Select all
void main()
{
    vec2 pixelLocation = gl_FragCoord.xy / iResolution.xy;

    gl_FragColor = texture2D(iChannel0, pixelLocation) * texture2D(iChannel1, pixelLocation);
}

To explain it a little bit, basically what I'm doing is multiplying the color in the first image by the color in the second image. Even if you're not a programmer, you can see that not a lot of code is required.

To use this shader in your own projects, click here to download it:
AlphaMask.txt
(176 Bytes) Downloaded 920 times
Then just load it into the GLSLShader module, as shown here:
Image

The two inputs to the GLSLShader module (the Image module and the Video module) are multiplied together, resulting in the alpha mask effect. (I put the Starfield in the background just so you can see where the video has become transparent.)

Note that circle.png and shortCars.avi are both in the Magic sample projects folder, so you should be able to duplicate the scene exactly. Or, try it out with different inputs to the GLSLShader module and I'm sure you'll have a lot of fun playing around with it.

Any questions, please let me know! :)
Eric
Eric
Site Admin
 
Posts: 2637
Joined: Wed Apr 09, 2014 9:28 pm

Re: Alpha Mask shader for the GLSLShader module

Tue Sep 16, 2014 7:28 am

that's really great ! thanks a lot
damstraversaz
 
Posts: 151
Joined: Tue Aug 26, 2014 11:22 am

Re: Alpha Mask shader for the GLSLShader module

Tue Sep 16, 2014 7:47 pm

Hugely helpful!

Very many thanks Eric!
Terry Payman
 
Posts: 542
Joined: Sun Sep 14, 2014 8:15 am
Location: UK

Re: Alpha Mask shader for the GLSLShader module

Fri Dec 05, 2014 4:54 am

Since I think this is a pretty useful shader, I've attached it as a text file to my initial post, for quick downloading :).
Eric
Site Admin
 
Posts: 2637
Joined: Wed Apr 09, 2014 9:28 pm

Return to Tutorials, etc.

© 2019 Color & Music, LLC • This web site is mobile-friendly