Randoloot/resources/effects/mountain_blend.gdshader
2026-10-18 14:46:34 +02:00

22 lines
1007 B
Plaintext

shader_type canvas_item;
uniform vec4 ground_tint : source_color = vec4(0.25,0.28,0.2,1.0);
uniform vec4 rock_tint : source_color = vec4(0.4,0.4,0.36,1.0);
float hash(vec2 p) { return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453); }
float noise(vec2 p) {
vec2 i=floor(p); vec2 f=fract(p); f=f*f*(3.0-2.0*f);
return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),mix(hash(i+vec2(0,1)),hash(i+vec2(1,1)),f.x),f.y);
}
void fragment() {
vec4 mountain=texture(TEXTURE,UV);
float edge=length((UV-vec2(0.5))*vec2(1.9,1.8));
float breakup=noise(UV*25.0)*0.065+noise(UV*65.0)*0.025;
float foothill=smoothstep(0.42,0.90,edge+breakup);
float feather=1.0-smoothstep(0.62,0.96,edge+breakup);
float luminosity=dot(mountain.rgb,vec3(0.299,0.587,0.114));
vec3 mineral=mix(mountain.rgb,rock_tint.rgb*(0.65+luminosity),0.18);
// Low foothills inherit the local biome before dissolving into the ground.
mineral=mix(mineral,ground_tint.rgb*(0.65+luminosity*0.9),foothill*0.62);
COLOR=vec4(mineral,mountain.a*feather);
}