Godot Version
4.6.3
Question
Hi, bit new to the forum, uh, I’m attempting to apply a mask to an AnimatedSprite2D, but I’m having some trouble in properly applying it to said sprite. As far as I can tell, the proper mask seems to be applied correctly only in one frame.
My shader code is the following:
shader_type canvas_item;
uniform sampler2D region_mask;
uniform vec4 border_color : source_color = vec4(0.7, 0.55, 0.2, 1.0);
uniform vec4 core_color : source_color = vec4(0.8, 0.1, 0.1, 1.0);
varying vec2 local_uv;
void vertex() {
local_uv = vec2(UV.x * 8.0, UV.y);
}
void fragment() {
// Called for every pixel the material is visible on.
vec4 frame = texture(TEXTURE, UV);
vec4 mask = texture(region_mask, local_uv);
vec4 result = frame;
result = mix(result, vec4(core_color.rgb, frame.a), mask.g);
result = mix(result, vec4(border_color.rgb, frame.a), mask.r);
COLOR = result;
}
I’m using a 32x32 mask, and the sprite is 256x32.