Texture Blend

Blend two colors and/or textures together based on a greyscale mask.

Shader code
shader_type spatial;

uniform sampler2D mask_texture:hint_albedo;
uniform vec4 albedo_a:hint_color = vec4(1.0f);
uniform sampler2D texture_a:hint_albedo;
uniform vec4 albedo_b:hint_color = vec4(1.0f);
uniform sampler2D texture_b:hint_albedo;

void fragment() {
	vec3 mask = texture(mask_texture, UV).rgb;
	vec3 a = albedo_a.rgb * texture(texture_a, UV).rgb;
	vec3 b = albedo_b.rgb * texture(texture_b, UV).rgb;
	vec3 color = mix(a, b, mask);
	ALBEDO = color;
blend, combine, merge, Mix, textures
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

Double texture blend 2D

FPS view shader with color/texture and metallic

Advanced 7 Texture Albedo Terrain Shader

Notify of

1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
1 year ago

tysm <3