I'm trying to implement tone mapping along with eye adaptation and HDR. Actually I implemented this already but I'm not satisfied with result and I think that I made something wrong.

My final image (before postprocessing) I store in half float texture. I have also 2 helper textures. The first one stores log luminance and avg, min and max color of it in last mip-map. The second one stores adapt value which is computed as:

prevLum + (avgLum - prevLum) * (1.0 - exp2(-adaptionRate))

where prevLum is previous adapt value (size of this texture is 1x1). Log luminance texture is R8B8G8 format and the second one is R8. In tutorials I saw that half float textures are used but in my case I've got too bright images (almost white).

In the final postprocess shader I'm using all of there values to obtain eye adaptation and tone mapping using this code:

float autokey(in float lum) {
    return 1.03 - 2.0 / (2.0 + log10(lum + 1.0));

float hejl(in float color) {
    float x = max(0.0, color - 0.004);
    return (x * (A * x + B)) / (x * (A * x + C) + D);

float adaptedLum = texture(adaptedLuminance, vec2(0.5)).r;
float exp = exposure * autokey(adaptedLum) / adaptedLum;
result *= exp;

result.xyz=RGB2xyY(result.xyz); // conversion to CIE xyY

result.z = hejl(result.z);


And here is my results:

  • eye adaptation and tone mapping turned on eye adaptation and tone mapping
  • eye adaptation only eye adaptation
  • tone mapping only tone mapping
  • everything off off

As you can see when tone mapping is turned on bunny color is paler. And when eye adaptation is turned on final image is much darker. Could someone explain me what could cause that, because I think that something here is wrong. Maybe it's something with color spaces which I don't understand well? Or with bloom which is applied before tone mapping and eye adaptation?

I have also another strange behaviour with eye adaptation. When I'm looking on dark areas, background (sky) get brighter. It's ok but it happens always when the center of camera is on black area (no matter how far camera is from this area).

I basen on implementation included in projects on this pages: John Chapman, Nutty Software

  • \$\begingroup\$ For a start you should try to disable bloom and only work with what is absolutely necessary. Also if tone-mapping causes your white to become darker, then it probably means, that it doesn't map from 0 - 1 range, and you should either change this, or adapt your lighting accordingly. \$\endgroup\$
    – akaltar
    Jun 19, 2015 at 12:05
  • \$\begingroup\$ Nice work, do you have a link to your project? \$\endgroup\$
    – danijar
    Jul 28, 2015 at 23:25
  • \$\begingroup\$ Thank you. Currently I don't have any link. But I'm going to publish some videos on YouTube or .exe file when I'll finish my master thesis. \$\endgroup\$
    – Harry
    Jul 29, 2015 at 12:26

1 Answer 1


You just don't tonemap bloom, or blur, or depth of field.

Those effects come on top of all other. Try to experiment with the values also.

  • \$\begingroup\$ Thanks, I'll look at it closer when I'll find some time. \$\endgroup\$
    – Harry
    Jul 29, 2015 at 12:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .