Download

Capture a single frame into a texture.

I’m trying to make a blueprint that takes a screenshot and saves it as a texture variable in a blueprint rather than saving it as an image file. I thought I would have been able to do it with Scene Capture 2D, but even with “Capture Every Frame” off, it still updates when the camera moves and deletes the texture when closing and then opening the game. I’ve been looking for a way to do this, but all the results I find are for the High Res Screenshot command or about using Scene Capture for mirrors and TVs. Is there a way to actually d this that I’m just not seeing?

If you want to have the image available after closing and reopening the game there is no other way to do so then to save it to disk. During runtime you can keep things in memory, but unless you save them, everything in memory will be lost when you close the game and will have to be recreated on a restart.

I am saving them with a Save Game blueprint. Whatever I saved loads fine as long as I don’t close the game, which defeats the purpose of saving in the first place. So I’m not sure if I’m doing something wrong with my saving blueprint.

The problem is probably not in this blueprint. My guess is that it properly saves a reference to a SceneCaptureActor, just not the image generated by it.

I would still think it’s easier to directly save your image to disk, but if you want to continue with your current approach you should see if you can somehow access the framebuffer that is generated by the SceneCaptureActor.

SceneCapture2D’s take a UTextureRenderTarget2D for their output. Can you get a reference to that texture and save it?

From code you can grab the UTextureRenderTarget2D from code like this:

[FONT=Courier New]// USceneCaptureComponent2D *SceneCapture

FTexureRenderTarget2DResource *Texture = (FTextureRenderTarget2DResource *) SceneCapture->TextureTarget->Resource;
TArray<FColor> ColorBuffer;
Texture->ReadPixels(ColorBuffer);