Also posted this here
This short story is that ReadPixels is returning an array of the right size but garbage data. Sometimes it points at random texture data but typically its pretty random:
UTexture2D *USharedRenderTarget::Create2DTexture() const
{
UTexture2D *p2dTex = UTexture2D::CreateTransient(RenderTexture->SizeX, RenderTexture->SizeY, PF_B8G8R8A8);
#if WITH_EDITORONLY_DATA
p2dTex->MipGenSettings = TMGS_NoMipmaps;
#endif
p2dTex->SRGB = RenderTexture->SRGB;
// Read the pixels from the RenderTarget and store them in a FColor array
TArray<FColor> SurfData;
FRenderTarget *RenderTarget = RenderTexture->GameThread_GetRenderTargetResource();
**RenderTarget->ReadPixels(SurfData);**
It seems like this should be possible and the workaround that’s come to mind (use UIImage Objective C functionality to do what I’m doing) is both annoying to implement and inferior in the long term.
Right now I’m saving the data into a jpg. It works on PC, is untested on MAC, fails on iPhone.
Any idea how to get the pixel array for the top mip of a render target?