Simple Chroma Key

Turns whatever color is selected into transparency based on intensity.

Filtering is a bit weird though, filtering is done before the shader.

Shader code
shader_type canvas_item;

uniform vec4 chroma_key : source_color = vec4(1.0, 0.0, 1.0, 1.0);
uniform float intensity : hint_range(0.0, 1.0) = 0.1;

void fragment() {
	vec4 tex_color = texture(TEXTURE, UV);
	vec3 color_diff = abs(tex_color.rgb - chroma_key.rgb);
	float diff_magnitude = length(color_diff);
	if (diff_magnitude < intensity) {
	COLOR = tex_color;
Chroma Key, godot4
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

Related shaders

Chowder – Chroma Key

Green Screen – Chroma Key

Simple UI Noise Mask

Notify of

Inline Feedbacks
View all comments