2
$\begingroup$

I have two textures with transparency and I want them on top of each other with a Diffuse shader below them via the Material nodes in Cycles.

setup

desired result

Because I'm using the Material nodes and not the Compositor, I can't just simply use the Alpha Over node.

Here's as far as I got. (Ambient Occlusion is enabled. I need both textures at full opacity.)

my failed node setup

My problem seems to be stemming from the fact that I don't know how to combine alpha channels, if that helps.

How do I do this?

(It MUST be done in the Materials node editor.)

Here's the .blend file:

$\endgroup$
2

2 Answers 2

2
$\begingroup$

The alpha channel of both images can be combined ( in this case it works if you add them, but you can also do other operations depending on your needs) and used to control the mix for the colors or shaders:

enter image description here

or:

enter image description here

$\endgroup$
1
$\begingroup$

I will share my setup that is a little different from the accepted answer - although it is inspired by the accepted answer. Hopefully it can help anyone who has transparent gradients in the images they want to layer, or who wants to layer numerous image textures repeatedly.

Here is the node setup:

enter image description here

And here is what's happening inside the "Alpha Over" Group node:

Having the alpha set to "straight" caused problems for me, so I can't overstate the importance of setting alpha to "premultiplied".

The Group node is pretty simple inside. Just like the method in the accepted answer, the alpha gets summed (think of a silhouette - the order doesn't matter). For the color Mix node however, it is the over image whose alpha channel drives the factor.

These Group nodes can be chained as many times as needed. If you want to change the blend mode for one of the mixes, duplicate the Group node and click the number indicating how many users the data-block has. This way you won't be changing the original group.

Update

2023-03-09

I thought it would be convenient to have opacity sliders for both "layers" built into the Group node, so I have added those.

Alpha Over for materials - node setup, including Opacity sliders

Note: Readers can disregard the "IAP_SHADELESS" group, as it is not relevant to the opacity setup.

Inside the new and improved "Alpha Over" Group node:

Inside the "Alpha Over" group node

Just like before, the alpha from the "over" image is factoring the Mix node. But now, it first passes through a Float type Mix node in order to account for any opacity slider adjustments. This ensures the opacity will be correct, regardless of the Blend Mode being used.

Here is a demo .blend file for anyone who wants to inspect the setup, or even append it to their startup file.

Made with Blender ver. 3.4

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .