I’m working on a script for the last week that takes a series of images and saves them as .png/.jpeg to the drive
My method is as follows:
From a CameraActor object:
- Initialize a USceneCaptureComponent2D, then an FTextureRenderTarget2DResource
- Set the render target variable of the USceneCaptureComponent2D to the FTextureRenderTarget2DResource
- set the setCameraView() of the USceneCaptureComponent2D to the getCameraView() of the CameraActor camera component
- ??? Save to file
I’ve looked at several solutions online and they tend all be outdated, for example this solution here uses FHighResolutionScreenshotConfig.SaveImage(), which is removed in UE4.21:
My only other option would be:
- set the readPixels() of the FTextureRenderTarget2DResource to a buffer
- Every tick: Save the contents of the buffer to a file using a c++ png library