how do I change the opacity of an image (overall alpha) without generating an opacity mask?

In most graphics and video applications you can go to the Opacity setting for an object and adjust it’s opacity (or transparency to look at it from the opposite POV).

I typed “Opacity” into the Vuo node library and didn’t really get any obvious answers.

In QC (yes that again!) you could apply a colour to an image with white in it and the colour would apply. Same for the opacity setting, from 0 (invisible) to 1 full opaque.

I’m looking for something that simple. Even if I figure out how to generate a texture of greyscale to make a mask, it’s a bit of overkill for such an everyday task… what am I missing here?

It’s in the color options for the shader:

2 Likes

Thanks @MartinusMagneson. I’m actually wanting to give alpha to a fetched image, a PNG file. five nodes just to add alpha and another to change blend mode to add. seems a wee bit inefficient to me. The Make _ Shader Colour nodes don’t work with images or image transform nodes, so not sure there’s any better way than what I have done. Fine for one image but when you have dozens of loaded images it becomes cumbersome. I guess it’s time I rolled a sub-composition to do it…

I made two sub-compositions, one for image alpha, one for alpha and blend mode outputting a layer.

ud.imageFilter.addAlphaToImage.vuo

ud.image.addAlphaBlendModeToImage.vuo (5.25 KB)

Screen Shot 2022-04-27 at 5.44.19 pm.png  

ud.imageFilter.addAlphaToImage.vuo (2.99 KB)

Oh, I’m answering before reading now it seems :sweat_smile:. Then you want the “Mask Image by Brightness” node I think. Alternatively a custom shader that converts a luma range in the input image to alpha.

Oh I must not be explaining correctly! What I’m after is simply an opacity value slider. I don’t want opacity to be determined by source image pixel brightness or colour or anything else in the source image. So the input is a slider of range 0 to 1 and that goes into a HSL Color or RGB Color node to set it from white (1) to black (0) where black means all the pixels will be totally transparent and white means they’ll all be completely opaque (unless there is already a alpha channel in which case it should multiply the old alpha values [0,1] with the new mask value [0,1].

What is strange is that when I use a single grey coloured image for a mask and use the stock Apply Mask node, what I get is mask by pixel brightness! This is not how masks are supposed to work. They should simply multiply the alpha channel by the incoming mask image (which is the same for every pixel). If the image has no alpha channel then it needs to be created.

please take a look at this image with 0.95 opacity applied three times in a row. It’s way too little opacity on the first pass, and when you click mouse to bring up the patterned background, it’s obvious the blacks are being masked much more than the whites.

source image is from here

ud.imageFilter.addAlphaToImage.vuo (2.99 KB)

here it is with opacity of 0.667 applied three times to the same image, with a background to show how blacks disappear in first pass, which they shouldn’t.

 

here’s the image chain composition:

image alpha chains.vuo (6.28 KB)

(source image link)  

There’s a node called Make Unlit Image Shader which has an opacity value input (0–1 range) and an Image input (sounds promising!!) but I can’t find another node that will receive its output except Arrange 3D objects in Grid and even that isn’t showing any output. I tried adding a 3D square and Change All Shaders like the example composition for the Make Lit Shader.

The GLSL code for this would just be to multiply source alpha 1 value with source 2 (R+G+B)/3

Without entering the realm of technically how masks work or should (not skilled enough for that), I would say this.

Make Unlit Image Shader which has an opacity value input (0–1 range) and an Image input (sounds promising!!) but I can’t find another node that will receive its output except Arrange 3D objects in Grid

Not sure what you mean here. That Make Unlit Image Shader can be used in any port called “material” (which is the generic name for several materials to be accepted (an image, a shader …).

And change all shaders outputs an object you can use in any object port.

For the rest,

a - If you wanna set the opacity of 3D objects later on the chain node regardless of their material, there is a feature request for that.

b - If you want to change the opacity of a layer with an image set to it, you can change the opacity of the layer itself ?

c - If you want to change the opacity of an image only, indeed maybe an Adjust Image Opacity node could be added. Although, a workaround seem to be to use Blend Images and link no image to the first port.

Hope this helps, but again, I’m not saying you’re not right about how things could work, I’m not skilled enough for technical details ;)

EDIT : Have you looked at the “Split Image RGB or HSL channels” nodes ? Maybe you could achieve what you want with it ?  

Archive.zip (2.63 MB)

2 Likes

Thanks @Bodysoulspirit. I guess the Blend Image node is the closest workaround. I’d prefer if the image stays as an image type, I wasn’t wanting to convert it to a layer or objects types if I don’t have to. Vuo seems to direct one down that path often when one searches for nodes to do the thing one wants to do.

That image you have looks like about 50% Opacity and consistent across all pixels, not just the 50% White pixels so that is the effect I’m looking for I think.

I’m not sure what the hell is going on inside the Mask node, but it doesn’t seem correct on my tests. I’ll continue to investigate… and maybe post a bug report if I"m convinced the Mask node isn’t working as it should.  

1 Like