How do I access shadow maps?

Hello,
I’m trying to access the shadow maps once I build the lighting, I know that I can see them in the editor in World Settings > Light Mass > Lightmaps.
But I need to access the actual texture from c++ or BP.

I tried using AWorldSettings, but it contains everything beside the actual texture even if in the editor are shown there.

I have had issues with this myself, but so far I’ve found a way to at least get at the textures:

TArray<UTexture2D*> LightMapsAndShadowMaps;
World->GetLightMapsAndShadowMaps(World->GetCurrentLevel(), LightMapsAndShadowMaps);

You can then iterate over them and save them into their respective files. But the bitmap converters don’t want to serialize shadow maps (because they are encoded as grayscale) and light maps are in what seems like a weird RLE BMP container (not vanilla, that’s for sure).

This is what I’ve got within the iterator:

FBufferArchive Buffer;
bool bSuccess = FImageUtils::ExportTexture2DAsHDR(map, Buffer);

if (bSuccess)
{
	ar->Serialize(const_cast<uint8*>(Buffer.GetData()), Buffer.Num());
}

Can share more code if you like but I also need help finding the UVs for these and actually exporting all of this shadow map data as a usable image file… :confused: