     }
     f *= boxes_opacity;
   } else if (static_tile >= 1.) {
-    vec2 number_tex_uv = (vec2(mod(static_tile, frames_per_axis), floor(static_tile/frames_per_axis)) + normalized_uv) * tile_size / sprite_size;
+    vec2 number_tex_uv = (static_tile_coords(static_tile) + normalized_uv) * tile_size / sprite_size;
     f = mix(f, 1., texture2D(static_sprite, number_tex_uv).a);
   }
 
   // Blend static outline on top
-  vec2 outline_tex_uv = (vec2(0.) + normalized_uv) * tile_size / sprite_size;
+  vec2 outline_tex_uv = (static_tile_coords(0.) + normalized_uv) * tile_size / sprite_size;
   f = mix(f, 1., texture2D(static_sprite, outline_tex_uv).a * border_opacity);
 
   // Blend flash on top
-  vec2 flash_tex_uv = (vec2(9., 0.) + normalized_uv) * tile_size / sprite_size;
+  vec2 flash_tex_uv = (static_tile_coords(9.) + normalized_uv) * tile_size / sprite_size;
   f = mix(f, 1., texture2D(static_sprite, flash_tex_uv).a * flash_opacity);
 
   // Change color according to highlight setting

uniform sampler2D idle_sprites[4];
uniform sampler2D static_sprite;
uniform vec2 paddings;

void main() {
  vec4 white = vec4(1.);

  float border_opacity = dynamic_tile_data_b2.z;
  float boxes_opacity = dynamic_tile_data_b2.w;



  float f;
  if(static_tile < 0.) {
