shader_type canvas_item; // Photoshop-style corner offsets in pixels uniform vec2 top_left = vec2(0.0); uniform vec2 top_right = vec2(0.0); uniform vec2 bottom_left = vec2(0.0); uniform vec2 bottom_right = vec2(0.0); void vertex() { // 1. Calculate UV based on the vertex position relative to size vec2 size = 1.0 / TEXTURE_PIXEL_SIZE; vec2 uv = VERTEX / size; // 2. Linear interpolation to find the offset for this specific vertex // This maps the square to whatever quadrilateral you define vec2 top_row = mix(top_left, top_right, uv.x); vec2 bottom_row = mix(bottom_left, bottom_right, uv.x); vec2 final_offset = mix(top_row, bottom_row, uv.y); VERTEX += final_offset; }