Advanced 7 Texture Albedo Terrain Shader

all you need is an RGBA mask, and a few seamless textures. made for godot 4.x but can probably work for 3.x

Shader code
shader_type spatial;
render_mode cull_back, blend_mix;

//uv scales
uniform lowp float uv_scale = 1.0;
uniform lowp float alpha_uvs_scale = 1.0;
uniform lowp float mask_uv_scale = 1.0;
//mix intensities
uniform lowp float mix0_intensity = 1.0;
uniform lowp float mix1_intensity = 1.0;
uniform mediump sampler2D terrain_mask : source_color;
//blacks and whites
uniform mediump sampler2D texture_black : source_color;
uniform lowp sampler2D texture_alphablack : source_color;
uniform lowp sampler2D texture_alphawhite : source_color;
uniform mediump sampler2D texture_red : source_color;
uniform mediump sampler2D texture_green : source_color;
uniform mediump sampler2D texture_blue : source_color;

void fragment() {
	vec2 scaled_uvs = UV * uv_scale;
	vec2 scaled_mask_uvs = UV * mask_uv_scale;
	vec2 scaled_alpha_uvs = UV * alpha_uvs_scale;
	vec4 texturemask = texture(terrain_mask, scaled_mask_uvs);
	vec3 textureblack = texture(texture_black, scaled_uvs).rgb;
	vec3 texturealphablack = texture(texture_alphablack, scaled_alpha_uvs).rgb;
	vec3 texturealphawhite = texture(texture_alphawhite, scaled_alpha_uvs).rgb;
	vec3 texturer = texture(texture_red, scaled_uvs).rgb;
	vec3 textureg = texture(texture_green, scaled_uvs).rgb;
	vec3 textureb = texture(texture_blue, scaled_uvs).rgb;
	float summed_rgb_mask = (
		texturemask.r +
		texturemask.g +
	vec3 mixxed_rgb_terrain = clamp(
		texturemask.r * texturer +
		texturemask.g * textureg +
		texturemask.b * textureb / 
		vec3(0.0) , vec3(1.0)
	vec3 mixxed_alpha_terrain = clamp(
		texturemask.a * textureb / 
		vec3(0.0) , vec3(1.0)
	ALBEDO = mix(mixxed_rgb_terrain, textureblack, 1.0 - summed_rgb_mask) * mix0_intensity + mix(mixxed_alpha_terrain, texturealphawhite, texturealphablack + texturemask.a) * mix1_intensity;
seamless, terrain, tilled
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.

More from Unhinged Dev

Double Vision w/ chromatic aberration


Related shaders

Albedo Terrain Mix Shader

Wandering Clipmap – Stylized Terrain

mesh-terrain blending

Notify of

Newest Most Voted
Inline Feedbacks
View all comments
5 months ago
Reply to  Unhinged Dev

Does the shader do height and pixel blending?
The preview images seems to have hard edges