for generating light maps it's the other way around. there you already have the triangle and its uvs. you have to rasterize the triangle and convert each pixel's uv-coordinate to a 3d-coordinate and trace to the light from there. i think that's the easy part. the hard part is the algorithm which automatically creates a good uv-map.