I’m trying to map a square slice of an equirectangular image inside a cubemap with 6 faces, without distortion.

The point is that I’m dealing with huge array sizes if I try to project the whole equirectangular texture (because the circumference is Earth-like), so I’m cutting it into pieces on demand, with a higher detail.

I need to convert/project this square image (512*512px) which is covering 0.08° of the 360*180 degrees that the equirectangular image provides. The total circumference is 44053660mts. and the offset is 34.5° Lat and 56.8 ° Lon. (These values would change, but not the circumference)

Can you help me to find a way to project that image onto a cubemap?

I already have an algorithm to make a cubemap from the full equirectangular image but can’t find a way to do the same with just a squared portion of it.

Thanks!