Skip to content

Commit d3a2830

Browse files
author
AleMC
committed
optim
1 parent ff89899 commit d3a2830

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

PostProcessing/Runtime/PostProcessLayer.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,18 @@ bool DynamicResolutionAllowsFinalBlitToCameraTarget()
277277
}
278278
#endif
279279

280-
#if UNITY_2019_1_OR_NEWER
281-
// We always use a CommandBuffer to blit to the final render target
282-
// OnRenderImage is used only to avoid the automatic blit from the RenderTexture of Camera.forceIntoRenderTexture to the actual target
283-
[ImageEffectUsesCommandBuffer]
284-
void OnRenderImage(RenderTexture src, RenderTexture dst)
285-
{
286-
if (finalBlitToCameraTarget && DynamicResolutionAllowsFinalBlitToCameraTarget())
287-
RenderTexture.active = dst; // silence warning
288-
else
289-
Graphics.Blit(src, dst);
290-
}
291-
#endif
280+
//#if UNITY_2019_1_OR_NEWER
281+
// // We always use a CommandBuffer to blit to the final render target
282+
// // OnRenderImage is used only to avoid the automatic blit from the RenderTexture of Camera.forceIntoRenderTexture to the actual target
283+
// [ImageEffectUsesCommandBuffer]
284+
// void OnRenderImage(RenderTexture src, RenderTexture dst)
285+
// {
286+
// if (finalBlitToCameraTarget && DynamicResolutionAllowsFinalBlitToCameraTarget())
287+
// RenderTexture.active = dst; // silence warning
288+
// else
289+
// Graphics.Blit(src, dst);
290+
// }
291+
//#endif
292292

293293
/// <summary>
294294
/// Initializes this layer. If you create the layer via scripting you should always call
@@ -668,20 +668,20 @@ void BuildCommandBuffers()
668668

669669
context.destination = cameraTarget;
670670

671-
#if UNITY_2019_1_OR_NEWER
672-
if (finalBlitToCameraTarget && !RuntimeUtilities.scriptableRenderPipelineActive)
673-
{
674-
if (m_Camera.targetTexture)
675-
{
676-
context.destination = m_Camera.targetTexture.colorBuffer;
677-
}
678-
else
679-
{
680-
context.flip = true;
681-
context.destination = Display.main.colorBuffer;
682-
}
683-
}
684-
#endif
671+
//#if UNITY_2019_1_OR_NEWER
672+
// if (finalBlitToCameraTarget && !RuntimeUtilities.scriptableRenderPipelineActive)
673+
// {
674+
// if (m_Camera.targetTexture)
675+
// {
676+
// context.destination = m_Camera.targetTexture.colorBuffer;
677+
// }
678+
// else
679+
// {
680+
// context.flip = true;
681+
// context.destination = Display.main.colorBuffer;
682+
// }
683+
// }
684+
//#endif
685685

686686
context.command = (uberAfterOpaque ? m_LegacyCmdBufferOpaque : m_LegacyCmdBuffer);
687687

PostProcessing/Shaders/Builtins/Bloom.shader

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,22 @@ Shader "Hidden/PostProcessing/Bloom"
3535

3636
half4 FragPrefilter13(VaryingsDefault i) : SV_Target
3737
{
38-
half4 hudColor = 0;
38+
half hudColor = 1;
3939
#if HUD_BLOOM
40-
hudColor = DownsampleBox13Tap(TEXTURE2D_PARAM(_HUD_RT, sampler_HUD_RT), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
41-
float hudColorLum = dot(hudColor, 0.33);
42-
hudColor = hudColor / lerp(1, hudColorLum, 1 - step(hudColor.a, 0.02)) * _HudBloomIntensity;
40+
hudColor += SAMPLE_TEXTURE2D(_HUD_RT, sampler_HUD_RT, UnityStereoTransformScreenSpaceTex(i.texcoord)).r * _HudBloomIntensity;
4341
#endif
4442
half4 color = DownsampleBox13Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
45-
return Prefilter(SafeHDR(color + hudColor), i.texcoord);
43+
return Prefilter(SafeHDR(color * hudColor), i.texcoord);
4644
}
4745

4846
half4 FragPrefilter4(VaryingsDefault i) : SV_Target
4947
{
48+
half hudColor = 1;
49+
#if HUD_BLOOM
50+
hudColor += SAMPLE_TEXTURE2D(_HUD_RT, sampler_HUD_RT, UnityStereoTransformScreenSpaceTex(i.texcoord)).r * _HudBloomIntensity;
51+
#endif
5052
half4 color = DownsampleBox4Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, UnityStereoAdjustedTexelSize(_MainTex_TexelSize).xy);
51-
return Prefilter(SafeHDR(color), i.texcoord);
53+
return Prefilter(SafeHDR(color * hudColor), i.texcoord);
5254
}
5355

5456
// ----------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)