Alpha Mask shader for the GLSLShader module
Posted: 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:
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: Then just load it into the GLSLShader module, as shown here:
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
---
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 use this shader in your own projects, click here to download it: Then just load it into the GLSLShader module, as shown here:
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