How to mix two partially transparent images together perfectly with cycles?

I basically have an item which comes as two images with their own alpha maps. However, there doesnt appear to be a way to mix the images together.

Basically i want it as though in paint you’d pasted an image over another one - the background is still see-through, but wherever there isn’t transparency in either of the images, it will show fully.

See below image:


Using an add shader at the end results in the image as given. Using a mix shader gives the item correctly with the transparent areas not visible, but also the entire item is somewhat transparent and ghostly. Is there any way to fix this?

Would you mind sharing the file?

If the rest of the shading information is identical, I think it’s easier to just mix colors instead of shaders:


First step is to mix both textures’ color information based of the alpha of the one that is supposed to be “on top”, then the combined (added) alpha of both textures is used to mix the transparency in.

2 Likes

Could you please show us what was your initial attempt at the Mix nodes? Node tree and samples of your images?
I somehow doubt Adding Transparencies created from image alphas is the right way to go…

HI I tried the exact same node setup and it ruins the image completely:


And here is the result with the original node setup and mix node instead of an add node at the end:


I would upload the file, except i cant find any file sharing website except dodgy looking ones and blenderartists doesnt have a way to upload blend files any more, any suggestions?

Sorry, but that’s not even remotely close to my node setup…
Instead of my Color > MixRGB node you used a Mix Shader node and instead of my Converter > Math node you used an Add Shader node.

If you’re unsure what node is used, always mind the color coding of the inputs and outputs!

2_Textures_on An_Object.blend (866 KB)

Got it, you can only upload a new file to here when you start a post, not at the end!

Sorry can you please explain which nodes in your image are which? I have no idea as it seems both of the shaders you used have the same look and name as the mix and add shaders and I cant tell which ones are and arent. I cant mind colours because in my blender version there arent any, and everything is grey.

As I said: Use my node setup and everything works.


By the way, with color coding I referred to the little colored dots marking the connectors of any node - those are colored in your version as well…:wink:

If you e. g. see a node with yellow connectors, you know that color information is supposed to be fed in there. If the connector is blue, it expects vector information. Green is for shading information etc.

Top left: MixRGB, top right: Mix Shader
Bottom left: Math (in Add mode), bottom right: Add Shader


If you examine the data type those nodes need as input and produce as output, they look nothing alike!

You could use something like this maybe…

http://www.pasteall.org/pic/show.php?id=98528

Thanks, with that, i have managed to get it to work as you have. However, one other question remains, how do you turn on the node colours so you can understand which nodes you are looking at? In my version they all have grey colours by default, and if I had known they had in-built colours, the confusion would probably not have arisen.

That’s because I’m using a different theme for Blender: You’re on default, I’m using “Flatty Light”.


Just look at the “Node Editor” section of the theme editor: There you can choose the colors for the different node types.

Thanks, I too was able to use the nodes you posted.
I also have another question: how do you make one of those images partially transparent? (The one in the back) I can’t figure out at what part of the node tree you need to add a mix shader with a transparent shader or whatever.

Not sure if I understand your question… Could you give an example?

BTW, in my render the image in the back is partially transparent, due to its own alpha channel. If you want to add additional transparency to the image in the back - what is that transparency based on? A third texture?

My node setup is about (mostly) not having to mix shaders at all, but mixing both images based on their color and alpha levels. To further explain my node setup:


The red part combines the color data from both textures based on the alpha of the “top” one, thereby bringing that, well, on top.

The green part mixes the diffuse shader with a transparent shader based on the combined alpha of both textures. Changing the “type” of the math node allows for interesting effects, quite like “booleans” between the two textures’ alpha values:


By “partially transparent” I mean like glass. As in alpha=0.5 or whatever. So that, for the red image, the grey background partially shows through the red, but for the green image, it’s solid green. Like green (opaque) paint on red glass.

AH, I see. I think it’s easiest to just add a Converter > Math (Multiply) node between the Alpha output of the red texture and the top input of the Add node. The factor for the multiply will determine how transparent the red area is.


Mind you, though, that with my nodes you’re still only mixing colors. The other shading attributes are the same for the red and the green areas. So, if you e. g. want an opaque diffuse green decal on a red refractive glossy plane, you will need to change the approach from mixing colors to mixing shaders.

it helps me a lot, thank you

Thanks a lot it helped me a lot as well for making some 2d cartoon eye animation using textures