Skip to content

Commit

Permalink
Shader keyword reduction
Browse files Browse the repository at this point in the history
- Changed to use the built-in keyword (UNITY_COLORSPACE_GAMMA) to determine
  the current color space. The old shader keywords GAMMA_COLOR and LINEAR_COLOR
  were removed by this change.
  • Loading branch information
Keijiro Takahashi authored and Keijiro Takahashi committed May 17, 2016
1 parent 424cb80 commit 98b3f20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
12 changes: 0 additions & 12 deletions Assets/Kino/Bloom/Bloom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ void OnDisable()
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
var useRGBM = Application.isMobilePlatform;
var isGamma = QualitySettings.activeColorSpace == ColorSpace.Gamma;

// source texture size
var tw = source.width;
Expand Down Expand Up @@ -209,17 +208,6 @@ void OnRenderImage(RenderTexture source, RenderTexture destination)
else
_material.DisableKeyword("ANTI_FLICKER");

if (isGamma)
{
_material.DisableKeyword("LINEAR_COLOR");
_material.EnableKeyword("GAMMA_COLOR");
}
else
{
_material.EnableKeyword("LINEAR_COLOR");
_material.DisableKeyword("GAMMA_COLOR");
}

// prefilter pass
var prefiltered = RenderTexture.GetTemporary(tw, th, 0, rtFormat);
Graphics.Blit(source, prefiltered, _material, 0);
Expand Down
10 changes: 5 additions & 5 deletions Assets/Kino/Bloom/Shader/Bloom.shader
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Shader "Hidden/Kino/Bloom"
half3 m = s0.rgb;
#endif

#if GAMMA_COLOR
#if UNITY_COLORSPACE_GAMMA
m = GammaToLinearSpace(m);
#endif
// Pixel brightness
Expand Down Expand Up @@ -239,11 +239,11 @@ Shader "Hidden/Kino/Bloom"
{
half4 base = tex2D(_BaseTex, i.uvBase);
half3 blur = UpsampleFilter(i.uvMain);
#if GAMMA_COLOR
#if UNITY_COLORSPACE_GAMMA
base.rgb = GammaToLinearSpace(base.rgb);
#endif
half3 cout = base.rgb + blur * _Intensity;
#if GAMMA_COLOR
#if UNITY_COLORSPACE_GAMMA
cout = LinearToGammaSpace(cout);
#endif
return half4(cout, base.a);
Expand All @@ -257,7 +257,7 @@ Shader "Hidden/Kino/Bloom"
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma multi_compile _ ANTI_FLICKER
#pragma multi_compile LINEAR_COLOR GAMMA_COLOR
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#pragma vertex vert_img
#pragma fragment frag_prefilter
#pragma target 3.0
Expand Down Expand Up @@ -297,7 +297,7 @@ Shader "Hidden/Kino/Bloom"
ZTest Always Cull Off ZWrite Off
CGPROGRAM
#pragma multi_compile _ HIGH_QUALITY
#pragma multi_compile LINEAR_COLOR GAMMA_COLOR
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
#pragma vertex vert_multitex
#pragma fragment frag_upsample_final
#pragma target 3.0
Expand Down

0 comments on commit 98b3f20

Please sign in to comment.