Download

How can I copy Render target to UTexture2D ?

Hi,
Everything is in the title, how can I copy data from UTextureRendertarget to UTexture2D.
I tried this code :


UTexture2D* texsample = RenderTarget->ConstructTexture2D(this, "TextureSample", EObjectFlags::RF_NoFlags, CTF_DeferCompression);

But pixels from texsample are all black.

Do you need to create a UTexture2D at runtime?

Because if you need it at runtime, that’s not the way to go. Instead read the pixels from the RenderTarget using the GameThread_GetRenderTargetResource and ReadPixels functions. Once you have a TArray<FColor> you can create a UTexture2DDynamic which is the correct way to create textures at runtime.