# Mobile bloom color overflow?

**URL:** <https://forums.unrealengine.com/t/mobile-bloom-color-overflow/101319>\
**Category:** Rendering\
**Tags:** unreal-engine\
**Created:** [October 16, 2017, 12:43pm UTC](https://forums.unrealengine.com/t/mobile-bloom-color-overflow/101319 "2017-10-16T12:43:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6c04a8c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6c04a8c](https://forums.unrealengine.com/u/anonymous_user_f6c04a8c)\
**Post date:** [October 16, 2017, 12:43pm UTC](https://forums.unrealengine.com/t/mobile-bloom-color-overflow/101319/1 "2017-10-16T12:43:54Z")

</div>

Hello all,

While tracking down highly glowed pixels getting erroneous green or yellow color in mobile,  
 ![MobileBloomError_20171016.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/3/e/3e3350c92ef684d615f6e74897cdefaa42c02300.png)

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  
)  
{

…  
…  
…

#if ES2\_USE\_MSAA  
// 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);  
#endif

// 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!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_f6c04a8c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_f6c04a8c](https://forums.unrealengine.com/u/anonymous_user_f6c04a8c)\
**Post date:** [October 23, 2017, 5:26am UTC](https://forums.unrealengine.com/t/mobile-bloom-color-overflow/101319/2 "2017-10-23T05:26:28Z")

</div>

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.
