Skip to content

Commit

Permalink
release v2.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Takashi Sakai committed May 21, 2018
2 parents ed3fce5 + b4cb57e commit 772297a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
15 changes: 10 additions & 5 deletions Assets/UIEffect/UI-EffectCapture.shader
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ Shader "UI/Hidden/UI-EffectCapture"
fixed4 colorFactor : COLOR1;
#endif

#if defined (UI_TONE) || defined (UI_BLUR)
half4 effectFactor : TEXCOORD2;
#endif
};

sampler2D _MainTex;
Expand All @@ -49,9 +51,16 @@ 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.effectFactor = _EffectFactor;
#endif

#if UI_TONE_HUE
OUT.effectFactor.y = sin(OUT.effectFactor.x*3.14159265359*2);
Expand All @@ -64,10 +73,6 @@ 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;
}

Expand Down
22 changes: 20 additions & 2 deletions Assets/UIEffect/UIEffectCapturedImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@ protected override void OnPopulateMesh(VertexHelper vh)
// When not displaying, clear vertex.
if (texture == null || effectColor.a < 1 / 255f || canvasRenderer.GetAlpha() < 1 / 255f)
vh.Clear();
#if UNITY_STANDALONE_WIN
else if(_capturedIterations % 2 == 0)
{
Debug.Log(iterations);
base.OnPopulateMesh(vh);
int count = vh.currentVertCount;
UIVertex vt = UIVertex.simpleVert;
Vector2 one = Vector2.one;
for (int i = 0; i < count; i++)
{
vh.PopulateUIVertex(ref vt, i);
vt.uv0 = new Vector2(vt.uv0.x, 1-vt.uv0.y);
vh.SetUIVertex(vt, i);
}
}
#endif
else
base.OnPopulateMesh(vh);
}
Expand Down Expand Up @@ -241,14 +257,15 @@ public void Capture()
_buffer.Blit(BuiltinRenderTextureType.CurrentActive, s_CopyId);

// Set properties.
_buffer.SetGlobalVector("_EffectFactor", new Vector4(toneLevel, 0, blur, 1));
_buffer.SetGlobalVector("_EffectFactor", new Vector4(toneLevel, 0, blur, 0));
_buffer.SetGlobalVector("_ColorFactor", new Vector4(effectColor.r, effectColor.g, effectColor.b, effectColor.a));

// Blit without effect.
if (!mat)
{
_buffer.Blit(s_CopyId, rtId);
_buffer.ReleaseTemporaryRT(s_CopyId);
_capturedIterations = 1;
}
// Blit with effect.
else
Expand All @@ -261,7 +278,6 @@ 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++)
{
Expand All @@ -276,6 +292,7 @@ public void Capture()
{
_buffer.ReleaseTemporaryRT(s_EffectId2);
}
_capturedIterations = m_Iterations;
}
}

Expand Down Expand Up @@ -312,6 +329,7 @@ public void Release()
RenderTexture _rt;
RenderTexture _rtToRelease;
CommandBuffer _buffer;
int _capturedIterations = 1;

static int s_CopyId;
static int s_EffectId1;
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## [v2.3.2](https://github.com/mob-sakai/UIEffect/tree/v2.3.2) (2018-05-21)

[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.3.1...v2.3.2)

**Closed issues:**

- Fixed: UIEffectCapturedImage: When iteration count is even. the result image is flipped vertically \(other method\) [\#65](https://github.com/mob-sakai/UIEffect/issues/65)

## [v2.3.1](https://github.com/mob-sakai/UIEffect/tree/v2.3.1) (2018-05-10)

[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.3.0...v2.3.1)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ UIEffect
UIEffect is an effect component for uGUI in Unity.
Let's decorate your UI with effects!

[![](https://img.shields.io/github/release/mob-sakai/UIEffect.svg?label=latest%20version)](https://github.com/mob-sakai/UIEffect/release)
[![](https://img.shields.io/github/release/mob-sakai/UIEffect.svg?label=latest%20version)](https://github.com/mob-sakai/UIEffect/releases)
[![](https://img.shields.io/github/release-date/mob-sakai/UIEffect.svg)](https://github.com/mob-sakai/UIEffect/releases)
![](https://img.shields.io/badge/requirement-Unity%205.5%2B-green.svg)
[![](https://img.shields.io/github/license/mob-sakai/UIEffect.svg)](https://github.com/mob-sakai/UIEffect/blob/master/LICENSE.txt)
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "UIEffect",
"version": "2.3.1",
"version": "2.3.2",
"repository": {
"type": "git",
"url": "git+https://github.com/mob-sakai/UIEffect.git"
},
"src": "Assets/UIEffect",
"unity": "/Applications/Unity2017.1.0p5/Unity2017.1.0p5.app/Contents/MacOS/Unity",
"unity": "/Applications/Unity/Hub/Editor/5.5.0p4/Unity.app/Contents/MacOS/Unity",
"license": "MIT"
}

0 comments on commit 772297a

Please sign in to comment.