• Create Account

### #Actualvidel

Posted 08 September 2012 - 08:26 AM

After implementing bloom and some other stuff I got back to my problem with the geometric mean. The problem is, that the render textures obviously can't store negative values. So I just got the value of 1 (the luminance texture is 0 if luminance < e, so I get exp(0) = 1,) for all dark average luminance values. The solution to this would be to map the luminance range to only positive numbers and then convert back to the real range in the exposure correction shader. I know this is done for example with normal maps. But as the range of values in the texture and luminances is not just [0..1] respectively [-1...1] it's not as easy as with normal maps.

My idea would be to define a lower bound for the log of a specific pixels luminance. Then add this value to the log to get only positive numbers. So if the lower bound would be -10, I would add 10 to the log of the luminance. And then substract 10 again just in the exposure shader.
Written in 'pseudocode' it would be something like this (although the shader does this quite different using several downsample blur passes):

sum = log(P1) + 10 + log(P2) +10 + log(PN) +10
sum = sum / N
->store to luminanceTex

lum = exp(luminanceTex - 10)
...

I hope that makes it clear what I have in mind.

Edit/ this approach seams to work, any better ideas though?

### #2videl

Posted 08 September 2012 - 06:52 AM

After implementing bloom and some other stuff I got back to my problem with the geometric mean. The problem is, that the render textures obviously can't store negative values. So I just got the value of 1 (the luminance texture is 0 if luminance < e, so I get exp(0) = 1,) for all dark average luminance values. The solution to this would be to map the luminance range to only positive numbers and then convert back to the real range in the exposure correction shader. I know this is done for example with normal maps. But as the range of values in the texture and luminances is not just [0..1] respectively [-1...1] it's not as easy as with normal maps.

My idea would be to define a lower bound for the log of a specific pixels luminance. Then add this value to the log to get only positive numbers. So if the lower bound would be -10, I would add 10 to the log of the luminance. And then substract 10 again just in the exposure shader.
Written in 'pseudocode' it would be something like this (although the shader does this quite different using several downsample blur passes):

sum = log(P1) + 10 + log(P2) +10 + log(PN) +10
sum = sum / N
->store to luminanceTex

lum = exp(luminanceTex - 10)
...

I hope that makes it clear what I have in mind. Any other ideas?

### #1videl

Posted 08 September 2012 - 06:51 AM

After implementing bloom and some other stuff I got back to my problem with the geometric mean. The problem is, that the render textures obviously can't store negative values. So I just got the value of 1 (the luminance texture is 0 if luminance < e, so I get exp(0) = 1,) for all dark average luminance values. The solution to this would be to map the luminance range to only positive numbers and then convert back to the real range in the exposure correction shader. I know this is done for example with normal maps. But as the range of values in the texture and luminances is not just [0..1] respectively [-1...1] it's not as easy as with normal maps.

My idea would be to define a lower bound for the log of a specific pixels luminance. Then add this value to the log to get only positive numbers. So if the lower bound would be -10, I would add 10 to the log of the luminance. And then substract 10 again just in the exposure shader.
Written in 'pseudocode' it would be something like this (although the shader does this quite different using several downsample blur passes):

sum = log(P1) + 10 + log(P2) +10 + log(PN) +10
sum = sum / N
->store to luminanceTex