How to get the start of a uv position?

Hi. I’m trying to make a distorted shader for GUI

The shader works fine if the there is only one image in a texture, but when there is a second image the shader doesn’t function well, due var_texcoord0.x < 0.5 is no longer the center of the image

My question, is there anyway to tell if vertex is in the on the right / left part of the box?

uniform highp mat4 view_proj;

// positions are in world space
attribute mediump vec3 position;
attribute mediump vec2 texcoord0;
attribute lowp vec4 color;

varying mediump vec2 var_texcoord0;
varying lowp vec4 var_color;

void main() {
  var_texcoord0 = texcoord0;
  var_color = vec4(color.rgb * color.a, color.a);
  
  vec3 pos = position;
  float xSkew = 0.0;
  float ySkew = position.z;
  pos.z = 0.0;
  if (var_texcoord0.x < 0.5) {
    ySkew = -ySkew;
  }
    
  mat4 transform = mat4(
      1,xSkew,0,0,
      ySkew,1,0,0,
      0,0,1,0,
      0,0,0,1);        
  
  
  gl_Position = view_proj * transform * vec4(pos.xyz, 1.0);
}

For a rectangular GUI object, its GLSL vertex input gl_VertexID (undocumented for Defold) should make local X identifiable with a little trial & error, since position is in world space instead of local.

It’s just built in, it’s not an attribute:

int vertex_id = gl_VertexID;

The problem with gl_VertexID is when having multiple gui node, how do we know which id belong to the target node?