How to tonemap HDR Screen Capture Cube (ODS) output?

I’m using ODS (TextureTargetLeft | Unreal Engine Documentation) so I’ve got two HDR outputs I would like to output in LDR, the problem is that Screen Capture Cubes are always HDR so I’m not sure how to tonemap these so they basically look the same as they did in engine and output as a R8G8B8 .png or something.

I found that a shader is used to combine the Screen Capture Cubes into the render target 2d: UE_4.22\Engine\Shaders\Private\ODSCapture.usf. I saw some tonemap stuff in TonemapCommon.ush but all I managed to accomplish was crash the engine.

Is there an easy way to convert the float4 color in ODSCapture.usf to a tonemapped gamma corrected LDR output?

Depends on if you care about preserving the highlights. A Linear to sRGB gamma transform would suffice, whether it’s the super simple pow function or the more complex function that keeps the linear toe in a sRGB image.

Since you have the original scene-referred linear image you have a lot of freedom as to how you want to tonemap it if you want to preserve any details in the upper range. You could rebuild Hejl, Reinhard, Uncharted/Hable, etc. UE4 uses ACES by default which can be seen in TonemapCommon.ush in ACESOutputTransformsRGBD65 for standard sRGB displays. But if you want something simple, you can use Stephen Hill’s or Krzysztof Narkowicz luminance fits * 1.5 to match Unreal as close as possible.

Thanks!

I used ACESOutputTransformsRGBD65() and it looks perfect. I was a bit confused at first because the result wasn’t the same as in the viewport, but it turns out I had some color grading in the post process volume which wasn’t reflected in the screen capture cube. After removing that and changing the lighting it looked really good. Here’s an example (from an Epic sample)