I found out how to use an equirectangular image as a projected texture for projection mapping type scenarios. Maybe it's helpful to someone else, so i'll share it here.
Render an equirectangular panorama of the scene. This needs cycles and the camera set to panoramic instead of perspective.
Save the rendered image.
go to the thing you want to project on, go ...
I am doing texture baking in headless mode and it works for me. Not sure what is the problem with your script but here is my script:
console_handler = logging.StreamHandler(sys.stdout)
log = logging.getLogger(__name__)
cuda_devices, opencl_devices = bpy.context.preferences.addons['cycles']...
First , I see some Overlapped UV islands (may I wrong because of image size).
Second , you should use a checker map to check your UV
then in Substance painter for some materials and texture coordinate you should change Projection on UV or Tri-Planer
Your issue is, you baked only the "diffuse: color", which is only the raw color that the render engine is supposed to use, in addition to other shading infos, to create the final result. If you want the final result, you need to do another kind of baking.
Now the question is, do you want something static that doesn't react to lights, or do you want ...
I think this is not directly possible.
Though, a workaround is to use an intermediate surface which is glass, combined with emission (as this setting darkens the surfaces).
Then, bake (transmission) from it to the target plane.
A and B are inverted from initial setting
As (poor) explanation, my hypothesis about why it works is here:
The transparent BSDF ...
The problems were caused by some non-planar quads as lemon said in the comments. For some reason, the direction in which tris are generated on those specific quads is important. Maybe in the bake, they were autogenerated in the opposite direction. I think that's the case, because when I join vertices to make edges in the opposite direction of the shading, ...