Sub topic 11
Alpha and Transparency
Working model
Assume you know how to create a material, assign it to a mesh, and use the Shader Editor. Alpha is a value that controls how much of a surface contributes to the final image. An alpha of 1 is fully opaque. An alpha of 0 is fully transparent.
In the Principled BSDF, the Alpha input usually receives a constant value or the alpha channel of an image texture. The shader then passes that value to the Material Output. The material settings determine whether the render engine actually uses the value for transparency.
| Alpha value | Result |
|---|---|
| 1.0 | Fully opaque |
| 0.5 | Half transparent when the material uses a blended method |
| 0.0 | Invisible, although shadows and other effects may still need configuration |
Connecting an image alpha
An image texture can provide both color and transparency. Connect its Color output to Base Color and its Alpha output to the Principled BSDF Alpha input.
import bpy
obj = bpy.context.active_object
if obj is None or obj.type != "MESH":
raise RuntimeError("Select a mesh object first")
mat = bpy.data.materials.new(name="LeafMaterial")
mat.use_nodes = True
nodes = mat.node_tree.nodes
links = mat.node_tree.links
bsdf = nodes.get("Principled BSDF")
image = bpy.data.images.load("//textures/leaf.png")
texture = nodes.new("ShaderNodeTexImage")
texture.image = image
links.new(texture.outputs["Color"], bsdf.inputs["Base Color"])
links.new(texture.outputs["Alpha"], bsdf.inputs["Alpha"])
if hasattr(mat, "surface_render_method"):
mat.surface_render_method = "DITHERED"
obj.data.materials.append(mat)The image must contain an alpha channel. If it does not, the Alpha output normally remains 1. Also check the image file itself. A PNG can store transparency, while some JPEG files cannot.
Material render settings
Open Material Properties, expand Settings, and find the surface render method. In current Blender versions, Blended allows gradual transparency and Dithered approximates transparency with a pattern of opaque pixels. Older versions may call similar choices Alpha Blend, Alpha Hashed, and Alpha Clip.
The engine and version affect the available choices. Cycles generally handles physically transparent surfaces through shader evaluation, while Eevee may require an explicit render method and has limits for sorting transparent objects.
Cutouts and sorting
A leaf texture often needs sharp cutouts rather than smooth glass-like fading. Use a ColorRamp or Math node to convert the texture alpha into values of 0 or 1. This produces a mask. For a soft fade, preserve intermediate alpha values and use a blended render method.
Transparent objects can display in the wrong order when several surfaces overlap. Keep transparent meshes simple, avoid unnecessary intersecting layers, and test the final camera view. For a one-sided card, enable Backface Culling when the back should not be visible.
Exercise
A PNG leaf appears as a solid rectangle. What should you check first?
Show answer
Connect the Image Texture Alpha output to the Principled BSDF Alpha input, then choose a cutout or blended surface render method in the material settings.