shader_type spatial; render_mode cull_back; uniform vec4 color_1: source_color = vec4(0.0, 0.03, 0.1, 1.0); uniform vec4 color_2: source_color = vec4(0.0, 0.1, 0.3, 1.0); uniform float roughness: hint_range(0.0, 1.0) = 0.15; uniform float specular_contribution = 0.2; // Used ONLY by the gunk, does not affect the gunk mask. uniform vec2 uv_scale = vec2(1.0); uniform float edge_bleed = 0.1; uniform sampler2D gunk_mask; uniform highp sampler2D gunk_noise; uniform highp sampler2D gunk_normal_map; float hardstep(float value) { float x = clamp(value, 0.0, 1.0); return 0.5 * tanh( (20.0 * x - 10.0) * inversesqrt(x - x * x) ) + 0.5; } void fragment() { vec2 local_uv = UV * uv_scale; float value = texture(gunk_noise, local_uv).r; vec4 color = mix(color_1, color_2, value); float roughness_mix = value * roughness; ALBEDO = color.rgb; ROUGHNESS = roughness_mix; SPECULAR = 0.5 * inversesqrt(specular_contribution); NORMAL_MAP = texture(gunk_normal_map, local_uv).xyz; float mask = texture(gunk_mask, UV).r; // soften edges NORMAL_MAP *= smoothstep(1.0, 0.0, mask); /* // Hard edge if(mask + edge_bleed < 0.5) { ALPHA = 1.0; } else { ALPHA = 0.0; } */ // Hardish edge ALPHA = hardstep(1.0 - mask + edge_bleed); }