@block vert uniform vec4 rect; uniform vec2 diffuse_size; void vert() { pos *= vec3(diffuse_size*rect.zw, 1); uv = (uv*rect.zw)+rect.xy; } @end @block frag uniform vec4 border; uniform vec2 scale; uniform vec4 shade; // border given as [left,down,right,top], in scaled coordinates vec2 uv9slice(vec2 uv, vec2 s, vec4 b) { vec2 t = clamp((s * uv - b.xy) / (s - b.xy - b.zw), 0., 1.); return mix(uv * s, 1. - s * (1. - uv), t); } void frag() { vec2 ruv = uv9slice(uv, scale, border); color = texture(sampler2D(diffuse,smp), ruv); if (color.a < 0.1) discard; } @end #include