Inverted Alpha (again sorry)

Hi,

I recently posted about having an inverted alpha on my material. The point of the post was that I had a moving rainbow texture for a sprite with opaque and transparent areas, and the rainbow was only going to the transparent areas rather than to the opaque only. The solution I was given was to use the multiply the alpha of the rainbow texture with the sprite I wanted to make rainbow, but now I want to make everything that way no matter what the material is applied to, no just that specific sprite.

Thank you in advance.

1 Like

if i understood correctly. you’ll need to apply your mask to all materials.

which might not look perfect.

i think what you’re trying to do is a bit odd.

im not sure what “inverted” has to do with the post. but if the inversion is the problem you need to use a “one minus” node. and make sure before that the input is normalized, either with a remap normalize or a saturate (clamp 0/1 fast)

Inverted Alpha usually means the alpha channel is reversed — transparent areas become opaque and vice versa. It’s common in graphics pipelines depending on the rendering format.

It’s a cave sprite, and it looks like this with the inverted alpha.

I tried using the OneMinus node but it just removed the rainbow texture. I want it to be on the outer areas rather than the inner areas without having to use the sprite of the cave inside of the texture, so that I can use it for anything, not just the cave. Sorry for not being clear the first time haha.

Just for reference, this is the cave before I add the material (note that none of the objects like the icicles, rocks, or plants are a part of the cave - those are separate. The cave is just in front of them on the y axis, that’s why the rainbow covers them).

i’m not sure i understand what you try to do.
do you have an image of what you are trying to achieve? the final result?

i do not understand what you mean.

i think the problem is how you draw the that light blue part.

the one minus seem sto be working, but you might be painting on top of it.

Yes I’m really sorry for not being clear haha.

I want the outer area, the blue part, to become rainbow colored rather than the inside. When I use the OneMinus node, it just removes the material completely. But you’re right maybe it’s covering it up? Idk.

all good, it’s not necessarily your fault. i struggle to understand without images of the code or reference images sometimes. please do share more code and images if possible.

with the code you shared, if you put a one minus between the alpha of the mask, and the multiply. it should work as you describe. unless i’m mistaken.

in ANY case, there should be NO light blue rendered to the screen, as that texture only is used as a mask.

so then (as alan watts says)

if there’s light blue on the screen, it means you are rendering something else, and that’s potentially causing issues.

is that another material?

the yellow outline on the screenshot with the rainbow makes me think its another material/object.

sidenote:

i hope that light blue thing comes from a render target. you have not shared any context for your issue, but it reminds me to worms or lemmings, maybe you want to make the environ destructible.

i think you might be able to optimize.

blue means you are using RGB, and Alpha. that’s 4 channels.

where you only need the alpha, so you can use a RT of only red for example (float16 for example).

and use the red channel instead of alpha.

that will make the texture 3 times smaller, and 3 times faster to render and move.

I think that the images I’ve shared made it confusing. The code that I showed makes it work, but only because the sprite is multiplied with the alpha of the rainbow. The problem is that when I only put the alpha into the opacity mask, it inverts it like the picture shown above. And when I add the OneMinus node, it just removes the rainbow. Here’s the code with the images to show you what’s going on.



Ah those screens are much better. I can see the issue now

when i say mask i talk about the 2nd texture thats cyan.

The one minus was supposed to go between the MASK and the multiply. Not in the rainbow texture alpha.

The rainbow texture alpha is useles, unless you plan to have a texture with actual alpha.

The alpha channel in the cyan mask can be problematic and give false results depending how that texture is set. I highly highly recommend you use a greyscale texture.

If the first scceen is how you want it, and works, then i suggest you just make a material function if you want to reuse it.

Or maybe you can place your assets so that you only use it once. You can put a plane on top and let ue mask one with the other, depending on your camera setup.