Convert LDR to HDR (environment map)

Started by
2 comments, last by Happy SDE 7 years ago

Hi Forum!

I am going to add more than 1 environment map to my game.
Unfortunately, most of good free images I found, are 8-bit LDR.
I converted them to dds cubemaps, and found that final result is not good as native HDR textures.

I am interesting: is it possible to convert somehow LDR to HDR right way?

I am searching for:

0. C/C++ library
1. Command line tool
2. High-level algorithm description / a little bit of theory what to do.
3. [If it is impossible to do it programmatically], some steps for graphic editor like Photoshop.
4. URL where it is possible to download 100+ HDR environment maps for free :)
5. Any other advice.

Thanks in advance!

Advertisement

Well, from a theoretical standpoint, all you need to do to get the HDR-image is undo the tonemapping and exposure/camera correction.

There's many different tonemapping operators, like the common modified reinhard:


float luminance = dot(vExposedColor, float3(0.2126, 0.7152, 0.0722));

float numer = (1 + (luminance * white)) * luminance; // white = 1.0f / (whitePoint * whitePoint)
float denum = 1 + luminance;

float tonemappedLuminance = numer / denum;

return tonemappedLuminance * (vExposedColor / luminance); // => finalColor = tonemappedLuminance * (vExposedColor / luminance)

Since that outputs the final color in an HDR toolchain, you'd have to undo/reformulate that entire formula to get "vExposedColor", while choosing an appropriate whitepoint (you could make that extremely large, or use the simple reinhard instead) - input obviously is the LDR texture color. I'm not entirely sure whether this is possible, ie. if there is going to be one simple result when you undo the tonemapping operator, maybe your math is better than mine and you can see for yourself :)

Next you'd need to undo the exposure correction. If its supposed to be an image taken by a real camera, you can try to emulate that cameras parameters; alternatively you can just play around with a manual exposure constant. If you're interested in the camera-approach, the best source I have is frostbites PBR-papers, page 82:

http://www.frostbite.com/wp-content/uploads/2014/11/course_notes_moving_frostbite_to_pbr.pdf

They explain how you use simulated camera parameters for HDR/Tonemapping, so you could use those operations (computeEV100 etc... in their code samples) to calculate an appropriate exposure coefficient. EDIT: Well, you'd need to specify a manual approximation for the expected average luminance in the HDR-image in that case. There's no "simple" solution for LDR -> HDR in any way, since multiple HDR-images could result in the same LDR-image.

With that in mind, you should be able to implemented a converter; though you'd have to supply manual parameters regardless to what approach you choose, I belive.

There's really not enough information in an 8-bit LDR photograph to recover the original HDR intensities at sufficient precision: the data simply isn't there. Anything that was clipped to black or white is gone forever, and can't be recovered. And even if it wasn't clipped, it will have been quantized to 8-bit which will potentially destroy the precision required to make that data usable at a different exposure level. People who acquire HDR data from photographs will typically use multiple photos taken at different exposures, and will also make use of RAW formatted data that typically contains higher precision and/or dynamic range compared to the final JPEG image saved by the camera. It also has to be combined with careful calibration and specialized algorithms to properly reconstruct the original physical intensities. You can read through these course notes from SIGGRAPH to get an idea of what's involved.

A different approach might be to synthesize the original HDR data using the LDR data input, perhaps using some sort of machine learning algorithm. I'm not personally aware of any research in this area, but it wouldn't surprise me at all if someone was already trying this approach.

Thank you all for responses!

I collected 54 amazing (x6 jpeg) cubemaps from: http://humus.name/index.php?page=Textures

As Juliean pointed out, my problem is probably absence of reverse tone map operator.

I am going to give it a shot. It seems pretty cheap for the moment.

MJP, many years ago I did HDR on my DSLR via 3 images. Probably one day I will back to it (I loved it a lot)! :)

This topic is closed to new replies.

Advertisement