Differentiation between meshes in a shader

I want to draw several meshes inside a shader pass but I would like to know if any of the vertices of meshA are intersect with meshB. I know I can iterate through all the points of meshA and check if they exist in meshB but that is a very lengthy process and it seems like a good job for a shader.

Pseudo code would be:


Texture A.unbind();

Texture B.unbind();


One thing I could think of is to construct meshB with coordinates in a larger scale (so meshA in meters and meshB in mm) then I can check if the coordinates are over a certain size and I can know which mesh they belong to. Then when I have separated them and performed my checking I can scale them to the correct size again.

Is there any other way to do such a thing?