Overlays (Tattoos,Scars,Cosmetics,Graffiti)

This shader is designed to overlay additional textures on top of the model, this can be blood, tattoos, cosmetics on the face, and any other options.

At the moment, you can control the color of the overlays, and transparency, by default you can overlay up to 5 textures, but this value can be very easily increased in the shader.

This shader does not use black and white masks, for transparency channel, you just have to use transparent png textures if you need transparency in textures.

You can also combine this with other shaders, such as cartoon or outline, using “Next Pass”.

For Godot 4+.

Shader code
shader_type spatial;

uniform sampler2D base_texture: source_color;
uniform vec4 base_tint : source_color = vec4(1.0,1.0,1.0,1.0);

uniform sampler2D overlay_texture1: source_color;
uniform sampler2D overlay_texture2: source_color;
uniform sampler2D overlay_texture3: source_color;
uniform sampler2D overlay_texture4: source_color;
uniform sampler2D overlay_texture5: source_color;

uniform vec4 overlay_color1 : source_color;
uniform vec4 overlay_color2 : source_color;
uniform vec4 overlay_color3 : source_color;
uniform vec4 overlay_color4 : source_color;
uniform vec4 overlay_color5 : source_color;

uniform float overlay_blend1 : hint_range(0, 1);
uniform float overlay_blend2 : hint_range(0, 1);
uniform float overlay_blend3 : hint_range(0, 1);
uniform float overlay_blend4 : hint_range(0, 1);
uniform float overlay_blend5 : hint_range(0, 1);

void fragment() {
    vec3 main_color = texture(base_texture, UV).rgb * base_tint.rgb;

    vec4 overlay1 = texture(overlay_texture1, UV) * overlay_color1;
    vec4 overlay2 = texture(overlay_texture2, UV) * overlay_color2;
    vec4 overlay3 = texture(overlay_texture3, UV) * overlay_color3;
    vec4 overlay4 = texture(overlay_texture4, UV) * overlay_color4;
    vec4 overlay5 = texture(overlay_texture5, UV) * overlay_color5;

    vec3 final_color = main_color;
    final_color = mix(final_color, overlay1.rgb, overlay1.a * overlay_blend1);
    final_color = mix(final_color, overlay2.rgb, overlay2.a * overlay_blend2);
    final_color = mix(final_color, overlay3.rgb, overlay3.a * overlay_blend3);
    final_color = mix(final_color, overlay4.rgb, overlay4.a * overlay_blend4);
    final_color = mix(final_color, overlay5.rgb, overlay5.a * overlay_blend5);
    ALBEDO = final_color;
}
Tags
customization, decal, layer, overlay, tattoo
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.
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments