traditional subtracting bright pass filter and LDR

shuipi

Newcomer
// Subtract out dark pixels
sample.rgb -= g_BrightPassThreshold;

// Clamp to 0
sample = max(sample, 0.0f);

These are straight copy from the DX sdk. But in the case of LDR, the subtracting step is a significant change to the rgb ratios in the original sample color, which causes the color of the bloom to be incorrect. Is there any good way to do this for LDR?
 
You can try clamping the color to zero if it is below a certain threshold value.

ie.
Code:
if(dot(sample.rgb, float3(0.33,0.33,0.33)) < g_BrightPassThreshold)
         sample.rgb = float3(0,0,0);
However, I'm not sure if you need dynamic branching (and thus SM3 or greater) to perform this operation in the pixel shader.
 
You can try clamping the color to zero if it is below a certain threshold value.

ie.
Code:
if(dot(sample.rgb, float3(0.33,0.33,0.33)) < g_BrightPassThreshold)
         sample.rgb = float3(0,0,0);
However, I'm not sure if you need dynamic branching (and thus SM3 or greater) to perform this operation in the pixel shader.
That should be compiled as a branchless conditional select operation even on modern hardware and should work on any SM2+ hardware AFAIK.
 
// Subtract out dark pixels
sample.rgb -= g_BrightPassThreshold;

// Clamp to 0
sample = max(sample, 0.0f);

These are straight copy from the DX sdk. But in the case of LDR, the subtracting step is a significant change to the rgb ratios in the original sample color, which causes the color of the bloom to be incorrect. Is there any good way to do this for LDR?
If you want the hues to stay the same you should calculate a luminance for the colour, subtract from it, clamp to 0, then multiply the colour with the new luminance divided by the old luminance.

Code:
float lum = dot(sample.rgb, float3(0.299, 0.587, 0.114)); // ITU-R BT.601 luma coefficients
float lum2 = max(lum - g_BrightPassThreshold.x, 0.0f);
sample.rgb *= lum2 / lum;
 
Would use of Rec.709 coefficients, which are the same as sRGB as far as I can tell, produce the same result?
What a weird question. Of course the result will be slightly different if you use slightly different coefficients. :D
 
Aha, so is the difference worth much? I dare say it stuck out to me using non-sRGB coefficients.

Simpler just to take ~0.6*green or ~0.7* green?

Jawed
 
Back
Top