After a ton of digging around I’ve managed to create an UTextureRenderTarget2D from C++ to capture a LDR screenshot in it using ScreenCaptureComponent2D set to “Final Color (LDR with PostProcess)”.
The screenshot looks ok while displayed on a image widget in the game but it’s much darker after saving it to a PNG file. I assume it’s something caused by the gamma correction but I’ve literally tried all combinations of rendertarget texture settings that came to mind to try to make it look ok but without any success.
Theoretically I would have to save it to disk without any gamma correction so that when viewing externally it gets gamma corrected again and it should look ok. Now it looks as it’s being double gamma corrected. But the question is HOW in UE4?
I’m saving the texture to disk exactly as described here:
To create the rendertarget texture from code I do this (in case it helps someone else):
UTextureRenderTarget2D *rtResult = NewObject<UTextureRenderTarget2D>();
rtResult->ClearColor = FLinearColor::Black;
rtResult->InitCustomFormat(width, height, PF_B8G8R8A8, true);
What am I missing?
Any suggestions are welcomed.
Here’s what I see after saving to PNG:
free upload
Here’s what it should like (when taking screenshot from UE4 directly):
image upload no limit