Wet Character Overlay (rain on skin, hair and cloth)
Makes a character look rained on without replacing any of its materials. Set it as the Next Pass of each of the character’s materials (skin, hair, cloth, leather) and it layers on top, so your textures and normal maps stay.
- Soaking: surfaces facing the sky get wet first and shine most; undersides stay drier.
- Darkening and gloss: it darkens the material underneath and gives it a wet gloss, with separate controls for cloth versus skin.
- Rain motion: rain-drop rings spread on shoulders and hair, and beads of water run down arms and skirts.
- Sky rim light: a cool sky-coloured rim along the silhouette ties the character into a rainy night scene.
To use it, create a ShaderMaterial with this shader and assign it to the Next Pass slot of each material. Drive wetness (0 to 1) from your weather. Tune darken, wet_roughness and rim_strength per material; I suggest more darkening and a higher roughness for cloth, and a lower darkening and a glossier look for skin and hair. Fade wetness slowly when the character steps under a roof, so they stay damp for a moment.
It needs normal tangents (standard imported meshes have them) and works on skinned meshes.
Shader code
shader_type spatial;
render_mode blend_mix, depth_draw_never, cull_back, diffuse_burley, specular_schlick_ggx;
// Wet Character Overlay: rain on a character without touching its own materials.
// Set this as the Next Pass of each of the character's materials (skin, hair, cloth, leather...).
// Surfaces facing the sky soak first and shine most; the cold sky catches the edge of the silhouette;
// drops ring on shoulders and hair, and beads of water run down arms and skirts.
group_uniforms Wetness;
// 0 = dry, 1 = soaked. Drive this from your weather. Fade it slowly when she steps under a roof.
uniform float wetness : hint_range(0.0, 1.0) = 1.0;
// How much the overlay darkens what lies under it (cloth takes more than skin).
uniform float darken : hint_range(0.0, 0.7) = 0.28;
uniform float wet_roughness : hint_range(0.03, 0.6) = 0.18;
uniform float wet_specular : hint_range(0.0, 1.0) = 0.6;
group_uniforms;
group_uniforms Drops;
uniform float drip_speed : hint_range(0.1, 4.0) = 1.0;
uniform float drip_scale : hint_range(2.0, 40.0) = 12.0;
uniform float ripple_scale : hint_range(4.0, 60.0) = 26.0;
uniform float ripple_speed : hint_range(0.5, 6.0) = 2.4;
uniform float normal_strength : hint_range(0.0, 1.0) = 0.35;
group_uniforms;
group_uniforms Rim;
uniform vec3 sky_tint : source_color = vec3(0.30, 0.40, 0.56);
uniform float rim_strength : hint_range(0.0, 2.0) = 0.55;
uniform float rim_power : hint_range(1.5, 8.0) = 3.2;
group_uniforms;
varying vec3 world_pos;
varying vec3 world_normal;
float hash21(vec2 p) {
p = fract(p * vec2(127.1, 311.7));
p += dot(p, p + 34.23);
return fract(p.x * p.y);
}
// A drop's expanding ring, as a direction to tilt the normal along.
vec2 ripples(vec2 uv, float t) {
vec2 cell = floor(uv);
vec2 local = fract(uv) - 0.5;
float h = hash21(cell);
float phase = fract(t + h);
float d = length(local);
float ring = smoothstep(0.05, 0.0, abs(d - phase * 0.42)) * (1.0 - phase);
return (d > 0.0001 ? local / d : vec2(0.0)) * ring * step(0.35, h);
}
// Beads of water running down.
vec2 streaks(vec2 uv, float t) {
vec2 grid = vec2(uv.x * 2.2, uv.y * 0.45);
vec2 cell = floor(grid);
vec2 local = fract(grid);
float h = hash21(cell);
float drop = fract(t * (0.6 + h * 0.8) + h * 7.0);
float wobble = 0.5 + 0.18 * sin(uv.y * 6.0 + h * 6.28);
float dx = local.x - wobble;
float dy = local.y - drop;
float tail = smoothstep(0.28, 0.0, dy) * step(0.0, dy);
float bead = exp(-dx * dx * 95.0) * tail * step(0.3, h);
return vec2(-dx * 8.0 * bead, -0.35 * bead);
}
void vertex() {
world_pos = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xyz;
world_normal = normalize((MODEL_MATRIX * vec4(NORMAL, 0.0)).xyz);
}
void fragment() {
float wet = clamp(wetness, 0.0, 1.0);
float up = clamp(world_normal.y * 0.5 + 0.5, 0.0, 1.0);
float top = smoothstep(0.25, 0.85, up);
float side = 1.0 - abs(world_normal.y);
float soaked = clamp(wet * mix(0.4, 1.15, top), 0.0, 1.0);
vec2 down_uv = vec2(world_pos.x + world_pos.z, -world_pos.y);
vec2 tilt = (streaks(down_uv * drip_scale, TIME * drip_speed) * side + ripples(world_pos.xz * ripple_scale, TIME * ripple_speed) * smoothstep(0.55, 0.9, up)) * normal_strength * soaked;
NORMAL_MAP = normalize(vec3(tilt, 1.0)) * 0.5 + 0.5;
NORMAL_MAP_DEPTH = 1.0;
float rim = pow(1.0 - clamp(dot(normalize(NORMAL), normalize(VIEW)), 0.0, 1.0), rim_power) * rim_strength * soaked;
// The layer darkens what is under it, then shines like water over it.
ALBEDO = vec3(0.0);
EMISSION = sky_tint * rim;
ALPHA = clamp(soaked * darken * mix(0.7, 1.2, top) + rim * 0.2, 0.0, 0.8);
ROUGHNESS = mix(0.6, wet_roughness, soaked);
SPECULAR = wet_specular;
}

Comments 0
No comments yet.