Compare commits

...

16 Commits

Author SHA1 Message Date
Takashi Sakai aaf79b76a9 release v2.2.0 2018-04-12 09:13:00 +09:00
Takashi Sakai 2c8b994aa0 update change log 2018-04-12 09:12:59 +09:00
Takashi Sakai 49c3855c49 Change: Reduce the pixelation effect when tone level = 1. #57 2018-04-12 09:01:02 +09:00
Takashi Sakai 537784c0f3 Update release script 2018-04-12 08:25:46 +09:00
Takashi Sakai bf8b4833fd Update README 2018-04-12 08:25:46 +09:00
Takashi Sakai c78bc86cf1 Refactor: Add shader struct 2018-04-12 08:25:46 +09:00
Takashi Sakai 0ad6bd7693 Fixed: Color effect on shadow is incorrect. #55 2018-04-12 08:25:46 +09:00
Takashi Sakai 3fda891b35 Feature: Customize shader/material. #46 2018-04-12 08:25:45 +09:00
Takashi Sakai efefad1a73 Feature: UIEffectCapturedImage supports keep canvas size. #54 2018-04-12 08:25:45 +09:00
Takashi Sakai 1e9cea00cb Feature: UIEffectCapturedImage supports Quality Type to easy setup. #53 2018-04-12 08:25:45 +09:00
Takashi Sakai f17183d1b0 release v2.1.0 2018-04-04 21:05:27 +09:00
Takashi Sakai 7d699f08db update change log 2018-04-04 21:05:27 +09:00
Takashi Sakai db98e1f0ce Add release script for Github 2018-04-04 21:04:21 +09:00
Takashi Sakai eaa78e2bb4 Feature: UIEffectCapturedImage support iterative operation. 2018-04-04 20:49:35 +09:00
Takashi Sakai 068783767a Change to symbolic 2018-04-03 18:53:30 +09:00
Takashi Sakai fe18d0f82f Delete files 2018-04-03 18:51:10 +09:00
20 changed files with 681 additions and 814 deletions
+6
View File
@@ -0,0 +1,6 @@
user=mob-sakai
project=UIEffect
issues-wo-labels=false
pr-wo-labels=false
exclude_labels=duplicate,question,invalid,wontfix,Duplicate,Question,Invalid,Wontfix,Meta: Exclude From Changelog,unreleased
unreleased=false
+4
View File
@@ -30,3 +30,7 @@ sysinfo.txt
# Builds
*.apk
# Packages
*.unitypackage
-78
View File
@@ -1,78 +0,0 @@
using System;
using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
namespace Coffee.UIExtensions
{
using BlurMode = UIEffect.BlurMode;
using ColorMode = UIEffect.ColorMode;
using ToneMode = UIEffect.ToneMode;
public static class ExportPackage
{
const string kPackageName = "UIEffect.unitypackage";
static readonly string[] kAssetPathes =
{
"Assets/UIEffect",
};
[MenuItem("Export Package/" + kPackageName)]
[InitializeOnLoadMethod]
static void Export()
{
if (EditorApplication.isPlayingOrWillChangePlaymode)
return;
// Export package
AssetDatabase.ExportPackage(kAssetPathes, kPackageName, ExportPackageOptions.Recurse | ExportPackageOptions.Default);
UnityEngine.Debug.Log("Export successfully : " + kPackageName);
// Update readme.
System.IO.File.Copy("Assets/UIEffect/Readme.md", "Readme.md", true);
}
[MenuItem("Export Package/Generate Material Variants")]
static void GenerateMaterialVariants()
{
#if UIEFFECT_SEPARATE
// On "UIEFFECT_SEPARATE" mode, generate effect materials on demand.
return;
#endif
// Export materials.
AssetDatabase.StartAssetEditing();
{
// For UIEffect
GenerateMaterialVariants(Shader.Find(UIEffect.shaderName));
// For UIEffectCapturedImage
GenerateMaterialVariants(Shader.Find(UIEffectCapturedImage.shaderName));
}
AssetDatabase.StopAssetEditing();
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
}
/// <summary>
/// Generates the material variants.
/// </summary>
static void GenerateMaterialVariants(Shader shader)
{
var combinations = (from tone in (ToneMode[])Enum.GetValues(typeof(ToneMode))
from color in (ColorMode[])Enum.GetValues(typeof(ColorMode))
from blur in (BlurMode[])Enum.GetValues(typeof(BlurMode))
select new { tone, color, blur }).ToArray();
for (int i = 0; i < combinations.Length; i++)
{
var comb = combinations[i];
EditorUtility.DisplayProgressBar("Genarate Effect Material", UIEffect.GetVariantName(shader, comb.tone, comb.color, comb.blur), (float)i / combinations.Length);
UIEffect.GetOrGenerateMaterialVariant(shader, comb.tone, comb.color, comb.blur);
}
EditorUtility.ClearProgressBar();
}
}
}
-12
View File
@@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: 89691001b43234d4db48a9fab0f1260a
timeCreated: 1502937469
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+1
View File
@@ -0,0 +1 @@
../../CHANGELOG.md
@@ -1,7 +1,6 @@
fileFormatVersion: 2
guid: 5b535d57ef51543408dea9bdc2ac90a0
folderAsset: yes
timeCreated: 1502937466
guid: 1fe75f65a37454bf5aa2dab183b4305a
timeCreated: 1522651812
licenseType: Pro
DefaultImporter:
userData:
@@ -1,6 +1,7 @@
using UnityEditor;
using UnityEditor.UI;
using UnityEngine;
using DesamplingRate = Coffee.UIExtensions.UIEffectCapturedImage.DesamplingRate;
namespace Coffee.UIExtensions
{
@@ -11,6 +12,41 @@ namespace Coffee.UIExtensions
[CanEditMultipleObjects]
public class UIEffectCapturedImageEditor : RawImageEditor
{
//################################
// Constant or Static Members.
//################################
public enum QualityMode : int
{
Fast = (DesamplingRate.x2 << 0) + (DesamplingRate.x2 << 4) + (FilterMode.Bilinear << 8) + (1 << 10),
Medium = (DesamplingRate.x1 << 0) + (DesamplingRate.x1 << 4) + (FilterMode.Bilinear << 8) + (1 << 10),
Detail = (DesamplingRate.None << 0) + (DesamplingRate.x1 << 4) + (FilterMode.Bilinear << 8) + (1 << 10),
Custom = -1,
}
//################################
// Public/Protected Members.
//################################
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
protected override void OnEnable()
{
base.OnEnable();
_spTexture = serializedObject.FindProperty("m_Texture");
_spColor = serializedObject.FindProperty("m_Color");
_spRaycastTarget = serializedObject.FindProperty("m_RaycastTarget");
_spDesamplingRate = serializedObject.FindProperty("m_DesamplingRate");
_spReductionRate = serializedObject.FindProperty("m_ReductionRate");
_spFilterMode = serializedObject.FindProperty("m_FilterMode");
_spIterations = serializedObject.FindProperty("m_Iterations");
_spKeepSizeToRootCanvas = serializedObject.FindProperty("m_KeepCanvasSize");
_customAdvancedOption = (qualityMode == QualityMode.Custom);
}
/// <summary>
/// Implement this function to make a custom inspector.
/// </summary>
@@ -21,9 +57,9 @@ namespace Coffee.UIExtensions
//================
// Basic properties.
//================
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Texture"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Color"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RaycastTarget"));
EditorGUILayout.PropertyField(_spTexture);
EditorGUILayout.PropertyField(_spColor);
EditorGUILayout.PropertyField(_spRaycastTarget);
//================
// Capture effect.
@@ -38,14 +74,24 @@ namespace Coffee.UIExtensions
GUILayout.Space(10);
EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);
// Desampling rate.
DrawDesamplingRate(serializedObject.FindProperty("m_DesamplingRate"));
EditorGUI.BeginChangeCheck();
QualityMode quality = qualityMode;
quality = (QualityMode)EditorGUILayout.EnumPopup("Quality Mode", quality);
if(EditorGUI.EndChangeCheck())
{
_customAdvancedOption = (quality == QualityMode.Custom);
qualityMode = quality;
}
// Reduction rate.
DrawDesamplingRate(serializedObject.FindProperty("m_ReductionRate"));
// Filter Mode.
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_FilterMode"));
// When qualityMode is `Custom`, show advanced option.
if (_customAdvancedOption)
{
DrawDesamplingRate(_spDesamplingRate);// Desampling rate.
DrawDesamplingRate(_spReductionRate);// Reduction rate.
EditorGUILayout.PropertyField(_spFilterMode);// Filter Mode.
EditorGUILayout.PropertyField(_spIterations);// Iterations.
}
EditorGUILayout.PropertyField(_spKeepSizeToRootCanvas);// Iterations.
serializedObject.ApplyModifiedProperties();
@@ -64,6 +110,48 @@ namespace Coffee.UIExtensions
}
}
//################################
// Private Members.
//################################
const int Bits4 = (1 << 4) - 1;
const int Bits2 = (1 << 2) - 1;
bool _customAdvancedOption = false;
SerializedProperty _spTexture;
SerializedProperty _spColor;
SerializedProperty _spRaycastTarget;
SerializedProperty _spDesamplingRate;
SerializedProperty _spReductionRate;
SerializedProperty _spFilterMode;
SerializedProperty _spIterations;
SerializedProperty _spKeepSizeToRootCanvas;
QualityMode qualityMode
{
get
{
if (_customAdvancedOption)
return QualityMode.Custom;
int qualityValue = (_spDesamplingRate.intValue << 0)
+ (_spReductionRate.intValue << 4)
+ (_spFilterMode.intValue << 8)
+ (_spIterations.intValue << 10);
return System.Enum.IsDefined(typeof(QualityMode), qualityValue) ? (QualityMode)qualityValue : QualityMode.Custom;
}
set
{
if (value != QualityMode.Custom)
{
int qualityValue = (int)value;
_spDesamplingRate.intValue = (qualityValue >> 0) & Bits4;
_spReductionRate.intValue = (qualityValue >> 4) & Bits4;
_spFilterMode.intValue = (qualityValue >> 8) & Bits2;
_spIterations.intValue = (qualityValue >> 10) & Bits4;
}
}
}
/// <summary>
/// Draws the desampling rate.
/// </summary>
+61 -21
View File
@@ -11,12 +11,11 @@ namespace Coffee.UIExtensions
[CanEditMultipleObjects]
public class UIEffectEditor : Editor
{
ReorderableList roAdditionalShadows;
SerializedProperty spAdditionalShadows;
SerializedProperty spBlurMode;
//################################
// Constant or Static Members.
//################################
/// <summary>
/// Implement this function to make a custom inspector.
/// Draw effect properties.
/// </summary>
public static void DrawEffectProperties(string shaderName, SerializedObject serializedObject)
{
@@ -93,23 +92,46 @@ namespace Coffee.UIExtensions
}
}
//################################
// Private Members.
//################################
ReorderableList _roAdditionalShadows;
SerializedProperty _spAdditionalShadows;
SerializedProperty _spBlurMode;
SerializedProperty _spCustomEffect;
SerializedProperty _spEffectMaterial;
SerializedProperty _spEffectColor;
SerializedProperty _spCustomFactorX;
SerializedProperty _spCustomFactorY;
SerializedProperty _spCustomFactorZ;
SerializedProperty _spCustomFactorW;
void OnEnable()
{
spAdditionalShadows = serializedObject.FindProperty("m_AdditionalShadows");
spBlurMode = serializedObject.FindProperty("m_BlurMode");
_spAdditionalShadows = serializedObject.FindProperty("m_AdditionalShadows");
_spBlurMode = serializedObject.FindProperty("m_BlurMode");
_spEffectColor = serializedObject.FindProperty("m_EffectColor");
roAdditionalShadows = new ReorderableList(serializedObject, spAdditionalShadows, true, true, true, true);
roAdditionalShadows.drawElementCallback = DrawElementCallback;
roAdditionalShadows.drawHeaderCallback = (rect) => EditorGUI.LabelField(rect, "Additional Shadows");
roAdditionalShadows.onAddCallback = OnAddCallback;
roAdditionalShadows.elementHeightCallback = ElementHeightCallback;
_spCustomEffect = serializedObject.FindProperty("m_CustomEffect");
_spEffectMaterial = serializedObject.FindProperty("m_EffectMaterial");
var spFactor = serializedObject.FindProperty("m_CustomFactor");
_spCustomFactorX = spFactor.FindPropertyRelative("x");
_spCustomFactorY = spFactor.FindPropertyRelative("y");
_spCustomFactorZ = spFactor.FindPropertyRelative("z");
_spCustomFactorW = spFactor.FindPropertyRelative("w");
_roAdditionalShadows = new ReorderableList(serializedObject, _spAdditionalShadows, true, true, true, true);
_roAdditionalShadows.drawElementCallback = DrawElementCallback;
_roAdditionalShadows.drawHeaderCallback = (rect) => EditorGUI.LabelField(rect, "Additional Shadows");
_roAdditionalShadows.onAddCallback = OnAddCallback;
_roAdditionalShadows.elementHeightCallback = ElementHeightCallback;
}
void OnAddCallback(ReorderableList ro)
{
spAdditionalShadows.InsertArrayElementAtIndex(ro.count);
var element = spAdditionalShadows.GetArrayElementAtIndex(ro.count - 1);
_spAdditionalShadows.InsertArrayElementAtIndex(ro.count);
var element = _spAdditionalShadows.GetArrayElementAtIndex(ro.count - 1);
element.FindPropertyRelative("shadowMode").intValue = (int)UIEffect.ShadowStyle.Shadow;
element.FindPropertyRelative("shadowColor").colorValue = Color.black;
element.FindPropertyRelative("effectDistance").vector2Value = new Vector2(1f, -1f);
@@ -119,11 +141,11 @@ namespace Coffee.UIExtensions
float ElementHeightCallback(int index)
{
var element = spAdditionalShadows.GetArrayElementAtIndex(index);
var element = _spAdditionalShadows.GetArrayElementAtIndex(index);
if (element.FindPropertyRelative("shadowMode").intValue == (int)UIEffect.ShadowStyle.None)
return 16;
return (spBlurMode.intValue == (int)UIEffect.BlurMode.None ? 66 : 84) + (EditorGUIUtility.wideMode ? 0 : 18);
return (_spBlurMode.intValue == (int)UIEffect.BlurMode.None ? 66 : 84) + (EditorGUIUtility.wideMode ? 0 : 18);
}
/// <summary>
@@ -131,7 +153,7 @@ namespace Coffee.UIExtensions
/// </summary>
void DrawElementCallback(Rect rect, int index, bool isActive, bool isFocused)
{
var sp = roAdditionalShadows.serializedProperty.GetArrayElementAtIndex(index);
var sp = _roAdditionalShadows.serializedProperty.GetArrayElementAtIndex(index);
Rect r = new Rect(rect);
r.height = EditorGUIUtility.singleLineHeight;
@@ -147,7 +169,7 @@ namespace Coffee.UIExtensions
r.y += EditorGUIUtility.wideMode ? r.height : r.height * 2;
EditorGUI.PropertyField(r, sp.FindPropertyRelative("useGraphicAlpha"));
if (spBlurMode.intValue != (int)UIEffect.BlurMode.None)
if (_spBlurMode.intValue != (int)UIEffect.BlurMode.None)
{
r.y += r.height;
EditorGUI.PropertyField(r, sp.FindPropertyRelative("shadowBlur"));
@@ -160,7 +182,25 @@ namespace Coffee.UIExtensions
public override void OnInspectorGUI()
{
serializedObject.Update();
DrawEffectProperties(UIEffect.shaderName, serializedObject);
// Custom effect.
EditorGUILayout.PropertyField(_spCustomEffect);
if(_spCustomEffect.boolValue)
{
EditorGUILayout.PropertyField(_spEffectMaterial);
EditorGUI.indentLevel++;
EditorGUILayout.Slider(_spCustomFactorX, 0, 1, new GUIContent("Effect Factor X"));
EditorGUILayout.Slider(_spCustomFactorY, 0, 1, new GUIContent("Effect Factor Y"));
EditorGUILayout.Slider(_spCustomFactorZ, 0, 1, new GUIContent("Effect Factor Z"));
EditorGUILayout.Slider(_spCustomFactorW, 0, 1, new GUIContent("Effect Factor W"));
EditorGUILayout.PropertyField(_spEffectColor);
EditorGUI.indentLevel--;
}
else
{
DrawEffectProperties(UIEffect.shaderName, serializedObject);
}
//================
// Shadow setting.
@@ -176,7 +216,7 @@ namespace Coffee.UIExtensions
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ShadowColor"));
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_UseGraphicAlpha"));
if (spBlurMode.intValue != (int)UIEffect.BlurMode.None)
if (_spBlurMode.intValue != (int)UIEffect.BlurMode.None)
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ShadowBlur"));
}
@@ -186,7 +226,7 @@ namespace Coffee.UIExtensions
//================
// Additional shadow setting.
//================
roAdditionalShadows.DoLayoutList();
_roAdditionalShadows.DoLayoutList();
serializedObject.ApplyModifiedProperties();
-7
View File
@@ -1,7 +0,0 @@
Copyright 2017 mob-sakai
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+1
View File
@@ -0,0 +1 @@
./../../LICENSE.txt
+1
View File
@@ -0,0 +1 @@
../../README.md
-327
View File
@@ -1,327 +0,0 @@
UIEffect
===
Easy to use effects for uGUI.
![image](https://user-images.githubusercontent.com/12690315/35077815-5ff8094e-fc42-11e7-92dd-99916c9f9da7.png)
[WebGL Demo](#demo) | [Download](https://github.com/mob-sakai/UIEffect/releases) | [Usage](#usage) | [Release Notes](#release-notes)
### Supports following effects!
* Grayscale
* Sepia tone
* Nega tone
* Pixelation
* Hue shift
* Cutoff (alpha-based)
* Mono (alpha-based)
* Color override
* Color additive
* Color subtract
* Blur fast(3x4)
* Blur medium(6x4)
* Blur detail(6x8)
* Shadow with effect
* Shadow
* Shadow3
* Outline
* Outline8
* Gradient vertex color
* Horizontal
* Vertical
* Angle
* Diagonal
#### And, more features!
* Control effect parameter with Animation
![image](https://user-images.githubusercontent.com/12690315/34617750-cf2c9464-f27f-11e7-8ee9-e6be3b209943.gif)
* Use for screen transition
![image](https://user-images.githubusercontent.com/12690315/34618554-71a32e40-f282-11e7-8b78-6948c50c6b58.gif)
* Multiple shadow effect to reduce rendering vertices
![image](https://user-images.githubusercontent.com/12690315/34552373-600fdab2-f164-11e7-8565-21c15af92a93.png)
* Capture image with effect, like post effect
![image](https://user-images.githubusercontent.com/12690315/34619147-868cb36a-f284-11e7-8122-b924ff09077f.gif)
* Dialog with captured image effect
![image](https://user-images.githubusercontent.com/12690315/34619468-97e3c134-f285-11e7-90b2-3a75bde13911.gif)
* Change vertex color as gradient, with rotation, offset, color correction
![image](https://user-images.githubusercontent.com/12690315/34931353-b1824df2-fa11-11e7-9dda-18aba10a8607.gif)
![image](https://user-images.githubusercontent.com/12690315/34930676-000c41d4-fa0e-11e7-825b-d5a1e757fea8.png)
<br><br><br><br>
## Demo
[WebGL Demo](https://developer.cloud.unity3d.com/share/WJTY06hfG7/webgl/)
* Effect sample
* Transition
* Dialog window with blur background
* Included in unitypackage
<br><br><br><br>
## Usage
1. Download UIEffect.unitypackage from [Releases](https://github.com/mob-sakai/UIEffect/releases) and install to your project.
1. Import the package into your Unity project. Select `Import Package > Custom Package` from the `Assets` menu.
1. Add `UIEffect` component to UI element (Image, RawImage, Text, etc...) from `Add Component` in inspector.
1. Choose effect type and adjust values in inspector.
![image](https://user-images.githubusercontent.com/12690315/34595809-3838dc54-f21e-11e7-858b-72821dca8b44.png)
1. Enjoy!
##### Requirement
* Unity 5.5+ *(included Unity 2017.x)*
* No other SDK are required
<br><br><br><br>
## Development Note
#### How does UIEffectCapturedImage work?
![image](https://user-images.githubusercontent.com/12690315/34619147-868cb36a-f284-11e7-8122-b924ff09077f.gif)
`UIEffectCapturedImage` is similar to post effect, but uses `CommandBuffer` to give effect only on the rendering result (= captured image) of a specific frame.
This effect is non-realtime, light-weight, less-camera, blit only once, but effective.
* Camera for processing effect is unnecessary.
* Process effect only once after `UIEffectCapturedImage.Capture`.
* Using reduction buffer, keep used memory size small and keep rendering load are small.
* When GameObjects with motion are on the screen, a result texture may be stirred.
* You can overlay and display like as: [Screen] | [UIEffectCapturedImage] | [Dialog A] | [UIEffectCapturedImage] | [Dialog B].
See also [Demo](#demo).
#### Why is UIEffect lightweight?
* UIEffect pre-generates material from a combination of effects. This has the following benefits.
* Draw call batching If possible, draw calls will decrease.
* Since only the required material and shader variants are included in the build, the build size will be smaller.
#### How to control effect parameters for uGUI element WITHOUT MaterialPropertyBlock?
* In general, you can use [MaterialPropertyBlock](https://docs.unity3d.com/ScriptReference/MaterialPropertyBlock.html) for renderers to control minor changes in the material without different batches.
* However, changing the [MaterialPropertyBlock](https://docs.unity3d.com/ScriptReference/MaterialPropertyBlock.html) of the uGUI element from the script will cause different batches and draw calls to increase.
* So UIEffect encodes multiple effect parameters to UV1 channel with [IMeshModifier](https://docs.unity3d.com/ScriptReference/UI.IMeshModifier.html).
* Pack four 6-bit [0-1] (64 steps) parameters into one float value.
* The parameters are low precision, but sufficient.
| uv1 | 6-bit [0-1] | 6-bit [0-1] | 6-bit [0-1] | 6-bit [0-1] |
|-|-|-|-|-|
| x(32bit float) | Tone level | *Empty* | Blur level | *Empty* |
| y(32bit float) | Red channel | Green channel | Blue channel | Alpha channel |
#### Note: Unity 5.6+
In Unity 5.6+, Canvas supports **Additional Shader Channels**.
Please enable `TexCoord1` to use UIEffect.
![image](https://user-images.githubusercontent.com/12690315/28405830-f4f261e8-6d68-11e7-9faf-7e5442062f59.png)
![image](https://user-images.githubusercontent.com/12690315/34560894-191b6cda-f18b-11e7-9de2-9a9d13f72ccd.png)
#### Note: if you include prefabs / scenes containing UIEffect in AssetBundle.
Use script define symbol `UIEFFECT_SEPARATE`.
Unused shader variants and materials will be excluded from AssetBundles.
||Combined mode (default)|Separated mode|
|-|-|-|
|Script define symbol| - |`UIEFFECT_SEPARATE`|
|Included in build|Only used variants|Only used variants|
|Included in AssetBundle|All variants (Heavy!)|Only used variants|
|Look in editor|![comb](https://user-images.githubusercontent.com/12690315/35324040-df4f1684-0132-11e8-9534-f958b93de158.png)|![sep](https://user-images.githubusercontent.com/12690315/35324405-fd5e89a6-0133-11e8-9d23-71ccc424fa21.png)|
#### How to improve performance?
* Use `ShaderVariantCollection` to preload shader.
https://docs.unity3d.com/Manual/OptimizingShaderLoadTime.html
* Set camera's clear flag to "Solid Color".
* Enable multi thread rendering.
<br><br><br><br>
## Release Notes
### ver.2.0.0
* Feature: Switch separate/combine materials by script symbol "UIEFFECT_SEPARATE".
* Combined mode (default)
* The effect materials are sub-asset, and will be hidden in project view & object picker window.
* Unused shader variants and materials will be excluded from build, but they will be **included in AssetBundle.**
![comb](https://user-images.githubusercontent.com/12690315/35324040-df4f1684-0132-11e8-9534-f958b93de158.png)
* Separated mode
* Use script define symbol `UIEFFECT_SEPARATE`.
* The effect materials are main-asset, and will be displayed in project view & object picker window.
* In Editor, the effect materials are generated as asset, on demand.
* Unused shader variants and materials will be excluded from build and AssetBundle.
* We recommend this mode only if you include prefabs / scenes containing UIEffect in AssetBundle.
![sep](https://user-images.githubusercontent.com/12690315/35324405-fd5e89a6-0133-11e8-9d23-71ccc424fa21.png)
* Changed: Default is "Combined mode".
* Changed: Change namespace to `Coffee.UIExtensions`.
* Changed: Unity 5.3.x & 5.4.x are no longer supported.
### ver.1.6.1
* Fixed: Cannot access protected member `UnityEngine.UI.BaseMeshEffect.graphic` in Unity5.6+.
### ver.1.6.0
* Changed: UIEffect inherit BaseMeshEffect.
* Fixed: Pixelization is incorrect.
* Changed: ShadowMode -> ShadowStyle.
* Changed: Blur level is range [0-1].
### ver.1.5.1
* Fixed: An error occurs when no effect is specified for UICapturedImage. [#36](https://github.com/mob-sakai/UIEffect/issues/36)
### ver.1.5.0
* Feature: Add ToneMode `Hue Shift`.
![image](https://user-images.githubusercontent.com/12690315/34830409-18114e44-f727-11e7-849a-0d61a35f03ea.png)
* Feature: Add ShadowMode `Shadow3`.
![image](https://user-images.githubusercontent.com/12690315/34930812-cb87dc24-fa0e-11e7-90a7-0013e2ba55d1.png)
* Feature: Add `UIGradient` component to change vertex color as gradient.
* Gradient direction
* Horizontal
* Vertical
* Angle
* Diagonal
* Rotation and offset
* Text gradient style
* Rect
* Fit
* Split
* Color space
* Uninitialized
* Gammma
* Linear
* Ignore aspect ratio
![image](https://user-images.githubusercontent.com/12690315/34930676-000c41d4-fa0e-11e7-825b-d5a1e757fea8.png)
### ver.1.4.4
* Fixed: Error has occur on edit prefab. [#27](https://github.com/mob-sakai/UIEffect/issues/27)
### ver.1.4.3
* Fixed: Color effect is incorrect. [#19](https://github.com/mob-sakai/UIEffect/issues/19)
### ver.1.4.2
* Fixed: Error has occur on after deserialize. [#16](https://github.com/mob-sakai/UIEffect/issues/16)
### ver.1.4.1
* Fixed: Demo link in `readme.md` is broken.
### ver.1.4.0
* Changed: ToneMode, ColorMode, BlurMode can be changed only in editor.
* Changed: Cutoff's level is reversed.
* Feature: Exclude unused shader variant from build.
* Add: Add many materials for shader variant, but exclude unused materials from build.
Build report of demo project is as following.
| | ver.1.3.0 | ver.1.4.0 |
|--|-----------|-----------|
| UI-Effect.shader | All 112 variants, 170.7 kb | 21 variants, 31.4 kb |
| UI-EffectCapturedImage.shader | All 80 variants, 49.0 kb | 2 variants, 7.3 kb |
| Materials in build | Instantiate on play, 0 kb | 23 items, about 6.9 kb |
| Total | 219.7 kb | 45.6 kb |
### ver.1.3.0
* Feature: Capture image with effect, like post effect.
* Demo: Add transition blur button & dialog with captured image effect.
![image](https://user-images.githubusercontent.com/12690315/34619468-97e3c134-f285-11e7-90b2-3a75bde13911.gif)
### ver.1.2.0
* Fixed : Pixelaration shifts to the lower right.
* Fixed : Cutoff alpha is incorrect.
* Feature: Supports multiple shadow effect for reduce rendering vertices.
![image](https://user-images.githubusercontent.com/12690315/34552373-600fdab2-f164-11e7-8565-21c15af92a93.png)
* Feature: New blur effect mode : `Medium`.
* Feature: Fix button to enable TexCoord1 of Canvas.additionalShaderChannels to use UIEffect.
![image](https://user-images.githubusercontent.com/12690315/34560894-191b6cda-f18b-11e7-9de2-9a9d13f72ccd.png)
* Changed : UIEffect.color is obsolete, use UIEffect.effectColor instead.
* Changed: Blur range is [0-2].
* Refactoring: Shader refactoring.
* Demo: Add transition button & multiple shadows.
### ver.1.1.0
* Feature: Add Pixelaration effect.
* Feature: Add Cutoff/Mono effect for patterned alpha images. It can be used for masks and transitions!
![image](https://user-images.githubusercontent.com/12690315/34618554-71a32e40-f282-11e7-8b78-6948c50c6b58.gif)
### ver.1.0.0
* Feature: Shader supports pre-processer macros (for example UNITY_VERTEX_OUTPUT_STEREO) for Unity 5.3.x, 5.4.x and 5.5.x.
* Feature: Supports changing value from animation.
* Feature: Supports Tone effect.
* grayscale
* sepia
* nega
* Feature: Supports Color effect.
* set
* add
* sub
* Feature: Supports Blur effect.
* fast
* detail
* Fix: Color effect will not be properly when it was rotated.
* Performance: Shader supports multi-compile for performance.
* Performance: Cache same effect materials to reduce draw calls.
* Improve: Supports mobile devices.
* Improve: Simplify component & inspector.
<br><br><br><br>
## License
* MIT
* © UTJ/UCL
## Author
[mob-sakai](https://github.com/mob-sakai)
## See Also
* GitHub Page : https://github.com/mob-sakai/UIEffect
* Releases : https://github.com/mob-sakai/UIEffect/releases
* Issue tracker : https://github.com/mob-sakai/UIEffect/issues
* Current Project : https://github.com/mob-sakai/UIEffect/projects/1
+9 -6
View File
@@ -85,7 +85,10 @@ Shader "UI/Hidden/UI-Effect"
#endif
#if defined (UI_TONE) || defined (UI_BLUR)
half3 effectFactor : TEXCOORD2;
half4 effectFactor : TEXCOORD2;
#endif
#if UI_TONE_HUE || UI_TONE_PIXEL
half4 extraFactor : TEXCOORD3;
#endif
};
@@ -112,10 +115,10 @@ Shader "UI/Hidden/UI-Effect"
#endif
#if UI_TONE_HUE
OUT.effectFactor.y = sin(OUT.effectFactor.x*3.14159265359*2);
OUT.effectFactor.x = cos(OUT.effectFactor.x*3.14159265359*2);
OUT.extraFactor.x = cos(OUT.effectFactor.x*3.14159265359 * 2);
OUT.extraFactor.y = sin(OUT.effectFactor.x*3.14159265359 * 2);
#elif UI_TONE_PIXEL
OUT.effectFactor.xy = max(2, (1-OUT.effectFactor.x) * _MainTex_TexelSize.zw);
OUT.extraFactor.xy = max(2, (1-OUT.effectFactor.x*0.98) * _MainTex_TexelSize.zw);
#endif
#if defined (UI_COLOR)
@@ -129,7 +132,7 @@ Shader "UI/Hidden/UI-Effect"
fixed4 frag(v2f IN) : SV_Target
{
#if UI_TONE_PIXEL
IN.texcoord = round(IN.texcoord * IN.effectFactor.xy) / IN.effectFactor.xy;
IN.texcoord = round(IN.texcoord * IN.extraFactor.xy) / IN.extraFactor.xy;
#endif
#if defined (UI_BLUR)
@@ -149,7 +152,7 @@ Shader "UI/Hidden/UI-Effect"
color.rgb = IN.color.rgb;
color.a = color.a * tex2D(_MainTex, IN.texcoord).a + IN.effectFactor.x * 2 - 1;
#elif UI_TONE_HUE
color.rgb = shift_hue(color.rgb, IN.effectFactor.x, IN.effectFactor.y);
color.rgb = shift_hue(color.rgb, IN.extraFactor.x, IN.extraFactor.y);
#elif defined (UI_TONE) & !UI_TONE_CUTOFF
color = ApplyToneEffect(color, IN.effectFactor.x);
#endif
+29 -3
View File
@@ -127,6 +127,9 @@ namespace Coffee.UIExtensions
[SerializeField] List<AdditionalShadow> m_AdditionalShadows = new List<AdditionalShadow>();
[SerializeField] bool m_CustomEffect = false;
[SerializeField] Vector4 m_CustomFactor = new Vector4();
//################################
// Public Members.
//################################
@@ -200,6 +203,11 @@ namespace Coffee.UIExtensions
/// </summary>
public List<AdditionalShadow> additionalShadows { get { return m_AdditionalShadows; } }
/// <summary>
/// Custom effect factor.
/// </summary>
public Vector4 customFactor { get { return m_CustomFactor; } set { m_CustomFactor = value; _SetDirty(); } }
/// <summary>
/// This function is called when the object becomes enabled and active.
/// </summary>
@@ -237,7 +245,7 @@ namespace Coffee.UIExtensions
{
// Pack some effect factors to 1 float.
Vector2 factor = new Vector2(
_PackToFloat(toneLevel, 0, blur, 0),
m_CustomEffect ? _PackToFloat(m_CustomFactor) : _PackToFloat(toneLevel, 0, blur, 0),
_PackToFloat(effectColor.r, effectColor.g, effectColor.b, effectColor.a)
);
@@ -284,6 +292,9 @@ namespace Coffee.UIExtensions
public void OnAfterDeserialize()
{
if (m_CustomEffect)
return;
var obj = this;
EditorApplication.delayCall += () =>
{
@@ -392,7 +403,7 @@ namespace Coffee.UIExtensions
/// Append shadow vertices.
/// * It is similar to Shadow component implementation.
/// </summary>
static void _ApplyShadow(List<UIVertex> verts, ref int start, ref int end, ShadowStyle mode, float toneLevel, float blur, Vector2 effectDistance, Color color, bool useGraphicAlpha)
void _ApplyShadow(List<UIVertex> verts, ref int start, ref int end, ShadowStyle mode, float toneLevel, float blur, Vector2 effectDistance, Color color, bool useGraphicAlpha)
{
if (ShadowStyle.None == mode)
return;
@@ -437,7 +448,7 @@ namespace Coffee.UIExtensions
/// Append shadow vertices.
/// * It is similar to Shadow component implementation.
/// </summary>
static void _ApplyShadowZeroAlloc(List<UIVertex> verts, ref int start, ref int end, float x, float y, Vector2 factor, Color color, bool useGraphicAlpha)
void _ApplyShadowZeroAlloc(List<UIVertex> verts, ref int start, ref int end, float x, float y, Vector2 factor, Color color, bool useGraphicAlpha)
{
// Check list capacity.
var neededCapacity = verts.Count + end - start;
@@ -456,6 +467,12 @@ namespace Coffee.UIExtensions
vt.position.Set(v.x + x, v.y + y, v.z);
Color vertColor = color;
if(colorMode != ColorMode.None)
{
vertColor.r = vertColor.g = vertColor.b = 1;
}
vertColor.a = useGraphicAlpha ? color.a * vt.color.a / 255 : color.a;
vt.color = vertColor;
@@ -490,5 +507,14 @@ namespace Coffee.UIExtensions
+ (Mathf.FloorToInt(y * PRECISION) << 6)
+ 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(Vector4 factor)
{
return _PackToFloat(Mathf.Clamp01(factor.x), Mathf.Clamp01(factor.y), Mathf.Clamp01(factor.z), Mathf.Clamp01(factor.w));
}
}
}
+49 -20
View File
@@ -53,6 +53,8 @@ namespace Coffee.UIExtensions
[SerializeField] DesamplingRate m_ReductionRate;
[SerializeField] FilterMode m_FilterMode = FilterMode.Bilinear;
[SerializeField] Material m_EffectMaterial;
[SerializeField][Range(1, 8)] int m_Iterations = 1;
[SerializeField] bool m_KeepCanvasSize = true;
//################################
@@ -112,6 +114,16 @@ namespace Coffee.UIExtensions
/// Captured texture.
/// </summary>
public RenderTexture capturedTexture { get { return _rt; } }
/// <summary>
/// Iterations.
/// </summary>
public int iterations { get { return m_Iterations; } set { m_Iterations = value; } }
/// <summary>
/// Fits graphic size to the root canvas.
/// </summary>
public bool keepCanvasSize { get { return m_KeepCanvasSize; } set { m_KeepCanvasSize = value; } }
/// <summary>
/// This function is called when the MonoBehaviour will be destroyed.
@@ -187,8 +199,9 @@ namespace Coffee.UIExtensions
// Cache id for RT.
if (s_CopyId == 0)
{
s_CopyId = Shader.PropertyToID("_ScreenCopy");
s_EffectId = Shader.PropertyToID("_Effect");
s_CopyId = Shader.PropertyToID("_UIEffectCapturedImage_ScreenCopyId");
s_EffectId1 = Shader.PropertyToID("_UIEffectCapturedImage_EffectId1");
s_EffectId2 = Shader.PropertyToID("_UIEffectCapturedImage_EffectId2");
}
// If size of generated result RT has changed, relese it.
@@ -237,21 +250,31 @@ namespace Coffee.UIExtensions
_buffer.Blit(s_CopyId, rtId);
_buffer.ReleaseTemporaryRT(s_CopyId);
}
// Blit with reduction buffer.
else if (m_DesamplingRate < m_ReductionRate)
{
GetDesamplingSize(m_ReductionRate, out w, out h);
_buffer.GetTemporaryRT(s_EffectId, w, h, 0, m_FilterMode);
_buffer.Blit(s_CopyId, s_EffectId, mat);
_buffer.ReleaseTemporaryRT(s_CopyId);
_buffer.Blit(s_EffectId, rtId);
_buffer.ReleaseTemporaryRT(s_EffectId);
}
// Blit without reduction buffer.
// Blit with effect.
else
{
_buffer.Blit(s_CopyId, rtId, mat);
GetDesamplingSize(m_ReductionRate, out w, out h);
_buffer.GetTemporaryRT(s_EffectId1, w, h, 0, m_FilterMode);
_buffer.Blit(s_CopyId, s_EffectId1, mat); // Apply effect (copied screen -> effect1).
_buffer.ReleaseTemporaryRT(s_CopyId);
// Iterate the operation.
if(1 < m_Iterations)
{
_buffer.GetTemporaryRT(s_EffectId2, w, h, 0, m_FilterMode);
for (int i = 1; i < m_Iterations; i++)
{
// Apply effect (effect1 -> effect2, or effect2 -> effect1).
_buffer.Blit(i % 2 == 0 ? s_EffectId2 : s_EffectId1, i % 2 == 0 ? s_EffectId1 : s_EffectId2, mat);
}
}
_buffer.Blit(m_Iterations % 2 == 0 ? s_EffectId2 : s_EffectId1, rtId);
_buffer.ReleaseTemporaryRT(s_EffectId1);
if (1 < m_Iterations)
{
_buffer.ReleaseTemporaryRT(s_EffectId2);
}
}
}
@@ -259,11 +282,15 @@ namespace Coffee.UIExtensions
_camera.AddCommandBuffer(kCameraEvent, _buffer);
// StartCoroutine by CanvasScaler.
#if UNITY_5_4_OR_NEWER
canvas.rootCanvas.GetComponent<CanvasScaler>().StartCoroutine(_CoUpdateTextureOnNextFrame());
#else
canvas.GetComponentInParent<CanvasScaler>().StartCoroutine(_CoUpdateTextureOnNextFrame());
#endif
var rootCanvas = canvas.rootCanvas;
var scaler = rootCanvas.GetComponent<CanvasScaler>();
scaler.StartCoroutine(_CoUpdateTextureOnNextFrame());
if (m_KeepCanvasSize)
{
var size = (rootCanvas.transform as RectTransform).rect.size;
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, size.x);
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, size.y);
}
}
/// <summary>
@@ -286,11 +313,13 @@ namespace Coffee.UIExtensions
CommandBuffer _buffer;
static int s_CopyId;
static int s_EffectId;
static int s_EffectId1;
static int s_EffectId2;
/// <summary>
/// Release genarated objects.
/// </summary>
/// <param name="releaseRT">If set to <c>true</c> release cached RenderTexture.</param>
void _Release(bool releaseRT)
{
if (releaseRT)
+155
View File
@@ -0,0 +1,155 @@
# Changelog
## [v2.2.0](https://github.com/mob-sakai/UIEffect/tree/v2.2.0) (2018-04-12)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.1.0...v2.2.0)
**Implemented enhancements:**
- Feature: Customize shader/material. You can create a custom ui shader and control it with UIEffct. [\#46](https://github.com/mob-sakai/UIEffect/issues/46)
- Feature: UIEffectCapturedImage supports keep canvas size. [\#54](https://github.com/mob-sakai/UIEffect/issues/54)
- Feature: UIEffectCapturedImage supports `Quality Type` to easy setup. [\#53](https://github.com/mob-sakai/UIEffect/issues/53)
**Fixed bugs:**
- Bug: Color effect on shadow is incorrect. [\#55](https://github.com/mob-sakai/UIEffect/issues/55)
**Closed issues:**
- Change: Reduce the pixelation effect when tone level = 1. [\#57](https://github.com/mob-sakai/UIEffect/issues/57)
## [v2.1.0](https://github.com/mob-sakai/UIEffect/tree/v2.1.0) (2018-04-04)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v2.0.0...v2.1.0)
**Implemented enhancements:**
- Feature: UIEffectCapturedImage support iterative operation [\#48](https://github.com/mob-sakai/UIEffect/issues/48)
## [v2.0.0](https://github.com/mob-sakai/UIEffect/tree/v2.0.0) (2018-01-25)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.6.1...v2.0.0)
**Breaking changes:**
- Important: Unity 5.3.x & 5.4.x are no longer supported. [\#40](https://github.com/mob-sakai/UIEffect/issues/40)
**Implemented enhancements:**
- Improve: Reduce the materials. Too many effect materials are exist. [\#15](https://github.com/mob-sakai/UIEffect/issues/15)
**Closed issues:**
- Change: Change namespace to Coffee.UIExtensions [\#6](https://github.com/mob-sakai/UIEffect/issues/6)
## [v1.6.1](https://github.com/mob-sakai/UIEffect/tree/v1.6.1) (2018-01-25)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.6.0...v1.6.1)
**Fixed bugs:**
- Bug: Cannot access protected member `UnityEngine.UI.BaseMeshEffect.graphic` [\#41](https://github.com/mob-sakai/UIEffect/issues/41)
## [v1.6.0](https://github.com/mob-sakai/UIEffect/tree/v1.6.0) (2018-01-18)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.5.1...v1.6.0)
**Fixed bugs:**
- Bug: Pixelization is incorrect. [\#34](https://github.com/mob-sakai/UIEffect/issues/34)
**Closed issues:**
- Change: UIEffect inherit BaseMeshEffect. [\#35](https://github.com/mob-sakai/UIEffect/issues/35)
- Change: Blur level range to \[0-1\] [\#32](https://github.com/mob-sakai/UIEffect/issues/32)
- Change: ShadowMode -\> ShadowStyle [\#18](https://github.com/mob-sakai/UIEffect/issues/18)
## [v1.5.1](https://github.com/mob-sakai/UIEffect/tree/v1.5.1) (2018-01-18)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.5.0...v1.5.1)
**Fixed bugs:**
- Bug: An error occurs when no effect is specified for UICapturedImage. [\#36](https://github.com/mob-sakai/UIEffect/issues/36)
## [v1.5.0](https://github.com/mob-sakai/UIEffect/tree/v1.5.0) (2018-01-16)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.4.4...v1.5.0)
**Implemented enhancements:**
- Feature: ShadowMode 'Shadow 3' [\#11](https://github.com/mob-sakai/UIEffect/issues/11)
- Feature: Hue [\#8](https://github.com/mob-sakai/UIEffect/issues/8)
- Feature: Gradient [\#7](https://github.com/mob-sakai/UIEffect/issues/7)
## [v1.4.4](https://github.com/mob-sakai/UIEffect/tree/v1.4.4) (2018-01-16)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.4.3...v1.4.4)
**Fixed bugs:**
- Bug: Error has occur on edit prefab. [\#27](https://github.com/mob-sakai/UIEffect/issues/27)
## [v1.4.3](https://github.com/mob-sakai/UIEffect/tree/v1.4.3) (2018-01-15)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.4.2...v1.4.3)
**Fixed bugs:**
- Bug: Color effect is incorrect. [\#19](https://github.com/mob-sakai/UIEffect/issues/19)
## [v1.4.2](https://github.com/mob-sakai/UIEffect/tree/v1.4.2) (2018-01-14)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.4.1...v1.4.2)
**Implemented enhancements:**
- Feature: ColorMode `Override` [\#12](https://github.com/mob-sakai/UIEffect/issues/12)
**Fixed bugs:**
- Bug: Error has occur OnAfterDeserialize in editor. [\#16](https://github.com/mob-sakai/UIEffect/issues/16)
## [v1.4.1](https://github.com/mob-sakai/UIEffect/tree/v1.4.1) (2018-01-10)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.4.0...v1.4.1)
## [v1.4.0](https://github.com/mob-sakai/UIEffect/tree/v1.4.0) (2018-01-07)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.3.0...v1.4.0)
**Implemented enhancements:**
- Feature: Exclude unused shader variants from build. [\#5](https://github.com/mob-sakai/UIEffect/issues/5)
## [v1.3.0](https://github.com/mob-sakai/UIEffect/tree/v1.3.0) (2018-01-06)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.2.0...v1.3.0)
## [v1.2.0](https://github.com/mob-sakai/UIEffect/tree/v1.2.0) (2018-01-05)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.1.0...v1.2.0)
**Implemented enhancements:**
- Feature: Fast multiple shadow effect. [\#2](https://github.com/mob-sakai/UIEffect/issues/2)
**Fixed bugs:**
- Pixelaration shifts to the lower right. [\#4](https://github.com/mob-sakai/UIEffect/issues/4)
## [v1.1.0](https://github.com/mob-sakai/UIEffect/tree/v1.1.0) (2017-08-17)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/v1.0.0...v1.1.0)
**Implemented enhancements:**
- Feature: Pixelization effect [\#1](https://github.com/mob-sakai/UIEffect/issues/1)
## [v1.0.0](https://github.com/mob-sakai/UIEffect/tree/v1.0.0) (2017-03-01)
[Full Changelog](https://github.com/mob-sakai/UIEffect/compare/a9c4ec4e72a055ca5e5c24f6a75c6720f0f6fd7f...v1.0.0)
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
+197
View File
@@ -0,0 +1,197 @@
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-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)
[![](https://img.shields.io/github/last-commit/mob-sakai/UIEffect/develop.svg?label=last%20commit%20to%20develop)](https://github.com/mob-sakai/UIEffect/commits/develop)
[![](https://img.shields.io/github/issues/mob-sakai/UIEffect.svg)](https://github.com/mob-sakai/UIEffect/issues)
<< [Description](#Description) | [WebGL Demo](#demo) | [Download](https://github.com/mob-sakai/UIEffect/releases) | [Usage](#usage) | [Development Note](#development-note) | [Change log](https://github.com/mob-sakai/UIEffect/blob/develop/CHANGELOG.md) >>
<br><br><br><br>
## Description
### Supports following effects!
![image](https://user-images.githubusercontent.com/12690315/35077815-5ff8094e-fc42-11e7-92dd-99916c9f9da7.png)
* Grayscale
* Sepia tone
* Nega tone
* Pixelation
* Hue shift
* Cutoff (alpha-based)
* Mono (alpha-based)
* Color overwrite
* Color additive
* Color subtract
* Blur fast(3x4)
* Blur medium(6x4)
* Blur detail(6x8)
* Shadow with effect
* Shadow
* Shadow3
* Outline
* Outline8
* Gradient vertex color
* Horizontal
* Vertical
* Angle
* Diagonal
### Easy to control effect parameters!
![image](https://user-images.githubusercontent.com/12690315/38594668-636dd3ac-3d82-11e8-9951-820964a6a95f.gif)
### And, more features!
* Control the effect parameters without instantiating the material
* Control the effect parameters with AnimationClip
![image](https://user-images.githubusercontent.com/12690315/34617750-cf2c9464-f27f-11e7-8ee9-e6be3b209943.gif)
* Use for screen transition
![image](https://user-images.githubusercontent.com/12690315/34618554-71a32e40-f282-11e7-8b78-6948c50c6b58.gif)
* Multiple shadow effect to reduce rendering vertices
![image](https://user-images.githubusercontent.com/12690315/34552373-600fdab2-f164-11e7-8565-21c15af92a93.png)
* UICapturedEffectImage: The captured image with effect, like post effect
![image](https://user-images.githubusercontent.com/12690315/34619147-868cb36a-f284-11e7-8122-b924ff09077f.gif)
* UICapturedEffectImage: Dialog window with the captured image effect
![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)
<br><br><br><br>
## Demo
[WebGL Demo](https://developer.cloud.unity3d.com/share/WJTY06hfG7/webgl/)
* Effect sample
* Transition
* Dialog window with blured background
* Included in unitypackage
<br><br><br><br>
## Usage
1. Download UIEffect.unitypackage from [Releases](https://github.com/mob-sakai/UIEffect/releases).
1. Import the package into your Unity project. Select `Import Package > Custom Package` from the `Assets` menu.
1. Add `UIEffect` component to UI element (Image, RawImage, Text, etc...) from `Add Component` in inspector.
1. Choose effect type and adjust values in inspector.
![image](https://user-images.githubusercontent.com/12690315/34595809-3838dc54-f21e-11e7-858b-72821dca8b44.png)
1. Enjoy!
##### Requirement
* Unity 5.5+ *(included Unity 2017.x)*
* No other SDK are required
<br><br><br><br>
## Development Note
#### How does UIEffectCapturedImage work?
![image](https://user-images.githubusercontent.com/12690315/34619147-868cb36a-f284-11e7-8122-b924ff09077f.gif)
`UIEffectCapturedImage` is similar to post effect, but uses `CommandBuffer` to give effect only on the rendering result (= captured image) of a specific frame.
This effect is non-realtime, light-weight, less-camera, blit only once, but effective.
* Camera for processing effect is unnecessary.
* Process effect only once after `UIEffectCapturedImage.Capture`.
* Using reduction buffer, keep used memory size small and keep rendering load are small.
* When GameObjects with motion are on the screen, a result texture may be stirred.
* You can overlay and display like as: [Screen] | [UIEffectCapturedImage] | [Dialog A] | [UIEffectCapturedImage] | [Dialog B].
See also [Demo](#demo).
#### Why is UIEffect lightweight?
* UIEffect pre-generates material from a combination of effects. This has the following benefits.
* Draw call batching If possible, draw calls will decrease.
* Since only the required material and shader variants are included in the build, the build size will be smaller.
#### How to control effect parameters for uGUI element WITHOUT MaterialPropertyBlock?
* In general, you can use [MaterialPropertyBlock](https://docs.unity3d.com/ScriptReference/MaterialPropertyBlock.html) for renderers to control minor changes in the material without different batches.
* However, changing the [MaterialPropertyBlock](https://docs.unity3d.com/ScriptReference/MaterialPropertyBlock.html) of the uGUI element from the script will cause different batches and draw calls to increase.
* So UIEffect encodes multiple effect parameters to UV1 channel with [IMeshModifier](https://docs.unity3d.com/ScriptReference/UI.IMeshModifier.html).
* Pack four 6-bit [0-1] (64 steps) parameters into one float value.
* The parameters are low precision, but sufficient.
| uv1 | 6-bit [0-1] | 6-bit [0-1] | 6-bit [0-1] | 6-bit [0-1] |
|-|-|-|-|-|
| x(32bit float) | Tone level | *Empty* | Blur level | *Empty* |
| y(32bit float) | Red channel | Green channel | Blue channel | Alpha channel |
#### Note: Unity 5.6+
In Unity 5.6+, Canvas supports **Additional Shader Channels**.
Please enable `TexCoord1` to use UIEffect.
![image](https://user-images.githubusercontent.com/12690315/28405830-f4f261e8-6d68-11e7-9faf-7e5442062f59.png)
![image](https://user-images.githubusercontent.com/12690315/34560894-191b6cda-f18b-11e7-9de2-9a9d13f72ccd.png)
#### Note: if you include prefabs / scenes containing UIEffect in AssetBundle.
Use script define symbol `UIEFFECT_SEPARATE`.
Unused shader variants and materials will be excluded from AssetBundles.
||Combined mode (default)|Separated mode|
|-|-|-|
|Script define symbol| - |`UIEFFECT_SEPARATE`|
|Included in build|Only used variants|Only used variants|
|Included in AssetBundle|All variants (Heavy!)|Only used variants|
|Look in editor|![comb](https://user-images.githubusercontent.com/12690315/35324040-df4f1684-0132-11e8-9534-f958b93de158.png)|![sep](https://user-images.githubusercontent.com/12690315/35324405-fd5e89a6-0133-11e8-9d23-71ccc424fa21.png)|
#### How to improve performance?
* Use `ShaderVariantCollection` to preload shader.
https://docs.unity3d.com/Manual/OptimizingShaderLoadTime.html
* Set camera's clear flag to "Solid Color".
* Enable multi thread rendering.
<br><br><br><br>
## License
* MIT
* © UTJ/UCL
## Author
[mob-sakai](https://github.com/mob-sakai)
## See Also
* GitHub page : https://github.com/mob-sakai/UIEffect
* Releases : https://github.com/mob-sakai/UIEffect/releases
* Issue tracker : https://github.com/mob-sakai/UIEffect/issues
* Current project : https://github.com/mob-sakai/UIEffect/projects/1
* Change log : https://github.com/mob-sakai/UIEffect/blob/master/CHANGELOG.md
-327
View File
@@ -1,327 +0,0 @@
UIEffect
===
Easy to use effects for uGUI.
![image](https://user-images.githubusercontent.com/12690315/35077815-5ff8094e-fc42-11e7-92dd-99916c9f9da7.png)
[WebGL Demo](#demo) | [Download](https://github.com/mob-sakai/UIEffect/releases) | [Usage](#usage) | [Release Notes](#release-notes)
### Supports following effects!
* Grayscale
* Sepia tone
* Nega tone
* Pixelation
* Hue shift
* Cutoff (alpha-based)
* Mono (alpha-based)
* Color override
* Color additive
* Color subtract
* Blur fast(3x4)
* Blur medium(6x4)
* Blur detail(6x8)
* Shadow with effect
* Shadow
* Shadow3
* Outline
* Outline8
* Gradient vertex color
* Horizontal
* Vertical
* Angle
* Diagonal
#### And, more features!
* Control effect parameter with Animation
![image](https://user-images.githubusercontent.com/12690315/34617750-cf2c9464-f27f-11e7-8ee9-e6be3b209943.gif)
* Use for screen transition
![image](https://user-images.githubusercontent.com/12690315/34618554-71a32e40-f282-11e7-8b78-6948c50c6b58.gif)
* Multiple shadow effect to reduce rendering vertices
![image](https://user-images.githubusercontent.com/12690315/34552373-600fdab2-f164-11e7-8565-21c15af92a93.png)
* Capture image with effect, like post effect
![image](https://user-images.githubusercontent.com/12690315/34619147-868cb36a-f284-11e7-8122-b924ff09077f.gif)
* Dialog with captured image effect
![image](https://user-images.githubusercontent.com/12690315/34619468-97e3c134-f285-11e7-90b2-3a75bde13911.gif)
* Change vertex color as gradient, with rotation, offset, color correction
![image](https://user-images.githubusercontent.com/12690315/34931353-b1824df2-fa11-11e7-9dda-18aba10a8607.gif)
![image](https://user-images.githubusercontent.com/12690315/34930676-000c41d4-fa0e-11e7-825b-d5a1e757fea8.png)
<br><br><br><br>
## Demo
[WebGL Demo](https://developer.cloud.unity3d.com/share/WJTY06hfG7/webgl/)
* Effect sample
* Transition
* Dialog window with blur background
* Included in unitypackage
<br><br><br><br>
## Usage
1. Download UIEffect.unitypackage from [Releases](https://github.com/mob-sakai/UIEffect/releases) and install to your project.
1. Import the package into your Unity project. Select `Import Package > Custom Package` from the `Assets` menu.
1. Add `UIEffect` component to UI element (Image, RawImage, Text, etc...) from `Add Component` in inspector.
1. Choose effect type and adjust values in inspector.
![image](https://user-images.githubusercontent.com/12690315/34595809-3838dc54-f21e-11e7-858b-72821dca8b44.png)
1. Enjoy!
##### Requirement
* Unity 5.5+ *(included Unity 2017.x)*
* No other SDK are required
<br><br><br><br>
## Development Note
#### How does UIEffectCapturedImage work?
![image](https://user-images.githubusercontent.com/12690315/34619147-868cb36a-f284-11e7-8122-b924ff09077f.gif)
`UIEffectCapturedImage` is similar to post effect, but uses `CommandBuffer` to give effect only on the rendering result (= captured image) of a specific frame.
This effect is non-realtime, light-weight, less-camera, blit only once, but effective.
* Camera for processing effect is unnecessary.
* Process effect only once after `UIEffectCapturedImage.Capture`.
* Using reduction buffer, keep used memory size small and keep rendering load are small.
* When GameObjects with motion are on the screen, a result texture may be stirred.
* You can overlay and display like as: [Screen] | [UIEffectCapturedImage] | [Dialog A] | [UIEffectCapturedImage] | [Dialog B].
See also [Demo](#demo).
#### Why is UIEffect lightweight?
* UIEffect pre-generates material from a combination of effects. This has the following benefits.
* Draw call batching If possible, draw calls will decrease.
* Since only the required material and shader variants are included in the build, the build size will be smaller.
#### How to control effect parameters for uGUI element WITHOUT MaterialPropertyBlock?
* In general, you can use [MaterialPropertyBlock](https://docs.unity3d.com/ScriptReference/MaterialPropertyBlock.html) for renderers to control minor changes in the material without different batches.
* However, changing the [MaterialPropertyBlock](https://docs.unity3d.com/ScriptReference/MaterialPropertyBlock.html) of the uGUI element from the script will cause different batches and draw calls to increase.
* So UIEffect encodes multiple effect parameters to UV1 channel with [IMeshModifier](https://docs.unity3d.com/ScriptReference/UI.IMeshModifier.html).
* Pack four 6-bit [0-1] (64 steps) parameters into one float value.
* The parameters are low precision, but sufficient.
| uv1 | 6-bit [0-1] | 6-bit [0-1] | 6-bit [0-1] | 6-bit [0-1] |
|-|-|-|-|-|
| x(32bit float) | Tone level | *Empty* | Blur level | *Empty* |
| y(32bit float) | Red channel | Green channel | Blue channel | Alpha channel |
#### Note: Unity 5.6+
In Unity 5.6+, Canvas supports **Additional Shader Channels**.
Please enable `TexCoord1` to use UIEffect.
![image](https://user-images.githubusercontent.com/12690315/28405830-f4f261e8-6d68-11e7-9faf-7e5442062f59.png)
![image](https://user-images.githubusercontent.com/12690315/34560894-191b6cda-f18b-11e7-9de2-9a9d13f72ccd.png)
#### Note: if you include prefabs / scenes containing UIEffect in AssetBundle.
Use script define symbol `UIEFFECT_SEPARATE`.
Unused shader variants and materials will be excluded from AssetBundles.
||Combined mode (default)|Separated mode|
|-|-|-|
|Script define symbol| - |`UIEFFECT_SEPARATE`|
|Included in build|Only used variants|Only used variants|
|Included in AssetBundle|All variants (Heavy!)|Only used variants|
|Look in editor|![comb](https://user-images.githubusercontent.com/12690315/35324040-df4f1684-0132-11e8-9534-f958b93de158.png)|![sep](https://user-images.githubusercontent.com/12690315/35324405-fd5e89a6-0133-11e8-9d23-71ccc424fa21.png)|
#### How to improve performance?
* Use `ShaderVariantCollection` to preload shader.
https://docs.unity3d.com/Manual/OptimizingShaderLoadTime.html
* Set camera's clear flag to "Solid Color".
* Enable multi thread rendering.
<br><br><br><br>
## Release Notes
### ver.2.0.0
* Feature: Switch separate/combine materials by script symbol "UIEFFECT_SEPARATE".
* Combined mode (default)
* The effect materials are sub-asset, and will be hidden in project view & object picker window.
* Unused shader variants and materials will be excluded from build, but they will be **included in AssetBundle.**
![comb](https://user-images.githubusercontent.com/12690315/35324040-df4f1684-0132-11e8-9534-f958b93de158.png)
* Separated mode
* Use script define symbol `UIEFFECT_SEPARATE`.
* The effect materials are main-asset, and will be displayed in project view & object picker window.
* In Editor, the effect materials are generated as asset, on demand.
* Unused shader variants and materials will be excluded from build and AssetBundle.
* We recommend this mode only if you include prefabs / scenes containing UIEffect in AssetBundle.
![sep](https://user-images.githubusercontent.com/12690315/35324405-fd5e89a6-0133-11e8-9d23-71ccc424fa21.png)
* Changed: Default is "Combined mode".
* Changed: Change namespace to `Coffee.UIExtensions`.
* Changed: Unity 5.3.x & 5.4.x are no longer supported.
### ver.1.6.1
* Fixed: Cannot access protected member `UnityEngine.UI.BaseMeshEffect.graphic` in Unity5.6+.
### ver.1.6.0
* Changed: UIEffect inherit BaseMeshEffect.
* Fixed: Pixelization is incorrect.
* Changed: ShadowMode -> ShadowStyle.
* Changed: Blur level is range [0-1].
### ver.1.5.1
* Fixed: An error occurs when no effect is specified for UICapturedImage. [#36](https://github.com/mob-sakai/UIEffect/issues/36)
### ver.1.5.0
* Feature: Add ToneMode `Hue Shift`.
![image](https://user-images.githubusercontent.com/12690315/34830409-18114e44-f727-11e7-849a-0d61a35f03ea.png)
* Feature: Add ShadowMode `Shadow3`.
![image](https://user-images.githubusercontent.com/12690315/34930812-cb87dc24-fa0e-11e7-90a7-0013e2ba55d1.png)
* Feature: Add `UIGradient` component to change vertex color as gradient.
* Gradient direction
* Horizontal
* Vertical
* Angle
* Diagonal
* Rotation and offset
* Text gradient style
* Rect
* Fit
* Split
* Color space
* Uninitialized
* Gammma
* Linear
* Ignore aspect ratio
![image](https://user-images.githubusercontent.com/12690315/34930676-000c41d4-fa0e-11e7-825b-d5a1e757fea8.png)
### ver.1.4.4
* Fixed: Error has occur on edit prefab. [#27](https://github.com/mob-sakai/UIEffect/issues/27)
### ver.1.4.3
* Fixed: Color effect is incorrect. [#19](https://github.com/mob-sakai/UIEffect/issues/19)
### ver.1.4.2
* Fixed: Error has occur on after deserialize. [#16](https://github.com/mob-sakai/UIEffect/issues/16)
### ver.1.4.1
* Fixed: Demo link in `readme.md` is broken.
### ver.1.4.0
* Changed: ToneMode, ColorMode, BlurMode can be changed only in editor.
* Changed: Cutoff's level is reversed.
* Feature: Exclude unused shader variant from build.
* Add: Add many materials for shader variant, but exclude unused materials from build.
Build report of demo project is as following.
| | ver.1.3.0 | ver.1.4.0 |
|--|-----------|-----------|
| UI-Effect.shader | All 112 variants, 170.7 kb | 21 variants, 31.4 kb |
| UI-EffectCapturedImage.shader | All 80 variants, 49.0 kb | 2 variants, 7.3 kb |
| Materials in build | Instantiate on play, 0 kb | 23 items, about 6.9 kb |
| Total | 219.7 kb | 45.6 kb |
### ver.1.3.0
* Feature: Capture image with effect, like post effect.
* Demo: Add transition blur button & dialog with captured image effect.
![image](https://user-images.githubusercontent.com/12690315/34619468-97e3c134-f285-11e7-90b2-3a75bde13911.gif)
### ver.1.2.0
* Fixed : Pixelaration shifts to the lower right.
* Fixed : Cutoff alpha is incorrect.
* Feature: Supports multiple shadow effect for reduce rendering vertices.
![image](https://user-images.githubusercontent.com/12690315/34552373-600fdab2-f164-11e7-8565-21c15af92a93.png)
* Feature: New blur effect mode : `Medium`.
* Feature: Fix button to enable TexCoord1 of Canvas.additionalShaderChannels to use UIEffect.
![image](https://user-images.githubusercontent.com/12690315/34560894-191b6cda-f18b-11e7-9de2-9a9d13f72ccd.png)
* Changed : UIEffect.color is obsolete, use UIEffect.effectColor instead.
* Changed: Blur range is [0-2].
* Refactoring: Shader refactoring.
* Demo: Add transition button & multiple shadows.
### ver.1.1.0
* Feature: Add Pixelaration effect.
* Feature: Add Cutoff/Mono effect for patterned alpha images. It can be used for masks and transitions!
![image](https://user-images.githubusercontent.com/12690315/34618554-71a32e40-f282-11e7-8b78-6948c50c6b58.gif)
### ver.1.0.0
* Feature: Shader supports pre-processer macros (for example UNITY_VERTEX_OUTPUT_STEREO) for Unity 5.3.x, 5.4.x and 5.5.x.
* Feature: Supports changing value from animation.
* Feature: Supports Tone effect.
* grayscale
* sepia
* nega
* Feature: Supports Color effect.
* set
* add
* sub
* Feature: Supports Blur effect.
* fast
* detail
* Fix: Color effect will not be properly when it was rotated.
* Performance: Shader supports multi-compile for performance.
* Performance: Cache same effect materials to reduce draw calls.
* Improve: Supports mobile devices.
* Improve: Simplify component & inspector.
<br><br><br><br>
## License
* MIT
* © UTJ/UCL
## Author
[mob-sakai](https://github.com/mob-sakai)
## See Also
* GitHub Page : https://github.com/mob-sakai/UIEffect
* Releases : https://github.com/mob-sakai/UIEffect/releases
* Issue tracker : https://github.com/mob-sakai/UIEffect/issues
* Current Project : https://github.com/mob-sakai/UIEffect/projects/1
Binary file not shown.
+10
View File
@@ -0,0 +1,10 @@
{
"name": "UIEffect",
"version": "2.2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/mob-sakai/UIEffect.git"
},
"src": "Assets/UIEffect",
"license": "MIT"
}
Executable
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash -e
# Release the project with the following steps:
# 1. Update the release version in package.json.
# 2. Update "CHANGELOG.md" using "github_changelog_generator-1.15.0.pre.rc".
# 3. Commit package.json and CHANGELOG.md.
# 4. Merge into master branch.
# 5. Export unitypackage.
# 6. Release using "gh-release-3.2.0". (Upload unitypackage)
UNITY_PATH=/Applications/Unity5.5.0p4/Unity5.5.0p4.app/Contents/MacOS/Unity
# input version
PACKAGE_NAME=`node -pe 'require("./package.json").name'`
echo Github Release: $PACKAGE_NAME
read -p "[? release version (for example: 1.0.0): " RELEASE_VERSION
[ -z "$RELEASE_VERSION" ] && exit
# update version
git checkout -B release develop
sed -i -e "s/\"version\": \(.*\)/\"version\": \"${RELEASE_VERSION}\",/g" package.json
# generate change log
TAG=v$RELEASE_VERSION
git tag $TAG
git push --tags
github_changelog_generator -t $GITHUB_TOKEN
git tag -d $TAG
git push --delete origin $TAG
git diff -- CHANGELOG.md
read -p "[? continue? (y/N):" yn
case "$yn" in [yY]*) ;; *) exit ;; esac
# commit files
git add CHANGELOG.md -f
git add package.json -f
git commit -m "update change log"
# merge and push
git checkout master
git merge --no-ff release -m "release $TAG"
git branch -D release
git push origin master
# export .unitypackage and release on Github
PACKAGE_SRC=`node -pe 'require("./package.json").src'`
$UNITY_PATH -quit -batchmode -projectPath "`pwd`" -exportpackage $PACKAGE_SRC $PACKAGE_NAME.unitypackage
gh-release --draft --assets $PACKAGE_NAME.unitypackage
echo "\n\n$PACKAGE_NAME v$RELEASE_VERSION has been successfully released!\n"