 
 out ivec2 out_pos;
 uniform vec4 mask = vec4(1,1,1,0);
+uniform int XOR = 0; // 1 to invert mask
 uniform sampler2D	tex_mask;
 
 void main(){

  // bool mask = any(notEqual(texelFetch(tex_mask, pos, 0).rgb, vec3(0.0)));
  // out_pos = mask ? pos : ivec2(POS_MAX);
  
  ivec2 pos = ivec2(gl_FragCoord.xy);
  vec4 xyzw = texelFetch(tex_mask, pos, 0);
  out_pos = (all(equal(xyzw, mask))) ? pos : ivec2(POS_MAX);
}

#endif // PASS_INIT

ivec2 dtnn = ivec2(POS_MAX);
int   dmin = LENGTH_SQ(dtnn);

void DTNN(const in ivec2 off){
  ivec2 dtnn_cur = getDTNN(tex_dtnn, off);
  ivec2 ddxy = dtnn_cur - pos;
  int dcur = LENGTH_SQ(ddxy);
