Multiply shader, masking

Hi there,

I’ve been playing with cutout shaders and additive and multiply shaders a lot recently, and just wondered if the following is possible / makes sense.

To my understanding, additive literally adds the color of the pixel to whatever it is over, multiply similarly “multiplies”.

With multiply, a coloured pixel multiplied by black will equal black, and multiplied by white will equal itself, right?
My question is, what happens if a pixel is multiplied by a pixel that is rgba of (0,0,0,0) e.g. transparent black? Is it possible using a multiply shader, and a carefully prepared texture (say, with a white shape, cut out of a black+transparent background), to act like a mask? A normal multiply shader would show black for the outline, and the original shape for what’s inside. It feels to me (And at the moment, my shader knowledge is entirely based on intuition), that it should be possible to alter the multiply shader to work a bit more like “alpha blended” particle shader. Is this actually possible?

In other experiments, I’ve had some limited success with a cutout + multiply shader, with two texture slots, one of the texture, and one with an appropriate setup mask texture. By performing the multiplication between the textures in the shader, I’ve been able to “mask” the texture, but would love to know if it is in theory possible to extend this technique into a more general masking technique.

Note I am familiar with depth mask masking, but would like to see if there’s a “clever arithmetic” way of blending that would perform a similar trick.

(I’ve also imagined maybe a plane with a texture, obscured by another plane with the same texture and a mask texture, performing some sort of “subtractive” or “inverse” to perform masking.

Basically, I need as many masking tricks as I can gather at this point, since having to create multiple cameras per depthmask layer makes it a little awkward as a general masking solution fit for an average project.

Thanks in advance!
Mike

What is it that you want to achieve exactly?

As far as I know, multiplying a pixel by RGBA 0000 still results in the pixel becoming RGBA 0000.

The alpha and the colour are multiplied separately. So really it’s doing pixel.rgb * 000, pixel.a * 0.

I’m not sure I really follow the rest of your post, though :expressionless:

thanks both.

I’m trying to find ways of masking shapes, preferably by adding a layer that masks stuff behind it.

This is the project that I’ve built so far: http://www.youtube.com/watch?v=NQbha2tOY5Y and am trying to come up with ways of masking the pages.

I’ve been able to achieve some masking effects by creating a shader that multiplies a white-to-transparent texture with another texture, so that fiddling with the cut-off masks/selectively shows part of a texture.http://www.youtube.com/watch?v=s3RKGAj9Uzk&feature=related

I was wondering if the multiply shader works with the scene, the way that multiplying one texture with a transparent->White texture works within the actual shader.

For my page thing, currently, I’m using DepthMask + Camera for each of the layers required (currently, 4 pages, background = 5 cameras). It all sort of works, but I keep having to add layers (e.g. I now want to mask the shape of the pages to be a slightly different shape. I’m generally finding the depth mask method a little onerous. It gets worse when I want to add the prefab to a project that already uses multiple layers, so I’m just looking for any tricks/options that achieve the equivalent of flash “mask” layers.

Thanks,
Mike