diff --git a/Assets/UIEffect/UI-EffectCapture.shader b/Assets/UIEffect/UI-EffectCapture.shader index ddbdbb41..98f77351 100644 --- a/Assets/UIEffect/UI-EffectCapture.shader +++ b/Assets/UIEffect/UI-EffectCapture.shader @@ -37,9 +37,7 @@ Shader "UI/Hidden/UI-EffectCapture" fixed4 colorFactor : COLOR1; #endif - #if defined (UI_TONE) || defined (UI_BLUR) half4 effectFactor : TEXCOORD2; - #endif }; sampler2D _MainTex; @@ -51,16 +49,9 @@ Shader "UI/Hidden/UI-EffectCapture" { v2f OUT; OUT.vertex = UnityObjectToClipPos(v.vertex); - - #if UNITY_UV_STARTS_AT_TOP - OUT.texcoord = half2(v.texcoord.x, 1 - v.texcoord.y); - #else - OUT.texcoord = v.texcoord; - #endif - #if defined (UI_TONE) || defined (UI_BLUR) + OUT.texcoord = v.texcoord; OUT.effectFactor = _EffectFactor; - #endif #if UI_TONE_HUE OUT.effectFactor.y = sin(OUT.effectFactor.x*3.14159265359*2); @@ -73,6 +64,10 @@ Shader "UI/Hidden/UI-EffectCapture" OUT.colorFactor = _ColorFactor; #endif + #if UNITY_UV_STARTS_AT_TOP + OUT.texcoord.y = lerp(OUT.texcoord.y, 1 - OUT.texcoord.y, OUT.effectFactor.w); + #endif + return OUT; } diff --git a/Assets/UIEffect/UIEffectCapturedImage.cs b/Assets/UIEffect/UIEffectCapturedImage.cs index d20425c6..44964c3f 100644 --- a/Assets/UIEffect/UIEffectCapturedImage.cs +++ b/Assets/UIEffect/UIEffectCapturedImage.cs @@ -241,7 +241,7 @@ public void Capture() _buffer.Blit(BuiltinRenderTextureType.CurrentActive, s_CopyId); // Set properties. - _buffer.SetGlobalVector("_EffectFactor", new Vector4(toneLevel, 0, blur, 0)); + _buffer.SetGlobalVector("_EffectFactor", new Vector4(toneLevel, 0, blur, 1)); _buffer.SetGlobalVector("_ColorFactor", new Vector4(effectColor.r, effectColor.g, effectColor.b, effectColor.a)); // Blit without effect. @@ -261,6 +261,7 @@ public void Capture() // Iterate the operation. if(1 < m_Iterations) { + _buffer.SetGlobalVector("_EffectFactor", new Vector4(toneLevel, 0, blur, 0)); _buffer.GetTemporaryRT(s_EffectId2, w, h, 0, m_FilterMode); for (int i = 1; i < m_Iterations; i++) {