Skip to content

Commit e4ec912

Browse files
author
AleMC
committed
hud bright backgrounds fix
1 parent d65fa26 commit e4ec912

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

Diff for: PostProcessing/Shaders/Builtins/Bloom.shader

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ Shader "Hidden/PostProcessing/Bloom"
3535

3636
half4 FragPrefilter13(VaryingsDefault i) : SV_Target
3737
{
38-
half hudColor = 1;
38+
half4 color = DownsampleBox13Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
3939
#if HUD_BLOOM
40-
hudColor += SAMPLE_TEXTURE2D(_HUD_RT, sampler_HUD_RT, UnityStereoTransformScreenSpaceTex(i.texcoord)).r * _HudBloomIntensity;
40+
half hudColor = SAMPLE_TEXTURE2D(_HUD_RT, sampler_HUD_RT, UnityStereoTransformScreenSpaceTex(i.texcoord)).r;
41+
color = color * (1 + saturate(hudColor * _HudBloomIntensity) * _HudBloomIntensity);
4142
#endif
42-
half4 color = DownsampleBox13Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
43-
return Prefilter(SafeHDR(color * hudColor), i.texcoord);
43+
return Prefilter(SafeHDR(color), i.texcoord);
4444
}
4545

4646
half4 FragPrefilter4(VaryingsDefault i) : SV_Target
4747
{
48-
half hudColor = 1;
48+
half4 color = DownsampleBox4Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
4949
#if HUD_BLOOM
50-
hudColor += SAMPLE_TEXTURE2D(_HUD_RT, sampler_HUD_RT, UnityStereoTransformScreenSpaceTex(i.texcoord)).r * _HudBloomIntensity;
50+
half hudColor = SAMPLE_TEXTURE2D(_HUD_RT, sampler_HUD_RT, UnityStereoTransformScreenSpaceTex(i.texcoord)).r;
51+
color = color * (1 + saturate(hudColor * _HudBloomIntensity) * _HudBloomIntensity);
5152
#endif
52-
half4 color = DownsampleBox4Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
53-
return Prefilter(SafeHDR(color * hudColor), i.texcoord);
53+
return Prefilter(SafeHDR(color), i.texcoord);
5454
}
5555

5656
// ----------------------------------------------------------------------------------------

Diff for: PostProcessing/Shaders/Builtins/Uber.shader

+19-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Shader "Hidden/PostProcessing/Uber"
1313
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
1414
float4 _MainTex_TexelSize;
1515

16+
TEXTURE2D_SAMPLER2D(_HUD_RT, sampler_HUD_RT);
17+
1618
// Auto exposure / eye adaptation
1719
TEXTURE2D_SAMPLER2D(_AutoExposureTex, sampler_AutoExposureTex);
1820

@@ -130,6 +132,11 @@ Shader "Hidden/PostProcessing/Uber"
130132

131133
color.rgb *= autoExposure;
132134

135+
#if HUD_BLOOM
136+
half4 unmodifiedColor = color;
137+
float hudMask = SAMPLE_TEXTURE2D(_HUD_RT, sampler_HUD_RT, UnityStereoTransformScreenSpaceTex(i.texcoord)).r;
138+
#endif
139+
133140
#if BLOOM || BLOOM_LOW
134141
{
135142
#if BLOOM
@@ -162,7 +169,7 @@ Shader "Hidden/PostProcessing/Uber"
162169
d = pow(saturate(d), _Vignette_Settings.z); // Roundness
163170
half vfactor = pow(saturate(1.0 - dot(d, d)), _Vignette_Settings.y);
164171
color.rgb *= lerp(_Vignette_Color, (1.0).xxx, vfactor);
165-
color.a = lerp(1.0, color.a, vfactor);
172+
//color.a = lerp(1.0, color.a, vfactor);
166173
}
167174
else
168175
{
@@ -176,7 +183,7 @@ Shader "Hidden/PostProcessing/Uber"
176183

177184
half3 new_color = color.rgb * lerp(_Vignette_Color, (1.0).xxx, vfactor);
178185
color.rgb = lerp(color.rgb, new_color, _Vignette_Opacity);
179-
color.a = lerp(1.0, color.a, vfactor);
186+
//color.a = lerp(1.0, color.a, vfactor);
180187
}
181188
}
182189
#endif
@@ -216,6 +223,11 @@ Shader "Hidden/PostProcessing/Uber"
216223
}
217224
#endif
218225

226+
#if HUD_BLOOM
227+
color = lerp(color, unmodifiedColor, saturate(hudMask * 4) * unmodifiedColor.a);
228+
color.a = 1;
229+
#endif
230+
219231
half4 output = color;
220232

221233
#if FINALPASS
@@ -267,13 +279,15 @@ Shader "Hidden/PostProcessing/Uber"
267279

268280
#pragma multi_compile __ DISTORT
269281
#pragma multi_compile __ CHROMATIC_ABERRATION CHROMATIC_ABERRATION_LOW
270-
#pragma multi_compile __ BLOOM BLOOM_LOW
282+
#pragma multi_compile __ BLOOM BLOOM_LOW
271283
#pragma multi_compile __ COLOR_GRADING_LDR_2D COLOR_GRADING_HDR_2D COLOR_GRADING_HDR_3D
272284
#pragma multi_compile __ VIGNETTE
273285
#pragma multi_compile __ GRAIN
274286
#pragma multi_compile __ FINALPASS
275287
#pragma multi_compile __ STEREO_INSTANCING_ENABLED STEREO_DOUBLEWIDE_TARGET
276288

289+
#pragma multi_compile __ HUD_BLOOM
290+
277291
#pragma vertex VertUVTransform
278292
#pragma fragment FragUber
279293

@@ -302,6 +316,8 @@ Shader "Hidden/PostProcessing/Uber"
302316
#pragma multi_compile __ FINALPASS
303317
#pragma multi_compile __ STEREO_DOUBLEWIDE_TARGET // not supported by OpenGL ES 2.0: STEREO_INSTANCING_ENABLED
304318

319+
#pragma multi_compile __ HUD_BLOOM
320+
305321
#pragma vertex VertUVTransform
306322
#pragma fragment FragUber
307323

0 commit comments

Comments
 (0)