Quick answer: Spatial shaders: set both ALBEDO (vec3) and ALPHA (float). Add render_mode blend_mix; at the top. CanvasItem: COLOR is vec4 already.

PNG with alpha looks transparent in editor preview but renders fully opaque in game. The shader doesn’t set ALPHA.

The Symptom

Custom shader on a Sprite3D / mesh ignores texture alpha. Standard material on the same mesh works.

The Fix

shader_type spatial;
render_mode blend_mix, cull_back;   // blend_mix enables transparency

uniform sampler2D albedo_tex;

void fragment() {
    vec4 c = texture(albedo_tex, UV);
    ALBEDO = c.rgb;
    ALPHA = c.a;
}

render_mode blend_mix puts the material in the transparent pass; ALPHA controls per-pixel transparency.

CanvasItem Variant

shader_type canvas_item;

void fragment() {
    COLOR = texture(TEXTURE, UV);   // vec4 already
}

Verifying

Apply shader to a sprite with transparent edges. Edges should fade. Without blend_mix or ALPHA: opaque.

“Both ALBEDO and ALPHA. blend_mix on. Transparent renders.”

Related Issues

For shader uniform array, see uniform array. For shader derivatives, see derivatives.

ALBEDO and ALPHA. blend_mix. Alpha applies.