Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Call SRGBToLinear in Bloom FragPrefilter Pass #629

Open
gam0022 wants to merge 3 commits into Unity-Technologies:v2
base: v2
Choose a base branch
Loading
from gam0022:fix-bloom-prefilter-call-SRGBToLinear

Conversation

@gam0022
Copy link

@gam0022 gam0022 commented Aug 1, 2018
edited
Loading

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.

float lthresh = Mathf.GammaToLinearSpace(settings.threshold.value);

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

half4 FragPrefilter13(VaryingsDefault i) : SV_Target
{
half4 color = DownsampleBox13Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, _MainTex_TexelSize.xy);
return Prefilter(SafeHDR(color), i.texcoord);
}
half4 FragPrefilter4(VaryingsDefault i) : SV_Target
{
half4 color = DownsampleBox4Tap(TEXTURE2D_PARAM(_MainTex, sampler_MainTex), i.texcoord, _MainTex_TexelSize.xy);
return Prefilter(SafeHDR(color), i.texcoord);
}

The UberShader Pass calls LinearToSRGB().

#if UNITY_COLORSPACE_GAMMA
{
output = LinearToSRGB(output);
}
#endif

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

oteguro and Yasei-no-otoko reacted with thumbs up emoji
Copy link
Author

gam0022 commented Sep 26, 2018

@Chman Would you please review?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /