Is world-space repeating overlay texture possible on tilemaps in Defold?

Hello! I need some help.

I recently came across a technique in Godot where a repeated overlay texture is applied on tilemaps using a shader (based on world position). I’m trying to achieve something similar in Defold.

Is it possible to do this using a tilemap material in Defold?

Here’s the shader I’m referencing:

shader_type canvas_item;

uniform sampler2D overlay_tex: repeat_enable, filter_nearest;
uniform float scale = 0.006944444; // calculated by 1/texture size e.g. 1/144
varying vec2 world_position;

void vertex(){
    // calculate the world position for use in the fragment shader
    world_position = (MODEL_MATRIX * vec4(VERTEX, 0.0, 1.0)).xy;
}

void fragment() {
    // only apply overlay_tex on the fully red parts of the original tiles
    float mix_amount = floor(COLOR.r);
    
    // sample the overlay_tex using world position
    vec4 overlay_color = texture(overlay_tex, world_position * scale);
    
    // combine original color and overlay color together
    COLOR = mix(COLOR, overlay_color, mix_amount);
}

Specifically, I want:

  • A repeating overlay texture across the whole tilemap (not per-tile UVs)

  • Sampling based on world position

  • Masking using tile color (like the red channel in this example)

Is this achievable in Defold’s tilemap system, or would I need a different approach?

Thanks!