Compare commits

..

6 Commits

Author SHA1 Message Date
Takashi Sakai db8839f3e0 release v2.4.0 2018-05-21 16:45:32 +09:00
Takashi Sakai 3aa186aeaf update change log 2018-05-21 16:45:32 +09:00
Takashi Sakai 237dab7639 Update readme 2018-05-21 16:02:21 +09:00
Takashi Sakai 45520d98c5 Update demo for v.2.4.0 2018-05-21 16:02:21 +09:00
Takashi Sakai 9e830f61f0 Remove shader keyword in material 2018-05-21 16:02:21 +09:00
Takashi Sakai ed9a68c1fa Resolved #64 : UIDissolve: Add color mode option. 2018-05-21 15:23:05 +09:00
12 changed files with 2327 additions and 1368 deletions
File diff suppressed because it is too large Load Diff
+5
View File
@@ -17,5 +17,10 @@ namespace Coffee.UIExtensions
mask.enabled = true;
}
}
public void SetTimeScale(float scale)
{
Time.timeScale = scale;
}
}
}
@@ -0,0 +1,214 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 8
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Dissolve
m_Shader: {fileID: 4800000, guid: e1b48dc831eb147e9886c049033213bf, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NoiseTex
second:
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
--- !u!21 &21162286589123374
Material:
serializedVersion: 6
m_ObjectHideFlags: 9
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Dissolve-Set
m_Shader: {fileID: 4800000, guid: e1b48dc831eb147e9886c049033213bf, type: 3}
m_ShaderKeywords: UI_COLOR_SET
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NoiseTex
second:
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
--- !u!21 &21841578701121694
Material:
serializedVersion: 6
m_ObjectHideFlags: 9
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Dissolve-Sub
m_Shader: {fileID: 4800000, guid: e1b48dc831eb147e9886c049033213bf, type: 3}
m_ShaderKeywords: UI_COLOR_SUB
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NoiseTex
second:
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
--- !u!21 &21939717441729078
Material:
serializedVersion: 6
m_ObjectHideFlags: 9
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Dissolve-Add
m_Shader: {fileID: 4800000, guid: e1b48dc831eb147e9886c049033213bf, type: 3}
m_ShaderKeywords: UI_COLOR_ADD
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NoiseTex
second:
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
@@ -1,7 +1,7 @@
fileFormatVersion: 2
guid: 17b17d6effbe14075a3bbdf1fda1f6e1
timeCreated: 1524469054
licenseType: Pro
timeCreated: 1526828325
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
@@ -8,7 +8,7 @@ Material:
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Shiny
m_Shader: {fileID: 4800000, guid: 20ffe76c2439c403aabdd25bd94bf011, type: 3}
m_ShaderKeywords: _EMISSION
m_ShaderKeywords:
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
-82
View File
@@ -1,82 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: UI-Effect-Dissolve
m_Shader: {fileID: 4800000, guid: e1b48dc831eb147e9886c049033213bf, type: 3}
m_ShaderKeywords: _EMISSION
m_LightmapFlags: 1
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _NoiseTex
second:
m_Texture: {fileID: 2800000, guid: 3e04c247fb2604af186173fce0bc62de, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _ColorMask
second: 15
- first:
name: _EdgeWidth
second: 0.1
- first:
name: _InnerSoftClip
second: 0.468
- first:
name: _InnerSoftness
second: 0.5
- first:
name: _OuterSoftClip
second: 0.776
- first:
name: _OuterSoftness
second: 0.5
- first:
name: _Stencil
second: 0
- first:
name: _StencilComp
second: 8
- first:
name: _StencilOp
second: 0
- first:
name: _StencilReadMask
second: 255
- first:
name: _StencilWriteMask
second: 255
- first:
name: _UseUIAlphaClip
second: 0
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EdgeInnerColor
second: {r: 1, g: 0, b: 0, a: 1}
- first:
name: _EdgeOuterColor
second: {r: 1, g: 0.7529412, b: 0, a: 1}
- first:
name: _InnerEdgeColor
second: {r: 1, g: 0, b: 0, a: 1}
- first:
name: _OuterEdgeColor
second: {r: 1, g: 0.75, b: 0, a: 1}
+13 -37
View File
@@ -16,12 +16,7 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
[Header(Dissolve)]
_NoiseTex ("Noise Texture (A)", 2D) = "white" {}
_EdgeWidth ("Edge width", Range (0.0001, 1)) = 0.05
_OuterEdgeColor ("Outer edge color", Color) = (1.0, 0.75, 0.0, 1.0)
_OuterSoftness ("Outer softness", Range (0.0001, 1)) = 0.5
_InnerEdgeColor ("Inner edge color", Color) = (1.0, 0.0, 0.0, 1.0)
_InnerSoftness ("Inner softness", Range (0.0001, 1)) = 0.5
_NoiseTex("Noise Texture (A)", 2D) = "white" {}
}
SubShader
@@ -61,9 +56,11 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
#pragma target 2.0
#pragma multi_compile __ UNITY_UI_ALPHACLIP
#pragma shader_feature __ UI_COLOR_ADD UI_COLOR_SUB UI_COLOR_SET
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#include "UI-Effect.cginc"
struct appdata_t
{
@@ -83,36 +80,15 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
float4 worldPosition : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
half3 effectFactor : TEXCOORD2;
fixed4 effectFactor : TEXCOORD2;
fixed4 effectFactor2 : TEXCOORD3;
};
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
sampler2D _MainTex;
sampler2D _NoiseTex;
float _EdgeWidth;
float3 _OuterEdgeColor;
float _OuterSoftness;
float3 _InnerEdgeColor;
float _InnerSoftness;
fixed3 UnpackToVec3(float value)
{
const int PACKER_STEP = 256;
const int PRECISION = PACKER_STEP - 1;
fixed3 vec;
vec.x = (value % PACKER_STEP) / PRECISION;
value = floor(value / PACKER_STEP);
vec.y = (value % PACKER_STEP) / PRECISION;
value = floor(value / PACKER_STEP);
vec.z = (value % PACKER_STEP) / PRECISION;
return vec;
}
v2f vert(appdata_t IN)
{
@@ -127,9 +103,11 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
OUT.color = IN.color * _Color;
//xy: Noize uv
//z: Dissolve factor
OUT.effectFactor = UnpackToVec3(IN.uv1.x);
//xy: Noize uv, z: Dissolve factor, w: width
OUT.effectFactor = UnpackToVec4(IN.uv1.x);
//xyz: color, w: softness
OUT.effectFactor2 = UnpackToVec4(IN.uv1.y);
return OUT;
}
@@ -146,11 +124,9 @@ Shader "UI/Hidden/UI-Effect-Dissolve"
clip (min(color.a - 0.01, factor));
#endif
fixed edgeLerp = step(cutout, color.a) * saturate((_EdgeWidth - factor)*16/_InnerSoftness);
fixed3 edgeColor = lerp(_OuterEdgeColor, _InnerEdgeColor, (factor)/_EdgeWidth);
color.rgb =lerp(color.rgb, edgeColor, edgeLerp);
color.a *= saturate((factor)*32/_OuterSoftness);
fixed edgeLerp = step(cutout, color.a) * saturate((IN.effectFactor.w/4 - factor)*16/ IN.effectFactor2.w);
color = ApplyColorEffect(color, fixed4(IN.effectFactor2.rgb, edgeLerp));
color.a *= saturate((factor)*32/ IN.effectFactor2.w);
return color;
}
+3
View File
@@ -145,6 +145,9 @@ fixed4 ApplyColorEffect(fixed4 color, fixed4 factor)
#elif UI_COLOR_SUB // Sub
color.rgb -= factor.rgb * factor.a;
#else
color.rgb = lerp(color.rgb, color.rgb * factor.rgb, factor.a);
#endif
#if UI_TONE_CUTOFF
+48 -24
View File
@@ -30,7 +30,11 @@ namespace Coffee.UIExtensions
//################################
// Serialize Members.
//################################
[SerializeField] [Range(0, 1)] float m_Location = 0;
[SerializeField] [Range(0, 1)] float m_Location = 0.5f;
[SerializeField] [Range(0, 1)] float m_Width = 0.5f;
[SerializeField] [Range(0, 1)] float m_Softness = 0.5f;
[SerializeField] [ColorUsage(false)] Color m_Color = new Color(0.0f, 0.25f, 1.0f);
[SerializeField] UIEffect.ColorMode m_ColorMode = UIEffect.ColorMode.Add;
[SerializeField] Material m_EffectMaterial;
@@ -47,6 +51,26 @@ namespace Coffee.UIExtensions
/// </summary>
public float location { get { return m_Location; } set { m_Location = Mathf.Clamp(value, 0, 1); _SetDirty(); } }
/// <summary>
/// Edge width.
/// </summary>
public float width { get { return m_Width; } set { m_Width = Mathf.Clamp(value, 0, 1); _SetDirty(); } }
/// <summary>
/// Edge softness.
/// </summary>
public float softness { get { return m_Softness; } set { m_Softness = Mathf.Clamp(value, 0, 1); _SetDirty(); } }
/// <summary>
/// Edge color.
/// </summary>
public Color color { get { return m_Color; } set { m_Color = value; _SetDirty(); } }
/// <summary>
/// Color effect mode.
/// </summary>
public UIEffect.ColorMode colorMode { get { return m_ColorMode; } }
/// <summary>
/// Effect material.
/// </summary>
@@ -82,31 +106,18 @@ namespace Coffee.UIExtensions
{
if (Application.isPlaying || !obj || !obj.graphic)
return;
var mat = UIEffect.GetOrGenerateMaterialVariant(Shader.Find(shaderName), UIEffect.ToneMode.None, m_ColorMode, UIEffect.BlurMode.None);
if(!m_EffectMaterial)
{
m_EffectMaterial = GetMaterial(shaderName);
EditorUtility.SetDirty(this);
EditorApplication.delayCall +=AssetDatabase.SaveAssets;
}
if(obj.isActiveAndEnabled && graphic.material != m_EffectMaterial)
{
graphic.material = m_EffectMaterial;
EditorUtility.SetDirty(graphic);
EditorApplication.delayCall +=AssetDatabase.SaveAssets;
}
if (m_EffectMaterial == mat && graphic.material == mat)
return;
graphic.material = m_EffectMaterial = mat;
EditorUtility.SetDirty(this);
EditorUtility.SetDirty(graphic);
EditorApplication.delayCall += AssetDatabase.SaveAssets;
};
}
public static Material GetMaterial(string shaderName)
{
string name = Path.GetFileName (shaderName);
return AssetDatabase.FindAssets("t:Material " + name)
.Select(x => AssetDatabase.GUIDToAssetPath(x))
.SelectMany(x => AssetDatabase.LoadAllAssetsAtPath(x))
.OfType<Material>()
.FirstOrDefault(x => x.name == name);
}
#endif
/// <summary>
@@ -129,7 +140,7 @@ namespace Coffee.UIExtensions
var x = Mathf.Clamp01 (vertex.position.x / rect.width + 0.5f);
var y = Mathf.Clamp01 (vertex.position.y / rect.height + 0.5f);
vertex.uv1 = new Vector2 (_PackToFloat (x, y, location), 0);
vertex.uv1 = new Vector2 (_PackToFloat (x, y, location, m_Width), _PackToFloat(m_Color.r, m_Color.g, m_Color.b, m_Softness));
vh.SetUIVertex(vertex, i);
}
@@ -158,5 +169,18 @@ namespace Coffee.UIExtensions
+ (Mathf.FloorToInt(y * PRECISION) << 8)
+ Mathf.FloorToInt(x * PRECISION);
}
/// <summary>
/// Pack 4 low-precision [0-1] floats values to a float.
/// Each value [0-1] has 64 steps(6 bits).
/// </summary>
static float _PackToFloat(float x, float y, float z, float w)
{
const int PRECISION = (1 << 6) - 1;
return (Mathf.FloorToInt(w * PRECISION) << 18)
+ (Mathf.FloorToInt(z * PRECISION) << 12)
+ (Mathf.FloorToInt(y * PRECISION) << 6)
+ Mathf.FloorToInt(x * PRECISION);
}
}
}
+8
View File
@@ -1,5 +1,13 @@
# Changelog
## [v2.4.0](https://github.com/mob-sakai/UIEffect/tree/v2.4.0) (2018-05-21)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.3.2...v2.4.0)
**Implemented enhancements:**
- UIDissolve: Add color mode option. [\#64](https://github.com/mob-sakai/UIEffect/issues/64)
## [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)
+16 -10
View File
@@ -17,12 +17,10 @@ Let's decorate your UI with effects!
<br><br><br><br>
## Description
### New feature in v2.3.0!
![v2.3.0](https://user-images.githubusercontent.com/12690315/39756239-bf546ae6-5303-11e8-964a-38aed7ea6096.gif)
### Supports following effects!
![image](https://user-images.githubusercontent.com/12690315/35077815-5ff8094e-fc42-11e7-92dd-99916c9f9da7.png)
@@ -74,13 +72,21 @@ Let's decorate your UI with effects!
![image](https://user-images.githubusercontent.com/12690315/34619468-97e3c134-f285-11e7-90b2-3a75bde13911.gif)
* UIGradient: Change vertex color as gradient, with rotation, offset, color correction
![image](https://user-images.githubusercontent.com/12690315/38594997-2a39f03c-3d84-11e8-865d-9ce12a8bb3db.gif)
* UIShiny: Shiny effect WITHOUT Mask component. This will suppress extra draw calls and improve performance.
Merged from [ShinyEffectForUGUI](https://github.com/mob-sakai/ShinyEffectForUGUI).
![image](https://user-images.githubusercontent.com/12690315/38501362-c56e3768-3c47-11e8-9ec1-50343d8b83ad.gif)
* UIDissolve: Dissolve effect WITHOUT material instancing. This will suppress extra draw calls and improve performance.
Merged from [DissolveEffectForUGUI](https://github.com/mob-sakai/DissolveEffectForUGUI).
![demo](https://user-images.githubusercontent.com/12690315/39131616-dcf7ea60-474a-11e8-8e20-f9e5bd8b3f5c.gif)
* UIFlip: Flip horizontal/vertical.
### New feature in v2.3.0
![v2.3.0](https://user-images.githubusercontent.com/12690315/39756239-bf546ae6-5303-11e8-964a-38aed7ea6096.gif)
* UIShiny: Shiny effect WITHOUT Mask component. This will suppress extra draw calls and improve performance.
* UIDissolve: Dissolve effect WITHOUT material instancing. This will suppress extra draw calls and improve performance.
* UIFlip: Flip graphic horizontal/vertical.
### New feature in v2.4.0
![v2.4.0](https://user-images.githubusercontent.com/12690315/40294019-a0bfb8aa-5d0e-11e8-8451-873502db6a99.gif)
![editor](https://user-images.githubusercontent.com/12690315/40294212-9e1b1ce2-5d0f-11e8-88ce-78a8c0523dc2.png)
* UIDissolve: Add color mode option.
* UIDissolve: You can change the edge color, width, softness, color mode in inspector.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "UIEffect",
"version": "2.3.2",
"version": "2.4.0",
"repository": {
"type": "git",
"url": "git+https://github.com/mob-sakai/UIEffect.git"