I have a 3d polygon mesh and a corresponding 2d polygon mesh (actually from a uv map) which I'm using to map the geometry onto a 2d plane. Given a point on the plane, how can I efficiently find the polygon on which it's resting in order to map that 2d point back into 3d?
The best approach I can think of is to store the polygons in a 2d interval tree, and use that to get candidate polygons. Is there a simpler approach?
Edit: To clarify, this is not for a shader. I'm actually taking a 2D physical simulation and rendering it wrapped around a 3d mesh. For drawing each object, I need to figure out what point in 3d corresponds to its real 2d position.