Godot Version
4.2
Question
While trying to apply a shader to an animated TileMap, it seems my shader is being applied per-tile? my shader looks like this:
Without my Shader it looks like this:
https://i.imgur.com/RdmptHu.png
I’m using a shader that applies a mask generated from a BitMap that matches the shape of a Polygon2D, resulting in a black and white image like this:
https://i.imgur.com/oLq6jV1.png
The shader turns the black into alpha and then uses the alpha to mask the TileMap, but it’s not working as expected, how can I make it apply to the entire tilemap?
Current Shader Code:
shader_type canvas_item;
uniform bool on = false;
uniform sampler2D polygon_texture;
uniform bool invert_mask = false;
void fragment() {
if(on==true){
vec4 color = texture(TEXTURE, UV);
vec4 polygon_alpha = texture(polygon_texture, UV);
if (polygon_alpha.r == 0.0 && polygon_alpha.g == 0.0 && polygon_alpha.b == 0.0) {
polygon_alpha.a = 0.0;
}
if (invert_mask == true) {
polygon_alpha = 1.0 - polygon_alpha;
}
if (polygon_alpha.a == 0.0)
{
color.a = 0.0;
}
COLOR = color;
}
}
(Sorry for the mix of 1 embed and 2 links, new folk have limits on what they can use in the forums)