How can I render a camera's image to a texture from a blueprint?

I’ve been going on a while goose chase trying to figure this out. Every topic I find talks about using the console to take screenshots.

I want to be able to render a camera’s image to a texture while in-game, and then save that texture to a file (jpg, png, whatever) at a location of my choosing. How can I go about this using blueprints?

You can use SceneCaptureComponent2D for this. You will have to create a ‘render Target’ for this in the editor (create it like a normal texture) and then set this as target for the SceneCaptureComponent2D.

But be aware: Even if you deactivate ‘update every frame’ this will still update when it moves.

Unfortunately, this is precisely what I want to avoid. I don’t want any additional renderings going on in my scene until the precise moment I want to take a screen capture. Is there any other way of going about it?

Unfortunately this is the only thing I can think of right now. I entered in a bug about scene captures updating all the time. They really should respect an “active” state.

In general this is somewhere the engine has a long way to go. There is a way to “create static texture” by right clicking the render target but I am not aware of any way to call this using blueprints without doing some code work.

Yeah, took me almost a day to find that out. I used a capSceneCaptureComponent2D attached to my player pawn to take screenshots (should be possible from the camera component IHMO). I disabled ‘update every frame’ but it still fired every frame because it was moved. So I removed it.

You have two options.

  1. You could extend SceneCaptureComponent2D C++ class and override some function in the chain of functions responsible for updating the texture, and put an if statement on it. You’ll add a boolean member to the class whose default is false, and which is used as the if statement’s condition. Within the result of the if statement you’ll set the bool to false again. Then you’ll make a new ufunction which will allow a designer to set the bool to true using a blueprint. Viola, you have a snap camera. It will only capture one frame of the scene when prompted.

  2. An alternative would be to have the blueprint responsible for taking a picture, do so by spawning the SceneCaptureComponent2D, doing what it needs to do with it, and then destroying it. This would be less optimal, but would produce more or less the same end result.

1 Like

,hi guys

i managed to use scenecapture2d for a pic in pic camera during game,using profilegpu command,founded that it s compounding frame time about 15ms

so i changed code in a way that when user closes pic in pic, scenecapture 's texture target i set to none.(deactiving didnt help)

now when the pic in pic is hidden it dosent increase render time.

thouth may help.

Hi guys! I’m going through a similar situation.
I’m using a SceneCaptureComponent2D to render to a RenderTarget. I want to save that RenderTarget as a .jpg/.png on the computer, but it saves a file that is unreadable.
Il there a way to simply save this image in one of this common files?
Thanks for the help.

just add “.png” to the file name