When I first came across a situation when I needed a transparent image in Blender I didn’t have any idea how to make that happen. But when I learned about shaders and the node editor I found the answer.
To use an image textures alpha channel in Blender we need to set up a material that combines a shader node like Principled BSDF with a transparency BSDF node. We mix the two shaders together with a mix shader and use the alpha channel from the image texture node as the factor input.
Let’s cover the details on how we achieve this in both Eevee and Cycles as well as some possible caveats and downsides that we may encounter.
What is transparency and its prerequisites?
The words transparency and alpha are often used interchangeably. They are after all, almost the same thing.
If there is a difference between them you can say that in an image, we have red green and blue channels. But in some image types, such as a PNG file, we may have a fourth channel that we call alpha. Alpha is then used to create transparency.
To use transparency we therefore need an image with an alpha channel. We also need to make sure that the alpha channel isn’t empty, which can be the case with many image files. If an image has an alpha channel, you would generally know that it does.
The image format we are using also needs to support an alpha channel. A JPEG for instance does not support alpha, while PNG files does. There are other file types that also support alpha but PNG is the file type you are most likely to come across.
There are also alternatives. For instance, we can use the built-in procedural textures in Blender to generate an alpha channel. All an alpha channel really is, is a gray scale image. A mask.
We could use any of the other channels in an image and tell Blender that we, for instance want to use the Red channel as alpha. But we are getting ahead of ourselves here.
How to set up a material for transparency in Blender
These are the steps we follow to use an image with alpha transparency in Cycles.
- Go to the shading workspace.
- Make sure that you have the correct object and material selected.
- Drag and drop your image into the shader editor on the left side of the Principled BSDF node.
- Go to the add menu(Shift+A) in the shader editor, find shader and choose a Transparent BSDF. Place it above the Principled BSDF node.
- Add a mix shader node as well and place it on the right side of the Principled shader and move the material output further to the right.
- Connect the image node color to the base color of the principled BSDF.
- Disconnect the Principled shader from the Material output and put it in the bottom slot of the Mix shader.
- Connect the Transparent BSDF to the Mix shaders top BSDF slot.
- Take the image texture nodes alpha output and plug it into the Mix shader factor input slot.
If you are interested in an overview of Eevees render settings you can find my guide here that covers most sections from shadows, indirect light to film settings where we find background transparency.
Related content: A guide to Blender Eevee render settings
This is the final node setup. The key is to use the alpha output of the image texture as the factor, deciding what pixels in the image are transparent and what pixels are not.
An alternative way, is also to connect the image alpha directly to the principled BSDF alpha and skip the transparent BSDF and mix shader all together. But the above solution is move universal and will work with other shaders as well.
If you are new to nodes you may want to check out my beginners guide on how to create materials in Blender
Related content: The complete beginners guide to Blender nodes, Eevee, Cycles and PBR
How to test the alpha transparency using Cycles?
To test that it works, make sure that you are in Cycles render engine and go to rendered preview mode using the button in the top right corner of the 3D viewport.
If you don’t see any transparency, double check your node setup against the image above and make sure that your image actually has an alpha channel by following the instructions below.
If at some point, your transparency becomes black, you probably have more transparent layers on top of each other than your Cycles render settings currently allows.
To fix this go to the render tab and find the light path section. Here you will find transparency bounces. By default, this is set to 8. This is how many transparent layers the ray will allow before it terminates and possibly render black.
In certain situations, for instance in trees with leaves that has alpha around them, this may not be enough, and we may need many bounces for the tree to look realistic. This is where you control this.
How to check that an image has transparency in Blender?
The easiest way to check if an image has an alpha channel is by using the node wrangler add-on. Enable it by going to Edit and preferences.
Find the add-on section and search for “wrangler”. Enable the add-on and close preferences.
In the shader editor, hold Ctrl+Shift and click your image texture node twice so that the alpha output gets connected to a viewer node that goes to the material output.
If you look in the 3D viewport and see both black and white areas it means that you have an alpha channel giving you transparency.
Black areas will represent the transparent areas and white will represent opaque.
How to use an image with transparency in Eevee
When we are using Eevee, the shader setup is the same as when we are using Cycles. But since Eevee is a rasterized render engine it handles transparency a bit different.
By default, we don’t have transparency enabled. Instead, we have to first choose the blend mode that we want to use.
The blend mode is set on a per material basis. You can find it if you go to the material tab in the properties panel and open the settings section. Here you will see a dropdown labeled Blend mode and by default it is set to opaque.
What is the differences between blend modes in Eevee?
We have three options when choosing blend mode in Eevee. These are:
- Alpha Clip
- Alpha Blend
- Alpha Hashed
In Eevee we have something called “per object sorting”. This means that the object with its origin the furthest away from the camera will be drawn first. In some cases we may have geometry in front of another object, but the origin points may be reversed.
This may mess up our transparency in Eevee if we have multiple transparent layers.
Alpha hash bypasses this problem by overwriting the previously drawn object. But alpha hash uses samples and may create a noisy result with too few samples. It is also quite performance taxing.
Alpha Blend just overwrites the previous color and is probably the best option to use when we don’t have a sorting problem.
Alpha clip is the cheapest to use in terms of performance but it works from a clip value. This means that we can’t have partially transparent pixels. We can only have full transparency or no transparency based on a threshold.
Also take note of the shadow mode. It determines if the shadow will be drawn from the object mesh or if it should take the transparency into account and let light through the transparent pieces. The blend modes here are:
- Alpha clip
- Alpha hashed
Here we have the same deal, but no alpha blend option.
None means no shadow and opaque means that we use the object’s geometry to determine the shadow.
Alpha clip will give us either a full shadow or no shadow depending on if the portion of an object lit is hitting a transparent or opaque part of the object.
Alpha hashed is capable of giving us a more nuanced shadow with light partially coming through. But at a higher performance cost and possibly noise with lower samples.
I set up a very simple scene to demonstrate the different modes. This is the scene in solid view. We will look from above while we use different blend modes on the material assigned to all the selected planes.
This is the material setup I used for the first example. In the alpha hash and alpha blend example I adjusted the color ramp to only include gray scale values and no black or white.
Note how I use the noise texture with a color ramp instead of an image texture alpha output. Both would work fine. All an alpha channel is, is a gray scale image anyway.
In this example we use alpha clip for both shadow and blend mode. I have a low sample count of 16 that contribute to the poor shadow quality.
This is the alpha blend example. We have no noise, and we can use values in between full black or full white to create a partial see-through environment.
In this last example I increased the samples to 128. You can see that it is still quite noisy and would require more samples to clear up. At 512, I started to get something comparable to alpha blend in this case.
Something I found when testing the shadow was that alpha clip often is enough to create fairly accurate shadows if we use soft shadows.
More about soft shadows in my guide to Eevee settings. It is the same link as above.
Related content: A guide to Blender Eevee render settings
When dealing with transparency we often have geometry without depth to them. Such as simple planes. In this case we may see the backside of a face. If you need to turn off the backside view of faces you can use backface culling found at the top of the material settings.
What is the difference between transparency BSDF and holdout?
You may have heard or seen that there is a transparent BSDF as well as a holdout shader node. Both have to do with transparency.
The transparency BSDF will render as transparency based on the blend method for Eevee or just as transparency in Cycles, revealing whatever is hidden behind partially or fully.
The holdout node will cut a hole in the canvas, leaving a transparent mask in the final render.
There is a lot more to transparency in Blender. In this article we focused on how to use alpha in a texture. In essence, alpha is just a black and white mask. But it is so fundamental to a lot of computer graphics.
We can have a transparent background, we can use the compositor to work with green screens, and we can mask however we want with procedural texture nodes in our materials just to name a few places where we use transparency and masks.
I hope you learned what you came for.
Thanks for your time.