TimmHess / UnrealImageCapture

A small tutorial repository on capturing images with semantic annotation from UnrealEngine to disk.
MIT License
222 stars 49 forks source link

weird camera exposure & color #27

Open safdarzareef opened 1 year ago

safdarzareef commented 1 year ago

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! (Also commented on https://github.com/TimmHess/UnrealImageCapture/issues/8, not sure whether you want a new issue or just the old one.)

TimmHess commented 1 year ago

Hey, maybe I am able to help a little. While issue #8, indeed, look similar, I think the cause could be quite different.

I am assuming that you are using a rather recent engine version 5.1 or 5.2? And that you are making use of global illumination (GI) features judging from the scene setup visible in your renders? Apparently, the SceneCapture2D was skipped in GI up until engine version 5.1 - but now it should be supported. From my experience, you need to tick GI explicitly in the CaptureComponent's post-process settings even when having a PostProcessVolume active (maybe that changed in 5.2). But, be aware that emissive materials and their light emissions might not be rendered correctly (again I only tested in 5.1).

Even though this still not quite explains the blatant color mismatch of the walls, especially since all other objects seem to be rendered correctly (?). But maybe there is something weird happening in the deferred render of CaptureComponent that results in this behavior... Or it might be a combination of GI and Gamma entangling to weird results.

In any case, I hope this gives you a direction to look, unfortunately, I will be rather busy the next 2 weeks so I could only try to interact with you based on your findings but I won't make it to dive deeper myself.

Maybe only one more thing - depending on what you need - you could try looking into MovieRenderQueue plugins for capturing (and annotating). They might not be as versatile but maybe they circumvent issues with the CaptureComponent.

safdarzareef commented 1 year ago

Hey, thank you a lot for your response. I am using 5.1 and GI features. By ticking do you mean doing this: image

If so, that still didn't make a difference, unfortunately. I have two questions:

Thank you so much!

TimmHess commented 1 year ago

I never looked into the RenderQueue because I always felt it was too static for my purposes. But it might as well not be and I just shied away from it... I once saw a render + annotation plugin for it on the marketplace though.

There must be a way to grab buffers directly from a camera. It is not possible with this codebase. But you can check out this blog https://medium.com/@weirdframes/bringing-deep-learning-to-unreal-engine-5-pt-1-aa84c8c05ffa It is targetting a totally different issue, BUT in the process, it reveals how to read pixels from a camera. At some point, I will do an effort to combine this codebase with the solution proposed in the blog above. Maybe you can give it a try :D

TimmHess commented 1 year ago

And about the GI - yes these are the flags I meant. In my test, I placed a SceneCapture with a TextureTarget/RenderTarget for testing purposes, and then ticking exactly these, as you did in the CaptureComponent's settings, at least gave me a change in the render target. But I never tested it together with the capturing code..

safdarzareef commented 1 year ago

Hmm I see, thank you @TimmHess. I'll try changing things around/looking at things, and update it in this thread if I find anything useful.