PostProcessing icon indicating copy to clipboard operation
PostProcessing copied to clipboard

Call SRGBToLinear in Bloom FragPrefilter Pass

Open gam0022 opened this issue 7 years ago • 1 comments

I fixed the Bloom Effect implementation: Calling SRGBToLinear() in the FragPrefilter Pass is missing.

This change makes Bloom Effect maintain the same appearance regardless of the Unity's Color Space setting (Gamma or Linear).

Details

The Bloom threshold is in Linear Space.

https://github.com/Unity-Technologies/PostProcessing/blob/d4eb22934ea7d1804e66af80d02bb4295e499781/PostProcessing/Runtime/Effects/Bloom.cs#L124

On the other hand, Bloom FragPrefilter does not convert to Linear Space.

https://github.com/Unity-Technologies/PostProcessing/blob/d4eb22934ea7d1804e66af80d02bb4295e499781/PostProcessing/Shaders/Builtins/Bloom.shader#L31-L41

The UberShader Pass calls LinearToSRGB().

https://github.com/Unity-Technologies/PostProcessing/blob/4bfd2efbd3c43bcb62ba3b3dd40152fcfc1598c1/PostProcessing/Shaders/Builtins/Uber.shader#L233-L237

It means that the Linear Space Threshold is compared with the SRGB Space RenderTexutre when UNITY_COLORSPACE_GAMMA is defined (Unity Color Space: Gamma).

I fixed this implementation so that the Bloom Effect works properly even if UNITY_COLORSPACE_GAMMA is defined or not.

Results

Before (v2 branch)

The intensity of Bloom is changed by Unity's color space setting (Gamma or Linear).

before_gamma

before_linear

After (this branch)

It maintains the same appearance regardless of the Unity's color space setting.

fixed_gamma

fixed_linear

The original image belongs to the following site. http://www.humus.name/index.php?page=Textures&ID=18

gam0022 avatar Aug 01 '18 16:08 gam0022

@Chman Would you please review?

gam0022 avatar Sep 26 '18 15:09 gam0022