Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I implement HDR in my graphics engine (deferred rendering) based on this document: link I save a luminance in a texture (RGBA16F) this way:

const float delta = 1e-6;
vec3 color = texture(texture0, texCoord).xyz;
float luminance = dot(color, vec3(0.2125, 0.7154, 0.0721));
float logLuminance = log(delta + luminance);
fragColor = vec4(logLuminance, logLuminance, 0.0, 0.0); 
// first channel stores max luminance during a minification process

Then I can calculate an average luminance and find a max luminance.

The delta = 1e-6. Is that a good choice ?

Can I calculate "a" (equation 2) dynamically to achieve better results ?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

First, the 1e-6 delta: this may well be fine, but it depends on the range of HDR luminances present in your scene. If your typical luminances are on the order of magnitude of 1 or higher, then 1e-6 should be fine, but if you have very dark scenes where the typical luminance can get down to 1e-4 or so, then 1e-6 as a delta might be too large.

As for the value a = 0.18 in the Reinhard et al paper, they indeed mention dynamically adjusting it, but it's not very clear how this is done:

For low-key or high-key images we allow the user to map the log average to different values of a. We typically vary a from 0.18 up to 0.36 and 0.72 and vary it down to 0.09, and 0.045.

It sounds to me like it's a user control, where the user is explicitly setting the image to appear brighter or darker (higher or lower a). This would be akin to the brightness setting that many games have, although I think that usually just applies a gamma curve to the post-tonemapping LDR image rather than altering the tonemapping equation. In any case, it's not clear how you would choose this value programmatically if you didn't want to make it a user control.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.