Sign in to follow this  
Happy SDE

Convert LDR to HDR (environment map)

Recommended Posts

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!

Edited by Happy SDE

Share this post


Link to post
Share on other sites

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.

Edited by Juliean

Share this post


Link to post
Share on other sites

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)! :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this