Alpha Mask

If I have a cube in front of another cube can I use nodes to punch the foreground cube through the background one?

I’m not sure I’ve explained that very well.

I want my image to have an alpha background and to only see part of the background cube. I’ve seen threads about masks and I can make my (foreground cube) mask black or white but can my mask be alpha?

Yes, but this is a post process effect so you will not see the inside of the cube to which you apply the mask because the mask is being applied to pixel data, not to scene geometry… Here is a screen shot of one node setup that will get the job done. There are other ways to do it also, even more so in the CVS builds, though I haven’t worked that out yet.

Note that each object is on it’s own render layer. This process is much less difficult to understand if you use an image file to mask the geometry rather than trying to use scene geometry to do it. This is because you can not simply use the alpha channel from one render layer to mask another as you can with an image file. You must first invert the alpha of the layer that you want to use as a mask and then multiply the alpha of the layer to be masked by the previously mentioned inverted alpha. The color ramp has been inverted from it’s default value and is used to invert the alpha channel of the layer which you want to apply as a mask.

If you have trouble understamding all of this, don’t worry, you’re not alone (I’m probably not explaining it very well either). I don’t do this very often and I have to play with it for about 10 minutes every time. You can always prebuild these effects, group the nodes together with a name and save them to a library from which you can later append, but that will just ensure that you never understand what’s going on which in turn will severly limit your ability to create. If you want to build a library like this, use it for studdy only and then rebuild the effects by hand until you begin to comprehend what’s really going on.

Here’s the blend file from the screen shot:

http://uploader.polorix.net//files/89/Mask%20Node%20Setup.blend

If yyou just want to do this to apply over another image or movie then you won’t need render layer #3 or the alpha over node. Your rendered file will have an embeded alpha if you set it up via the combined button on the render layers tab and the RGBA button on the format tab.

Attachments


Holy cow, forget that jack-ass node set up. Fligh just showed me a trick in this post via his .blend file :

http://blenderartists.org/forum/showthread.php?p=772141#post772141

Turning on the “Env” button on the materials tab for the layer that you want to use as a mask will cut straight through any object on it’s render layer, no nodes involved. If you want geometry in the background then that will have to go on a seperate render layer and be combined in the nodes compositor via an alpha over node.

Ha ha, when I read the first post I trembled with fear, unable to comprehend the sheer complexity of the node set-up! Luckily, you followed that up with the link to the other thread where I just have to press a single button!!!

Now that’s what I’m talking about!

Many, many, many thanks!

I like the attitude your bird is displaying.