Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weird camera exposure & color #8

Closed
HaiyiMei opened this issue Mar 2, 2021 · 4 comments
Closed

weird camera exposure & color #8

HaiyiMei opened this issue Mar 2, 2021 · 4 comments

Comments

@HaiyiMei
Copy link

HaiyiMei commented Mar 2, 2021

Hi, It's me again :)
I have one problem. When rendering pictures by code, I got weird camera exposure and color issues. The detail can be seen in the following, the first is the preview screen when hit the play button in the ue4 editor, and the second is rendered by code.

微信截图_20210302163917

000000000018

I'm running the rendering code as you are, including the config of the UTextureRenderTarget2D. I think the problem comes from the config of UTextureRenderTarget2D and I don't know how to modify the config. Am I right or do you know the reason? Thanks a lot~

@TimmHess
Copy link
Owner

TimmHess commented Mar 2, 2021

Hey, this looks very much like a 'gamma' value issue. I assume you do have 'eye adaption' enabled in your camera? - I typically disabled it via an unbound post-process volume and set a exposure bias of 0.0f. I suppose that is how I overcame this issue, because I definitely had these very result myself.

The better fix might be to switch from

renderTarget2D->TargetGamma = 1.2f;

to

renderTarget2D->TargetGamma = GEngine->GetDisplayGamma();

and move this also into the capture function call, such that the render target's gamma is updated for every frame according to the current display gamma.
That would be this line:

void ACaptureManager::CaptureColorNonBlocking(...){
// Re-read the display for the render-target
CaptureComponent->GetCaptureComponent2D()->TextureTarget->TargetGamma = GEngine->GetDisplayGamma();

 // Get RenderConterxt
.... 
}

@HaiyiMei
Copy link
Author

HaiyiMei commented Mar 3, 2021

@TimmHess Precisely! You solved my problem. Thanks for your quick and detailed reply! You are the best 🥇

@HaiyiMei HaiyiMei closed this as completed Mar 3, 2021
@TimmHess
Copy link
Owner

TimmHess commented Mar 3, 2021

Awesome! Glad it worked :)

@safdarzareef
Copy link

safdarzareef commented May 22, 2023

Hi @TimmHess, thanks for this repo. I am having similar issues. Would you be able to help me with it? I tried what you suggested above (the GEngine->GetDisplayGamma() part) but they change very little. Right now, I have:

Editor:
image

Saved Image:
image

I am using jpegs to save by the way - I changed the ERGB format on CameraCaptureManager.cpp Tick() to RGBA. Also changed the pixel format on SetupCameraComponent to PF_R8G8B8A8 to match it.

Thanks a lot for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants