Jump to content
  • Advertisement
Sign in to follow this  
Happy SDE

Convert LDR to HDR (environment map)

This topic is 590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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:


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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!