Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit d4eb229

Browse files
committed
Clamp is now set in gamma-space like threshold
1 parent 78361ca commit d4eb229

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

PostProcessing/Runtime/Effects/Bloom.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public sealed class Bloom : PostProcessEffectSettings
2020
[Range(0f, 1f), Tooltip("Makes transition between under/over-threshold gradual (0 = hard threshold, 1 = soft threshold).")]
2121
public FloatParameter softKnee = new FloatParameter { value = 0.5f };
2222

23-
[Tooltip("Clamps pixels to control the bloom amount.")]
23+
[Tooltip("Clamps pixels to control the bloom amount. Value is in gamma-space.")]
2424
public FloatParameter clamp = new FloatParameter { value = 65472f };
2525

2626
[Range(1f, 10f), Tooltip("Changes the extent of veiling effects. For maximum quality stick to integer values. Because this value changes the internal iteration count, animating it isn't recommended as it may introduce small hiccups in the perceived radius.")]
@@ -125,7 +125,8 @@ public override void Render(PostProcessRenderContext context)
125125
float knee = lthresh * settings.softKnee.value + 1e-5f;
126126
var threshold = new Vector4(lthresh, lthresh - knee, knee * 2f, 0.25f / knee);
127127
sheet.properties.SetVector(ShaderIDs.Threshold, threshold);
128-
sheet.properties.SetVector(ShaderIDs.Params, new Vector4(settings.clamp, 0f, 0f, 0f));
128+
float lclamp = Mathf.GammaToLinearSpace(settings.clamp.value);
129+
sheet.properties.SetVector(ShaderIDs.Params, new Vector4(lclamp, 0f, 0f, 0f));
129130

130131
int qualityOffset = settings.fastMode ? 1 : 0;
131132

PostProcessing/Shaders/Builtins/Bloom.shader

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Shader "Hidden/PostProcessing/Bloom"
2323
{
2424
half autoExposure = SAMPLE_TEXTURE2D(_AutoExposureTex, sampler_AutoExposureTex, uv).r;
2525
color *= autoExposure;
26-
color = QuadraticThreshold(color, _Threshold.x, _Threshold.yzw);
2726
color = min(_Params.x, color); // clamp to max
27+
color = QuadraticThreshold(color, _Threshold.x, _Threshold.yzw);
2828
return color;
2929
}
3030

0 commit comments

Comments
 (0)