Getting UV coordinates from raytrace hit

One approach is discussed here:

The idea is to create a texture with a gradient and apply it to the model, and then render that into an offscreen buffer from the ray’s position, and render it at a very low resolution. Then you read out the pixel value, and youĺl be able to read the U,V out of the pixel colour.