Jump to content
  • Advertisement
Sign in to follow this  
Prune

Which color space for tone-mapping?

This topic is 3789 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

I notice that GLSL examples apply tone mapping to RGB values directly, which seems to me would be incorrect. However, I'm having trouble figuring out which color space to do the conversion in. Luminance is already in such examples computed as a weighted sum from RGB using matrix values I see used for Y in XYZ color space. Once the luminance is mapped, (I use Y = Y * (Y / (maxY * maxY) + 1.0) / (Y + 1.0); ) I've seen examples where they simply multiply it into the original RGB values. How can that be right? I did try to extract X and Z as well and then convert the XYZ after tonemapping Y back to RGB, but I'm not getting a sensible result...

Share this post


Link to post
Share on other sites
Advertisement
Hi, I am quite ignorant on this subject, but AFAIK the pbrt raytracer uses XYZ for the color calculations, and it provides tone mapping so I suppose that it is the right (or a reasonably good) way to do it. From the site you can download the source.
Hope this helps

Share this post


Link to post
Share on other sites
Hi Prune,

I'm experimenting with tomemapping the past few days as well, and as you said, i've also seen a few of demos where they just multiply the HDR RGB value with the adapted luminance. I suppose there is an explanation behind this, but i haven't actually searched for it. Instead, i did what seemed more logical to me. I tried RGB to XYZ, adapt Y and back to RGB as you said. It seems that in XYZ space you can't modify luminance (Y) and get the same color back (either darker or brighter).

What i found out is that you can convert XYZ to Yxy, alter Y and convert back to XYZ (and from there to RGB) and the color will stay (almost?) the same with a different brightness. From this:
Quote:

It is often convenient to discuss "pure" colour in the absence of brightness. The CIE defines a normalization process to compute "little" x and y chromaticity coordinates:
...


Probably by doing all the math on paper (RGB->XYZ->Yxy, alter Y, Yxy->XYZ->RGB) you will find the explanation behind the direct multiplication of RGB values with the adapted luminance.

Hope that helps.

HellRaiZer

EDIT : Forget about Yxy. You can try it and see that it works, but there is actually an explanation behind what most demos do. If you do the math you will find out that the whole thing boils down to :


ldr_RGB = hdr_RGB * (adapted_luminance / hdr_luminance);


I hope i haven't done any mistakes. This will make your shaders a lot simpler :)

Share this post


Link to post
Share on other sites
It is true that doing it in RGB space is technically wrong.

The problem is, even if you do it "the right way", you'll have trouble to decide which one looks "better".

So what most people do ( including me ) is to go for the simplest/fastest solution, RGB space.

Y.

Share this post


Link to post
Share on other sites
Wrong, right, there is none.

Tone mapping is taking a high dynamic range picture (one that has data from very small values to very high values) and compress it to a very small range (0..255 integers). That compression will lose some info whatever route you take. The control you have is where you'll lose this info. Some people will prefer to lose brightness info to saturation info. Some prefer to preserve hue, other will want a maximum contrast. Other will prefer to preserve "saliency" at the expense of truth.

There is no right and wrong answer.

Share this post


Link to post
Share on other sites
Preserving hue, although it avoids the 'washing out' effect, can often lead to very unnatural images.

I usually prefer a weighted mix of a standard RGB space tonemap and a hue preserving tonemap.

Share this post


Link to post
Share on other sites
Any shader code you care to share, or a general algorithm you use to do this tonemapping?

Share this post


Link to post
Share on other sites
Quote:
Original post by LeGreg
Wrong, right, there is none.

I disagree. The way it should be done is one that makes the least visual difference in the human visual system from an equivalent image displayed on an HDR screen. The same way audio and video codecs are studied in blind testing with human subjects needs to be applied here to find an approximately optimal mapping operator.

Share this post


Link to post
Share on other sites
Quote:
Original post by Prune
Quote:
Original post by LeGreg
Wrong, right, there is none.

I disagree. The way it should be done is one that makes the least visual difference in the human visual system from an equivalent image displayed on an HDR screen. The same way audio and video codecs are studied in blind testing with human subjects needs to be applied here to find an approximately optimal mapping operator.


Evaluation of Tone Mapping Operators using a High Dynamic Range Display

Suprisingly the the answer might be different when choosing the "best" TMO with/without reference image.

Share this post


Link to post
Share on other sites
Quote:
Original post by stephanh
Suprisingly the the answer might be different when choosing the "best" TMO with/without reference image.

That's a failure of the specific study mentioned, not the concept that blind testing of perception is the correct approach.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!