DitheredTransparency.gdshader 420 B

123456789101112131415161718
  1. shader_type canvas_item;
  2. void fragment() {
  3. vec4 tex_color = texture(TEXTURE, UV);
  4. vec4 color = tex_color;
  5. // Get pixel coordinate in texture space
  6. vec2 tex_size = vec2(textureSize(TEXTURE, 0)); // Godot 4
  7. ivec2 coord = ivec2(floor(UV * tex_size));
  8. // Simple checker pattern based on texture pixel positions
  9. bool checker = (coord.x + coord.y) % 2 == 0;
  10. if (checker)
  11. {
  12. discard;
  13. }
  14. }