Sphere surface picking

Im currently trying to create an application where you can draw on the surface of a sphere.

At the moment I’m having trouble working out exactly on the sphere the user has clicked, then converting that to a point within the texture.

Any help would be appreciated, if someone gave me the steps I’m sure I cold covert it to code.

If you only want the texture coordinate, just render the object with texture coordinates as color in an offscreen renderpass and read out the pixel at the mouse position.