Multiply RGB by luminance or working in CIE ? Which is more correct ?

Started by
17 comments, last by MegaPixel 11 years, 6 months ago

[quote name='MegaPixel' timestamp='1348574474' post='4983535']
So that means that I can post multiply the RGB color with the adjusted luminance before to run it through the filmic curve or after ?

It is the question of what you want to archieve.

If you just want to fake the human eye (adjusting to the darkness), then it would be worth an attempt. According to the filmic tonemapper function here, I would just alter the ExposureBias according to the average luminance. It is more like playing around with the mapper until it looks good vs. a physical correct solution.
[/quote]

so that means that I should use

float relativeLuminance = (fragmentLuminance / (averageSceneLuminance+0.0001f))*key;


to modulate the color without run it into the Reinhard tonemapper:


float tonemappedLuminance = (relativeLuminance*(1.f+(relativeLuminance/(Lw*Lw)))) / (1.f+relativeLuminance);).


so for the filmic curve should be:


finalColor *= relativeLuminance;
finalColor = max(0.f,finalColor-0.004f);
float4 gammaColor = (finalColor*(6.2f*finalColor+0.5f))/(finalColor*(6.2f*finalColor+1.7f)+0.06f);
//out the color applying gamma correction
return gammaColor+pow(bloomColor,1.f/2.2f);


(no CIE to RGB needed in this case as the filmic curves works in RGB space straight away)
Advertisement

[quote name='MegaPixel' timestamp='1348574474' post='4983535']
So that means that I can post multiply the RGB color with the adjusted luminance before to run it through the filmic curve or after ?

It is the question of what you want to archieve.

If you just want to fake the human eye (adjusting to the darkness), then it would be worth an attempt. According to the filmic tonemapper function here, I would just alter the ExposureBias according to the average luminance. It is more like playing around with the mapper until it looks good vs. a physical correct solution.

Simple example (don't know if it look good):

ExposureBias = 1.5 + (1.0-avgLumi);

[/quote]

I understand the idea of tweaking etc. but I'd like first to understand the correct underlying theory and then tweak from there. If you work on the avgLum directly means that you are not using the scaled one L(x,y) / avgLum which is the pixel relative luminance (assume key =1 ) ... see Reinhard for reference

I would just alter the ExposureBias according to the average luminance.

Don't do that. The exposure bias is part of Hable's tone mapping operator. It's there to assure that the average luminance (1) gets mapped to 0.5. Otherwise it would be way brighter. You don't need that with other tone mapping operators though.

BTT: I'm not quite sure what you guys are doing. It's this easy:


float3 color = sampleColor(texCoord);
float3 bloomColor = sampleBloom(texCoord);

//Add the bloom (bloomFactor is some constant, 0.0075f is a good value imho)
color += bloomFactor * bloomColor;

//Calculate the exposure (this is the simplest way to do it)
float exposure = 1 / averageLuminance;

//Adjust the exposure
float3 color *= exposure;

//Map the color to LDR (Serr tone mapping operator, the same as Hables standard values)
float3 tonemappedColor = 4.6f * color / (3.6f * color + 5.6f);

//Adjust gamma and return (ajusting gamma might not be needed)
return pow(tonemappedColor, 1/2.2f);

[quote name='Ashaman73' timestamp='1348577752' post='4983548']
I would just alter the ExposureBias according to the average luminance.

Don't do that. The exposure bias is part of Hable's tone mapping operator. It's there to assure that the average luminance (1) gets mapped to 0.5. Otherwise it would be way brighter. You don't need that with other tone mapping operators though.

BTT: I'm not quite sure what you guys are doing. It's this easy:


float3 color = sampleColor(texCoord);
float3 bloomColor = sampleBloom(texCoord);

//Add the bloom (bloomFactor is some constant, 0.0075f is a good value imho)
color += bloomFactor * bloomColor;

//Calculate the exposure (this is the simplest way to do it)
float exposure = 1 / averageLuminance;

//Adjust the exposure
float3 color *= exposure;

//Map the color to LDR (Serr tone mapping operator, the same as Hables standard values)
float3 tonemappedColor = 4.6f * color / (3.6f * color + 5.6f);

//Adjust gamma and return (ajusting gamma might not be needed)
return pow(tonemappedColor, 1/2.2f);

[/quote]

you run the tonemapping process even whem you have to perform the bright pass ? I guess yes since you want to cut the luminance under a given threshold value... ?

[quote name='CryZe' timestamp='1348579184' post='4983559']
[quote name='Ashaman73' timestamp='1348577752' post='4983548']
I would just alter the ExposureBias according to the average luminance.

Don't do that. The exposure bias is part of Hable's tone mapping operator. It's there to assure that the average luminance (1) gets mapped to 0.5. Otherwise it would be way brighter. You don't need that with other tone mapping operators though.

BTT: I'm not quite sure what you guys are doing. It's this easy:


float3 color = sampleColor(texCoord);
float3 bloomColor = sampleBloom(texCoord);

//Add the bloom (bloomFactor is some constant, 0.0075f is a good value imho)
color += bloomFactor * bloomColor;

//Calculate the exposure (this is the simplest way to do it)
float exposure = 1 / averageLuminance;

//Adjust the exposure
float3 color *= exposure;

//Map the color to LDR (Serr tone mapping operator, the same as Hables standard values)
float3 tonemappedColor = 4.6f * color / (3.6f * color + 5.6f);

//Adjust gamma and return (ajusting gamma might not be needed)
return pow(tonemappedColor, 1/2.2f);

[/quote]
[/quote]

you run the tonemapping process even whem you have to perform the bright pass ? I guess yes since you want to cut the luminance under a given threshold value... ?
Also can you point me to some good reading to understand first the simplest way instead of just applying Reinhard or whatever other tonemapper blindly ? thanks in advance for your help ;)
Btw I tried your serr approach and my scene looked way too much bright and I have just one pointlight !

you run the tonemapping process even whem you have to perform the bright pass ? I guess yes since you want to cut the luminance under a given threshold value... ?

There's no need for a bright pass with a threshold value if you actually have high dynamic range values. Threshold values for bloom are from back in the days where you couldn't afford the bandwidth for HDR illumination. Bright lights are thousands if not millions of times brighter than the rest of your scene (or at least they should biggrin.png). By simply using a multiplicative factor you reduce the amount of bloom so that only the bloom of these really bright lights is visible. So there's no need for either a bright pass or a threshold value for bloom. A threshold value is just not realistic. Lenses always scatter a tiny percentage of the light onto nearby pixels (depending on the quality of the lenses), they never subtract light.

[quote name='MegaPixel' timestamp='1348579435' post='4983562']
you run the tonemapping process even whem you have to perform the bright pass ? I guess yes since you want to cut the luminance under a given threshold value... ?

There's no need for a bright pass with a threshold value if you actually have high dynamic range values. Threshold values for bloom are from back in the days where you couldn't afford the bandwidth for HDR illumination. Bright lights are thousands if not millions of times brighter than the rest of your scene (or at least they should biggrin.png). By simply using a multiplicative factor you reduce the amount of bloom so that only the bloom of these really bright lights is visible. So there's no need for either a bright pass or a threshold value for bloom.
[/quote]

So you scale down the color intensity by some factor before gaussian blur is applied (like during the downsampling of the scene something like sceneColor*threshold)? But it doesn't seem to be effective, because what I actually want is for only some part of the scene to glow and I don't want to see all the scene blurred ...
It doesn't matter whether you do it before or afterwards. I do it when combining it with the source color again. But the result is the same either way. Not everything will be blurred. Like I said, with proper high dynamic range, it won't happen. Simply decrease the factor to something where not everything is glowing and increase the luminance of everything you want to see glowing (you might need to make them thousands of times brighter, but this is actually realistic). And that's why you need the tone mapper. The tone mapper will reduce their perceived luminance and lets them look like they wouldn't actually be thousands of times brighter.

The sun in my engine is for example 6.5 million lux while shadows on a sunny day are just 10,000 lux, nights are 0.005 lux.

It doesn't matter whether you do it before or afterwards. I do it when combining it with the source color again. But the result is the same either way. Not everything will be blurred. Like I said, with proper high dynamic range, it won't happen. Simply decrease the factor to something where not everything is glowing and increase the luminance of everything you want to see glowing (you might need to make them thousands of times brighter, but this is actually realistic). And that's why you need the tone mapper. The tone mapper will reduce their perceived luminance and lets them look like they wouldn't actually be thousands of times brighter.

The sun in my engine is for example 6.5 million lux while shadows on a sunny day are just 10,000 lux, nights are 0.005 lux.


How you define a lux in your engine ?

Also to have good bloom I was thinking to downsample 5 times, something like:

1) blur while downsampling the scene for the first time
2) blur while downsampling to the next level
...
till 5) ...

then:

upsample each downscaled version of the previous 5 steps JUST to the previous level (so don't stretch a given level to fullscreen?) looks like Epic is doing like this in unreal engine 4 ...
I just have the doubt that they actually stretch each level to fullscreen while adding them together ... can you confirm on that ?

This topic is closed to new replies.

Advertisement