shader_type canvas_item; uniform float rows = 44.0; // Really int but don't want to recast all the time uniform float cols = 63.0; // ^ uniform vec4 color_unmarked: hint_color = vec4(0.5, 0.5, 0.5, 1.0); uniform vec4 color_marked: hint_color = vec4(0.0, 0.0, 1.0, 1.0); uniform vec4 color_crossed: hint_color = vec4(1.0, 0.0, 0.0, 1.0); uniform float line_thickness = 0.1; // Cell scale uniform float line_offset = 0.05; // Should be half of thickness to be centered, but might need tweaking for small values void fragment(){ vec2 frag_pos = UV * vec2(cols, rows); bvec2 frag_marginal = lessThan(fract(frag_pos+line_offset), vec2(line_thickness)); bvec2 frag_marginal_x = lessThan(fract(frag_pos-0.425), vec2(0.15)); // vec2 grid_data = texture(TEXTURE, (frag_pos+line_offset)/vec2(cols+1.0, rows+1.0)).rg; // float grid_data_s = texture(TEXTURE, ((frag_pos+line_offset)/vec2(cols+1.0, rows+1.0)).yx).a*128.0; //*17.0; // COLOR = vec4(grid_data_s, grid_data_s, grid_data_s, 1.0); int grid_data_s = int(texture(TEXTURE, ((frag_pos+line_offset)/vec2(cols+1.0, rows+1.0)).yx).r*255.0); ivec2 grid_data = ivec2(grid_data_s%4, grid_data_s/4); COLOR = vec4(0.0); if (frag_marginal.x){ if (grid_data.g >= 2){ if (frag_marginal_x.y) COLOR = color_crossed; }else if (grid_data.g == 1){ COLOR = color_marked; }else COLOR = color_unmarked; } if (frag_marginal.y){ if (grid_data.r >= 2){ if (frag_marginal_x.x) COLOR = color_crossed; }else if (grid_data.r == 1){ COLOR = color_marked; }else COLOR = color_unmarked; } // if (frag_marginal.x){ // if (grid_data.g >= 0.99){ // if (frag_marginal_x.y) // COLOR = color_crossed; // }else if (grid_data.g >= 0.49){ // COLOR = color_marked; // }else // COLOR = color_unmarked; // } // if (frag_marginal.y){ // if (grid_data.r >= 0.99){ // if (frag_marginal_x.x) // COLOR = color_crossed; // }else if (grid_data.r >= 0.49){ // COLOR = color_marked; // }else // COLOR = color_unmarked; // } }