Mobile bloom color overflow?

Hello all,

While tracking down highly glowed pixels getting erroneous green or yellow color in mobile,

I found out that PC version bloom pixel shader has color clamping at BloomSetupCommon(),

while I cannot find such code at PostProcessMobile.usf.

I just added the same code to BloomPS_ES2() like below… and it fixes the problem on our end.

void BloomPS_ES2(
float2 InUVs[4] : TEXCOORD0,
out half4 OutColor : SV_Target0

// This should really happen before the average, instead doing after average as optimization.
OutColor.rgb = rcp(OutColor.r(-0.299) + OutColor.g*(-0.587) + OutColor.b*(-0.114) + 1.0);

// Try to kill negatives and NaNs here
OutColor.rgb = max(OutColor.rgb, 0);

  • //////////////////// Added clamping code
  • OutColor.rgb = min(float3(256 * 256, 256 * 256, 256 * 256), OutColor.rgb);
  • ////////////////////

// Trim bloom and sunshafts black level.
half TotalLuminance = Luminance(OutColor.rgb);
half BloomLuminance = TotalLuminance - BloomThreshold.x;
half Amount = saturate(BloomLuminance * 0.5f);
OutColor.rgb *= Amount;



Please let me know if the clamping was intentionally removed for mobile bloom, or if there’s a better spot to do the clamping.

Thank you!

For anybody who might be interested…
I had to clamp it a little more… 65536 → 65000, and placed the clamp at the end of BloomPS_ES2() to actually suppress the problem in mobile device.