Download

taking screenshots with "scene capture 2d" while in game

hey,
I’m making a small practice game, where the player has a camera that he have to take certain images with, i got a scene capture 2d setup with a scene render 2d texture applied to the camera screen. how can i make it so that when the player presses the mouse button the camera would take an image, in a way that it would be possible to retrieve the images taken from within the game, as the player should be able to see the images he had taken.

thanks in advance!

my work is stuck on this problem, it’s vital that i solve it, any suggestions is welcomed.

is there a way to do it in code ? if there is, please help me out here.

I donated code for this very thing to Rama’s BP plugin ages ago.
I think its still using the old version, but it will get you started :slight_smile:

first, thank you so much for suggesting these, they seem exactly what i need.

i downloaded the plugin and setted it up, and i connected the “capture component 2D save image” to an action trigger (the left mouse button) and setted up a path like this one (D:\Unreal Projects\blueprint_test\TEST save image est001.jpg), when i play the game it would work normally, but once i click the mouse button it crashes… any ideas ?

thanks again for the plug-in.

Got your PM and replied with some updated code.
It’ll make its way int Rama’s plugin at some point.

Kris, I’m having the same crash problem. I don’t know if it’s just the Mac OS X caused the problem?
It took me a while to figure out how to compile the plugin.

Sorry, I have no experience using the save image function on a Mac.
The original code was updated to fix a crash.
This should be in Rama’s plugin by now.
I’ll check with him.

Hi Kris,
Is it possible to get this feature as C++ code? Would much appreciate that.

Rama’s plugin comes with full source and is probably the best place to get it.
It’ll be more up to date then mine :slight_smile:

Kris and Rama,

The CaptureComponent2DSaveImage node is failing consistently for me. As there is no logging info provided I’ve traced the problem in the debugger to:


bool UVictoryBPFunctionLibrary::CaptureComponent2D_SaveImage(class USceneCaptureComponent2D* Target, const FString ImagePath, const FLinearColor ClearColour)
{
	...

	// Format not supported - use PF_B8G8R8A8.
	if (Target->TextureTarget->GetFormat() != PF_B8G8R8A8)
	{
		// TRACEWARN("Format not supported - use PF_B8G8R8A8.");
		return false;
	}


No capture source format that I select will pass this test.

I’m using the scene capture mirror posted by Eric to this thread: Creating a mirror using Scene Capture 2D actor? - UE4 AnswerHub.

If I comment out the test I find that setting the capture source to ‘Final Color (LDR) in RGB’ will give me a good image saved on disk while SceneColor (HDR) creates a mostly black frame.

I don’t have enough info about these formats or image handling to make and submit true fix. It would be very useful if the save node was working and more flexible in terms of the capture source.

Regards,

David

Plus it would be great to optimize this node. I’m lucky if it will produce four jpgs per second and it also reduces game frame rate to about that speed. I’m calling the node from the scene capture mirror BP on the event tick but need to figure out how to move the save to a different thread.

David

Found a significant performance gain by editing the Scene Capture Texture Target. Turning on Texture Render Target 2D | Shared gives a bigger boost than tweaking the target size.