feat: completely redesigned UIEffect architecture

BREAKING CHANGE: All v4 components are obsolete. See README to upgrade.
This commit is contained in:
mob-sakai
2024-11-09 18:44:43 +09:00
committed by mob-sakai
parent 0424295dfc
commit 4e069a45d9
23 changed files with 3016 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9771c52489373469f83fc4c794026764
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,30 @@
{
"name": "Coffee.UIEffect.Editor",
"rootNamespace": "",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:735c8f008d0ad4caa9cdc4306f1c3042"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": false,
"defineConstraints": [],
"versionDefines": [
{
"name": "com.unity.textmeshpro",
"expression": "1.0.0",
"define": "TMP_ENABLE"
},
{
"name": "com.unity.ugui",
"expression": "2.0.0",
"define": "TMP_ENABLE"
}
],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4a03bd468489b4da08c028255886b30d
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+319
View File
@@ -0,0 +1,319 @@
using UnityEditor;
using UnityEngine;
using System.Linq;
using System;
using Object = UnityEngine.Object;
#if TMP_ENABLE
using TMPro;
#endif
namespace Coffee.UIEffects.Editors
{
/// <summary>
/// UIEffect editor.
/// </summary>
[CustomEditor(typeof(UIEffect), true)]
[CanEditMultipleObjects]
public class UIEffect2Editor : Editor
{
private SerializedProperty _toneFilter;
private SerializedProperty _toneIntensity;
private SerializedProperty _colorFilter;
private SerializedProperty _color;
private SerializedProperty _colorIntensity;
private SerializedProperty _samplingFilter;
private SerializedProperty _samplingIntensity;
private SerializedProperty _transitionFilter;
private SerializedProperty _transitionRate;
private SerializedProperty _transitionTex;
private SerializedProperty _transitionTexScale;
private SerializedProperty _transitionTexOffset;
private SerializedProperty _transitionReverse;
private SerializedProperty _transitionRotation;
private SerializedProperty _transitionKeepAspectRatio;
private SerializedProperty _transitionWidth;
private SerializedProperty _transitionSoftness;
private SerializedProperty _transitionColorFilter;
private SerializedProperty _transitionColor;
private SerializedProperty _targetMode;
private SerializedProperty _targetColor;
private SerializedProperty _targetRange;
private SerializedProperty _targetSoftness;
private SerializedProperty _blendType;
private SerializedProperty _srcBlendMode;
private SerializedProperty _dstBlendMode;
private SerializedProperty _shadowMode;
private SerializedProperty _shadowDistance;
private SerializedProperty _shadowDistanceX;
private SerializedProperty _shadowDistanceY;
private SerializedProperty _shadowIteration;
private SerializedProperty _shadowFade;
private SerializedProperty _shadowEffectOnOrigin;
private SerializedProperty _shadowMirrorScale;
private void OnEnable()
{
if (target == null) return;
_toneFilter = serializedObject.FindProperty("m_ToneFilter");
_toneIntensity = serializedObject.FindProperty("m_ToneIntensity");
var toneParams = serializedObject.FindProperty("m_ToneParams");
_colorFilter = serializedObject.FindProperty("m_ColorFilter");
_color = serializedObject.FindProperty("m_Color");
_colorIntensity = serializedObject.FindProperty("m_ColorIntensity");
_samplingFilter = serializedObject.FindProperty("m_SamplingFilter");
_samplingIntensity = serializedObject.FindProperty("m_SamplingIntensity");
_transitionFilter = serializedObject.FindProperty("m_TransitionFilter");
_transitionRate = serializedObject.FindProperty("m_TransitionRate");
_transitionTex = serializedObject.FindProperty("m_TransitionTex");
_transitionTexScale = serializedObject.FindProperty("m_TransitionTexScale");
_transitionTexOffset = serializedObject.FindProperty("m_TransitionTexOffset");
_transitionReverse = serializedObject.FindProperty("m_TransitionReverse");
_transitionRotation = serializedObject.FindProperty("m_TransitionRotation");
_transitionKeepAspectRatio = serializedObject.FindProperty("m_TransitionKeepAspectRatio");
_transitionWidth = serializedObject.FindProperty("m_TransitionWidth");
_transitionSoftness = serializedObject.FindProperty("m_TransitionSoftness");
_transitionColorFilter = serializedObject.FindProperty("m_TransitionColorFilter");
_transitionColor = serializedObject.FindProperty("m_TransitionColor");
_targetMode = serializedObject.FindProperty("m_TargetMode");
_targetColor = serializedObject.FindProperty("m_TargetColor");
_targetRange = serializedObject.FindProperty("m_TargetRange");
_targetSoftness = serializedObject.FindProperty("m_TargetSoftness");
_blendType = serializedObject.FindProperty("m_BlendType");
_srcBlendMode = serializedObject.FindProperty("m_SrcBlendMode");
_dstBlendMode = serializedObject.FindProperty("m_DstBlendMode");
_shadowMode = serializedObject.FindProperty("m_ShadowMode");
_shadowDistance = serializedObject.FindProperty("m_ShadowDistance");
_shadowDistanceX = _shadowDistance.FindPropertyRelative("x");
_shadowDistanceY = _shadowDistance.FindPropertyRelative("y");
_shadowIteration = serializedObject.FindProperty("m_ShadowIteration");
_shadowFade = serializedObject.FindProperty("m_ShadowFade");
_shadowEffectOnOrigin = serializedObject.FindProperty("m_ShadowEffectOnOrigin");
_shadowMirrorScale = serializedObject.FindProperty("m_ShadowMirrorScale");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
DrawPresetMenu(targets);
DrawSeparator();
DrawProperties();
serializedObject.ApplyModifiedProperties();
}
public void DrawProperties()
{
serializedObject.Update();
// Tone filter
if (DrawHeaderPopup(_toneFilter))
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_toneIntensity);
EditorGUI.indentLevel--;
}
// Color filter
DrawSeparator();
var prevColorFilter = (ColorFilter)_colorFilter.intValue;
if (DrawHeaderPopup(_colorFilter))
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_colorIntensity);
DrawColor(_colorFilter, _color, prevColorFilter);
EditorGUI.indentLevel--;
}
EditorGUI.EndChangeCheck();
// Sampling filter
DrawSeparator();
if (DrawHeaderPopup(_samplingFilter))
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_samplingIntensity);
EditorGUI.indentLevel--;
}
// Transition filter
DrawSeparator();
if (DrawHeaderPopup(_transitionFilter))
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_transitionRate);
EditorGUILayout.PropertyField(_transitionTex);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_transitionTexScale, EditorGUIUtility.TrTempContent("Scale"));
EditorGUILayout.PropertyField(_transitionTexOffset, EditorGUIUtility.TrTempContent("Offset"));
EditorGUILayout.PropertyField(_transitionRotation, EditorGUIUtility.TrTempContent("Rotation"));
EditorGUILayout.PropertyField(_transitionKeepAspectRatio,
EditorGUIUtility.TrTempContent("Keep Aspect Ratio"));
EditorGUILayout.PropertyField(_transitionReverse, EditorGUIUtility.TrTempContent("Reverse"));
EditorGUI.indentLevel--;
if (2 < _transitionFilter.intValue)
{
EditorGUILayout.PropertyField(_transitionWidth);
EditorGUILayout.PropertyField(_transitionSoftness);
prevColorFilter = (ColorFilter)_transitionColorFilter.intValue;
EditorGUILayout.PropertyField(_transitionColorFilter);
DrawColor(_transitionColorFilter, _transitionColor, prevColorFilter);
}
EditorGUI.indentLevel--;
}
// Target
DrawSeparator();
if (DrawHeaderPopup(_targetMode))
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_targetColor);
EditorGUILayout.PropertyField(_targetRange);
EditorGUILayout.PropertyField(_targetSoftness);
EditorGUI.indentLevel--;
}
// Blending
DrawSeparator();
if (!DrawHeaderPopup(_blendType))
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_srcBlendMode);
EditorGUILayout.PropertyField(_dstBlendMode);
EditorGUI.indentLevel--;
}
// Shadow
DrawSeparator();
var prevShadowMode = (ShadowMode)_shadowMode.intValue;
if (DrawHeaderPopup(_shadowMode))
{
EditorGUI.indentLevel++;
if ((ShadowMode)_shadowMode.intValue == ShadowMode.Mirror)
{
if (prevShadowMode != ShadowMode.Mirror)
{
_shadowDistanceX.floatValue = 0.5f;
_shadowDistanceY.floatValue = 0f;
}
EditorGUILayout.Slider(_shadowDistanceX, 0, 1, "Reflection");
EditorGUILayout.PropertyField(_shadowDistanceY, EditorGUIUtility.TrTempContent("Offset"));
EditorGUILayout.PropertyField(_shadowMirrorScale);
}
else
{
if (prevShadowMode == ShadowMode.Mirror)
{
_shadowDistanceX.floatValue = 1f;
_shadowDistanceY.floatValue = -1f;
}
EditorGUILayout.PropertyField(_shadowDistance);
EditorGUILayout.PropertyField(_shadowIteration);
}
EditorGUILayout.PropertyField(_shadowFade);
EditorGUILayout.PropertyField(_shadowEffectOnOrigin);
EditorGUI.indentLevel--;
}
}
private static void DrawColor(SerializedProperty filter, SerializedProperty color, ColorFilter prevFilter)
{
if (filter.intValue == (int)ColorFilter.None)
{
}
else if (filter.intValue == (int)ColorFilter.HsvModifier)
{
if (prevFilter != ColorFilter.HsvModifier)
{
color.colorValue = Color.black;
}
EditorGUILayout.Slider(color.FindPropertyRelative("r"), -0.5f, 0.5f, "Hue");
EditorGUILayout.Slider(color.FindPropertyRelative("g"), -1f, 1f, "Saturation");
EditorGUILayout.Slider(color.FindPropertyRelative("b"), -1f, 1f, "Value");
EditorGUILayout.Slider(color.FindPropertyRelative("a"), 0, 1, "Alpha");
}
else if (filter.intValue == (int)ColorFilter.Contrast)
{
if (prevFilter != ColorFilter.Contrast)
{
color.colorValue = Color.black;
}
EditorGUILayout.Slider(color.FindPropertyRelative("r"), -1f, 1f, "Contrast");
EditorGUILayout.Slider(color.FindPropertyRelative("g"), -1f, 1f, "Brightness");
EditorGUILayout.Slider(color.FindPropertyRelative("a"), 0, 1, "Alpha");
}
else
{
if (prevFilter == ColorFilter.HsvModifier || prevFilter == ColorFilter.Contrast)
{
color.colorValue = Color.white;
}
EditorGUILayout.PropertyField(color);
}
}
private static bool DrawHeaderPopup(SerializedProperty sp)
{
var r = EditorGUILayout.GetControlRect();
var pos = EditorGUI.PrefixLabel(r, EditorGUIUtility.TrTempContent(sp.displayName), EditorStyles.boldLabel);
EditorGUI.PropertyField(pos, sp, GUIContent.none);
return 0 < sp.intValue;
}
private static void DrawSeparator()
{
EditorGUILayout.Space(4);
GUILayout.Label(GUIContent.none, "sv_iconselector_sep", GUILayout.ExpandWidth(true));
}
private static void DrawPresetMenu(Object[] targets)
{
var r = EditorGUILayout.GetControlRect();
r.width /= 2;
if (GUI.Button(r, EditorGUIUtility.TrTempContent("Load"), "MiniPopup"))
{
var menu = new GenericMenu();
foreach (var preset in UIEffectProjectSettings.LoadEditorPresets())
{
var path = UIEffectProjectSettings.GetPresetPath(preset);
menu.AddItem(new GUIContent(path), false, () =>
{
Array.ForEach(targets.OfType<UIEffect>().ToArray(), t =>
{
t.LoadPreset(preset);
});
});
}
menu.DropDown(r);
}
r.x += r.width;
if (GUI.Button(r, EditorGUIUtility.TrTempContent("Save As New"), "MiniButton"))
{
UIEffectProjectSettings.SaveAsNewPreset(targets.OfType<UIEffect>().FirstOrDefault());
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5d33be88508194850bb6de86b1fbe19c
timeCreated: 1487152293
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 799912d824bbb4fcbb9228f721870ae8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,27 @@
{
"name": "Coffee.UIEffect",
"rootNamespace": "",
"references": [
"GUID:6055be8ebefd69e48b49212b09b47b2f"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [
{
"name": "com.unity.textmeshpro",
"expression": "1.0.0",
"define": "TMP_ENABLE"
},
{
"name": "com.unity.ugui",
"expression": "2.0.0",
"define": "TMP_ENABLE"
}
],
"noEngineReferences": false
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 735c8f008d0ad4caa9cdc4306f1c3042
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+107
View File
@@ -0,0 +1,107 @@
using UnityEngine.Rendering;
namespace Coffee.UIEffects
{
public enum ToneFilter
{
None = 0,
Grayscale = 1,
Sepia = 2,
Negative = 3,
Retro = 4,
Posterize = 5
}
public enum ColorFilter
{
None = 0,
Multiply = 1,
Additive = 2,
Subtractive = 3,
Replace = 4,
MultiplyLuminance = 5,
MultiplyAdditive = 6,
HsvModifier = 7,
Contrast = 8
}
public enum SamplingFilter
{
None = 0,
BlurFast = 1,
BlurMedium = 2,
BlurDetail = 3,
Pixelation = 4,
RgbShift = 5,
EdgeLuminance = 6,
EdgeAlpha = 7
}
public enum TransitionFilter
{
None = 0,
Fade = 1,
Cutoff = 2,
Dissolve = 3,
Shiny = 4,
Mask = 5,
Melt = 6,
Burn = 7
}
public enum BlendType
{
Custom,
AlphaBlend,
Multiply,
Additive,
SoftAdditive,
MultiplyAdditive
}
public enum TargetMode
{
None = 0,
Hue = 1,
Luminance = 2
}
public enum ShadowMode
{
None = 0,
Shadow,
Shadow3,
Outline,
Outline8,
Mirror
}
internal static class BlendTypeConverter
{
public static (BlendMode, BlendMode) Convert(this (BlendType type, BlendMode src, BlendMode dst) self)
{
return self.type switch
{
BlendType.AlphaBlend => (BlendMode.One, BlendMode.OneMinusSrcAlpha),
BlendType.Multiply => (BlendMode.DstColor, BlendMode.OneMinusSrcAlpha),
BlendType.Additive => (BlendMode.One, BlendMode.One),
BlendType.SoftAdditive => (BlendMode.OneMinusDstColor, BlendMode.One),
BlendType.MultiplyAdditive => (BlendMode.DstColor, BlendMode.One),
_ => (self.src, self.dst)
};
}
public static BlendType Convert(this (BlendMode src, BlendMode dst) self)
{
return self switch
{
(BlendMode.One, BlendMode.OneMinusSrcAlpha) => BlendType.AlphaBlend,
(BlendMode.DstColor, BlendMode.OneMinusSrcAlpha) => BlendType.Multiply,
(BlendMode.One, BlendMode.One) => BlendType.Additive,
(BlendMode.OneMinusDstColor, BlendMode.One) => BlendType.SoftAdditive,
(BlendMode.DstColor, BlendMode.One) => BlendType.MultiplyAdditive,
_ => BlendType.Custom
};
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7618fbe72150241a98a3bef3c8410c2f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+737
View File
@@ -0,0 +1,737 @@
using System.Collections.Generic;
using Coffee.UIEffectInternal;
using UnityEngine;
using UnityEngine.Rendering;
namespace Coffee.UIEffects
{
[ExecuteAlways]
[DisallowMultipleComponent]
public class UIEffect : UIEffectBase
{
[SerializeField]
protected ToneFilter m_ToneFilter = ToneFilter.None;
[Range(0, 1)]
[SerializeField]
protected float m_ToneIntensity = 1;
[SerializeField]
protected Vector4 m_ToneParams = new Vector4(0, 0, 0, 0);
[SerializeField]
protected ColorFilter m_ColorFilter = ColorFilter.None;
[Range(0, 1)]
[SerializeField]
protected float m_ColorIntensity = 1;
[ColorUsage(false, true)]
[SerializeField]
protected Color m_Color = Color.white;
[SerializeField]
protected SamplingFilter m_SamplingFilter = SamplingFilter.None;
[Range(0, 1)]
[SerializeField]
protected float m_SamplingIntensity = 0.5f;
[SerializeField]
protected TransitionFilter m_TransitionFilter = TransitionFilter.None;
[Range(0, 1)]
[SerializeField]
protected float m_TransitionRate = 0.5f;
[SerializeField]
protected bool m_TransitionReverse;
[SerializeField]
protected Texture m_TransitionTex;
[SerializeField]
protected Vector2 m_TransitionTexScale = new Vector2(1, 1);
[SerializeField]
protected Vector2 m_TransitionTexOffset = new Vector2(0, 0);
[SerializeField]
[Range(0, 360)]
private float m_TransitionRotation = 0;
[SerializeField]
protected bool m_TransitionKeepAspectRatio = true;
[Range(0, 1)]
[SerializeField]
protected float m_TransitionWidth = 0.2f;
[Range(0, 1)]
[SerializeField]
protected float m_TransitionSoftness = 0.2f;
[SerializeField]
protected ColorFilter m_TransitionColorFilter = ColorFilter.MultiplyAdditive;
[ColorUsage(true, true)]
[SerializeField]
protected Color m_TransitionColor = new Color(0f, 0.5f, 1.0f, 1.0f);
[SerializeField]
protected TargetMode m_TargetMode = TargetMode.None;
[ColorUsage(false, false)]
[SerializeField]
protected Color m_TargetColor = Color.white;
[Range(0, 1)]
[SerializeField]
protected float m_TargetRange = 0.1f;
[Range(0, 1)]
[SerializeField]
protected float m_TargetSoftness = 0.5f;
[SerializeField]
protected BlendType m_BlendType = BlendType.AlphaBlend;
[SerializeField]
protected BlendMode m_SrcBlendMode = BlendMode.One;
[SerializeField]
protected BlendMode m_DstBlendMode = BlendMode.OneMinusSrcAlpha;
[SerializeField]
protected ShadowMode m_ShadowMode = ShadowMode.None;
[SerializeField]
protected Vector2 m_ShadowDistance = new Vector2(1f, -1f);
[Range(1, 5)]
[SerializeField]
protected int m_ShadowIteration = 1;
[Range(0, 1)]
[SerializeField]
protected float m_ShadowFade = 0.9f;
[SerializeField]
protected bool m_ShadowEffectOnOrigin = false;
[Range(0, 2)]
[SerializeField]
protected float m_ShadowMirrorScale = 0.5f;
public ToneFilter toneFilter
{
get => m_ToneFilter;
set
{
if (m_ToneFilter == value) return;
context.toneFilter = m_ToneFilter = value;
ApplyContextToMaterial();
}
}
public float toneIntensity
{
get => m_ToneIntensity;
set
{
value = Mathf.Clamp(value, 0, 1);
if (Mathf.Approximately(m_ToneIntensity, value)) return;
context.toneIntensity = m_ToneIntensity = value;
ApplyContextToMaterial();
}
}
public ColorFilter colorFilter
{
get => m_ColorFilter;
set
{
if (m_ColorFilter == value) return;
context.colorFilter = m_ColorFilter = value;
ApplyContextToMaterial();
}
}
public float colorIntensity
{
get => m_ColorIntensity;
set
{
value = Mathf.Clamp(value, 0, 1);
if (Mathf.Approximately(m_ColorIntensity, value)) return;
context.colorIntensity = m_ColorIntensity = value;
ApplyContextToMaterial();
}
}
public Color color
{
get => m_Color;
set
{
m_Color.a = 1;
if (m_Color == value) return;
context.color = m_Color = value;
ApplyContextToMaterial();
}
}
public SamplingFilter samplingFilter
{
get => m_SamplingFilter;
set
{
if (m_SamplingFilter == value) return;
context.samplingFilter = m_SamplingFilter = value;
SetVerticesDirty();
ApplyContextToMaterial();
}
}
public float samplingIntensity
{
get => m_SamplingIntensity;
set
{
value = Mathf.Clamp(value, 0, 1);
if (Mathf.Approximately(m_SamplingIntensity, value)) return;
context.samplingIntensity = m_SamplingIntensity = value;
ApplyContextToMaterial();
}
}
public TransitionFilter transitionFilter
{
get => m_TransitionFilter;
set
{
if (m_TransitionFilter == value) return;
context.transitionFilter = m_TransitionFilter = value;
SetVerticesDirty();
ApplyContextToMaterial();
}
}
public float transitionRate
{
get => m_TransitionRate;
set
{
value = Mathf.Clamp(value, 0, 1);
if (Mathf.Approximately(m_TransitionRate, value)) return;
context.transitionRate = m_TransitionRate = value;
ApplyContextToMaterial();
}
}
public bool transitionReverse
{
get => m_TransitionReverse;
set
{
if (m_TransitionReverse == value) return;
context.transitionReverse = m_TransitionReverse = value;
ApplyContextToMaterial();
}
}
public Texture transitionTexture
{
get => m_TransitionTex;
set
{
if (m_TransitionTex == value) return;
context.transitionTex = m_TransitionTex = value;
ApplyContextToMaterial();
}
}
public Vector2 transitionTextureScale
{
get => m_TransitionTexScale;
set
{
if (m_TransitionTexScale == value) return;
context.transitionTexScale = m_TransitionTexScale = value;
ApplyContextToMaterial();
}
}
public Vector2 transitionTextureOffset
{
get => m_TransitionTexOffset;
set
{
if (m_TransitionTexOffset == value) return;
context.transitionTexOffset = m_TransitionTexOffset = value;
ApplyContextToMaterial();
}
}
public float transitionRotation
{
get => m_TransitionRotation;
set
{
if (Mathf.Approximately(m_TransitionRotation, value)) return;
context.transitionRotation = m_TransitionRotation = value;
SetVerticesDirty();
}
}
public bool transitionKeepAspectRatio
{
get => m_TransitionKeepAspectRatio;
set
{
if (m_TransitionKeepAspectRatio == value) return;
context.transitionKeepAspectRatio = m_TransitionKeepAspectRatio = value;
SetVerticesDirty();
}
}
public float transitionWidth
{
get => m_TransitionWidth;
set
{
value = Mathf.Clamp(value, 0, 1);
if (Mathf.Approximately(m_TransitionWidth, value)) return;
context.transitionWidth = m_TransitionWidth = value;
ApplyContextToMaterial();
}
}
public float transitionSoftness
{
get => m_TransitionSoftness;
set
{
value = Mathf.Clamp(value, 0, 1);
if (Mathf.Approximately(m_TransitionSoftness, value)) return;
context.transitionSoftness = m_TransitionSoftness = value;
ApplyContextToMaterial();
}
}
public ColorFilter transitionColorFilter
{
get => m_TransitionColorFilter;
set
{
if (m_TransitionColorFilter == value) return;
context.transitionColorFilter = m_TransitionColorFilter = value;
ApplyContextToMaterial();
}
}
public Color transitionColor
{
get => m_TransitionColor;
set
{
if (m_TransitionColor == value) return;
context.transitionColor = m_TransitionColor = value;
ApplyContextToMaterial();
}
}
public TargetMode targetMode
{
get => m_TargetMode;
set
{
if (m_TargetMode == value) return;
context.targetMode = m_TargetMode = value;
ApplyContextToMaterial();
}
}
public Color targetColor
{
get => m_TargetColor;
set
{
if (m_TargetColor == value) return;
context.targetColor = m_TargetColor = value;
ApplyContextToMaterial();
}
}
public float targetRange
{
get => m_TargetRange;
set
{
value = Mathf.Clamp(value, 0, 1);
if (Mathf.Approximately(m_TargetRange, value)) return;
context.targetRange = m_TargetRange = value;
ApplyContextToMaterial();
}
}
public float targetSoftness
{
get => m_TargetSoftness;
set
{
value = Mathf.Clamp(value, 0, 1);
if (Mathf.Approximately(m_TargetSoftness, value)) return;
context.targetSoftness = m_TargetSoftness = value;
ApplyContextToMaterial();
}
}
public BlendType blendType
{
get => m_BlendType;
set
{
if (m_BlendType == value) return;
(m_SrcBlendMode, m_DstBlendMode) = (m_BlendType, m_SrcBlendMode, m_DstBlendMode).Convert();
context.srcBlendMode = m_SrcBlendMode;
context.dstBlendMode = m_DstBlendMode;
ApplyContextToMaterial();
}
}
/// <summary>
/// Source blend type for rendering.
/// This is used when material is not set and blend type is custom.
/// </summary>
public BlendMode srcBlendMode
{
get => m_SrcBlendMode;
set
{
if (m_SrcBlendMode == value) return;
context.srcBlendMode = m_SrcBlendMode = value;
m_BlendType = (m_SrcBlendMode, m_DstBlendMode).Convert();
ApplyContextToMaterial();
}
}
/// <summary>
/// Destination blend type for rendering.
/// This is used when material is not set and blend type is custom.
/// </summary>
public BlendMode dstBlendMode
{
get => m_DstBlendMode;
set
{
if (m_DstBlendMode == value) return;
context.dstBlendMode = m_DstBlendMode = value;
m_BlendType = (m_SrcBlendMode, m_DstBlendMode).Convert();
ApplyContextToMaterial();
}
}
public ShadowMode shadowMode
{
get => m_ShadowMode;
set
{
if (m_ShadowMode == value) return;
context.shadowMode = m_ShadowMode = value;
SetVerticesDirty();
}
}
public Vector2 shadowDistance
{
get => m_ShadowDistance;
set
{
if (m_ShadowDistance == value) return;
context.shadowDistance = m_ShadowDistance = value;
SetVerticesDirty();
}
}
public float shadowFade
{
get => m_ShadowFade;
set
{
value = Mathf.Clamp01(value);
if (Mathf.Approximately(m_ShadowFade, value)) return;
context.shadowFade = m_ShadowFade = value;
SetVerticesDirty();
}
}
public int shadowIteration
{
get => m_ShadowIteration;
set
{
value = Mathf.Clamp(value, 1, 5);
if (m_ShadowIteration == value) return;
context.shadowIteration = m_ShadowIteration = value;
SetVerticesDirty();
}
}
public bool shadowEffectOnOrigin
{
get => m_ShadowEffectOnOrigin;
set
{
if (m_ShadowEffectOnOrigin == value) return;
m_ShadowEffectOnOrigin = value;
SetVerticesDirty();
}
}
public float shadowMirrorScale
{
get => m_ShadowMirrorScale;
set
{
value = Mathf.Clamp(value, 0f, 2f);
if (Mathf.Approximately(m_ShadowMirrorScale, value)) return;
m_ShadowMirrorScale = value;
SetVerticesDirty();
}
}
public List<UIEffectReplica> replicas => _replicas ??= ListPool<UIEffectReplica>.Rent();
private List<UIEffectReplica> _replicas;
protected override void OnEnable()
{
(m_SrcBlendMode, m_DstBlendMode) = (m_BlendType, m_SrcBlendMode, m_DstBlendMode).Convert();
base.OnEnable();
ApplyContextToMaterial();
}
protected override void OnDisable()
{
base.OnDisable();
ApplyContextToMaterial();
}
protected override void OnDestroy()
{
ListPool<UIEffectReplica>.Return(ref _replicas);
}
#if UNITY_EDITOR
protected override void OnValidate()
{
(m_SrcBlendMode, m_DstBlendMode) = (m_BlendType, m_SrcBlendMode, m_DstBlendMode).Convert();
base.OnValidate();
}
#endif
public override void SetVerticesDirty()
{
base.SetVerticesDirty();
replicas.ForEach(c =>
{
if (!c) return;
c.SetVerticesDirty();
});
}
public override void SetMaterialDirty()
{
base.SetMaterialDirty();
replicas.ForEach(c =>
{
if (!c) return;
c.SetMaterialDirty();
});
}
protected override void UpdateContext(UIEffectContext c)
{
c.toneFilter = m_ToneFilter;
c.toneIntensity = m_ToneIntensity;
c.toneParams = m_ToneParams;
c.colorFilter = m_ColorFilter;
c.color = m_Color;
c.colorIntensity = m_ColorIntensity;
c.samplingFilter = m_SamplingFilter;
c.samplingIntensity = m_SamplingIntensity;
c.transitionFilter = m_TransitionFilter;
c.transitionRate = m_TransitionRate;
c.transitionReverse = m_TransitionReverse;
c.transitionTex = m_TransitionTex;
c.transitionTexScale = m_TransitionTexScale;
c.transitionTexOffset = m_TransitionTexOffset;
c.transitionRotation = m_TransitionRotation;
c.transitionKeepAspectRatio = m_TransitionKeepAspectRatio;
c.transitionWidth = m_TransitionWidth;
c.transitionSoftness = m_TransitionSoftness;
c.transitionColor = m_TransitionColor;
c.transitionColorFilter = m_TransitionColorFilter;
c.targetMode = m_TargetMode;
c.targetColor = m_TargetColor;
c.targetRange = m_TargetRange;
c.targetSoftness = m_TargetSoftness;
c.srcBlendMode = m_SrcBlendMode;
c.dstBlendMode = m_DstBlendMode;
c.shadowMode = m_ShadowMode;
c.shadowDistance = m_ShadowDistance;
c.shadowIteration = m_ShadowIteration;
c.shadowFade = m_ShadowFade;
c.shadowEffectOnOrigin = m_ShadowEffectOnOrigin;
c.shadowMirrorScale = m_ShadowMirrorScale;
}
public override void ApplyContextToMaterial()
{
base.ApplyContextToMaterial();
replicas.ForEach(c =>
{
if (!c) return;
c.ApplyContextToMaterial();
});
}
public override void SetRate(float rate, UIEffectTweener.CullingMask mask)
{
if (toneFilter != ToneFilter.None && 0 < (mask & UIEffectTweener.CullingMask.Tone))
{
toneIntensity = rate;
}
if (colorFilter != ColorFilter.None && 0 < (mask & UIEffectTweener.CullingMask.Color))
{
colorIntensity = rate;
}
if (samplingFilter != SamplingFilter.None && 0 < (mask & UIEffectTweener.CullingMask.Sampling))
{
samplingIntensity = rate;
}
if (transitionFilter != TransitionFilter.None && 0 < (mask & UIEffectTweener.CullingMask.Transition))
{
transitionRate = rate;
}
}
public override bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera)
{
switch (transitionFilter)
{
case TransitionFilter.None:
case TransitionFilter.Shiny:
case TransitionFilter.Mask:
return true;
default:
return transitionRate < 1;
}
}
public void LoadPreset(string presetName)
{
LoadPreset(UIEffectProjectSettings.LoadRuntimePreset(presetName));
}
public void LoadPreset(UIEffect preset)
{
if (!preset) return;
m_ToneFilter = preset.m_ToneFilter;
m_ToneIntensity = preset.m_ToneIntensity;
m_ToneParams = preset.m_ToneParams;
m_ColorFilter = preset.m_ColorFilter;
m_Color = preset.m_Color;
m_ColorIntensity = preset.m_ColorIntensity;
m_SamplingFilter = preset.m_SamplingFilter;
m_SamplingIntensity = preset.m_SamplingIntensity;
m_TransitionFilter = preset.m_TransitionFilter;
m_TransitionRate = preset.m_TransitionRate;
m_TransitionReverse = preset.m_TransitionReverse;
m_TransitionTex = preset.m_TransitionTex;
m_TransitionTexScale = preset.m_TransitionTexScale;
m_TransitionTexOffset = preset.m_TransitionTexOffset;
m_TransitionRotation = preset.m_TransitionRotation;
m_TransitionKeepAspectRatio = preset.m_TransitionKeepAspectRatio;
m_TransitionWidth = preset.m_TransitionWidth;
m_TransitionSoftness = preset.m_TransitionSoftness;
m_TransitionColor = preset.m_TransitionColor;
m_TransitionColorFilter = preset.m_TransitionColorFilter;
m_TargetMode = preset.m_TargetMode;
m_TargetColor = preset.m_TargetColor;
m_TargetRange = preset.m_TargetRange;
m_TargetSoftness = preset.m_TargetSoftness;
m_BlendType = preset.m_BlendType;
(m_SrcBlendMode, m_DstBlendMode) = (m_BlendType, preset.m_SrcBlendMode, preset.m_DstBlendMode).Convert();
m_ShadowMode = preset.m_ShadowMode;
m_ShadowDistance = preset.m_ShadowDistance;
m_ShadowIteration = preset.m_ShadowIteration;
m_ShadowFade = preset.m_ShadowFade;
m_ShadowEffectOnOrigin = preset.m_ShadowEffectOnOrigin;
m_ShadowMirrorScale = preset.m_ShadowMirrorScale;
UpdateContext(context);
ApplyContextToMaterial();
SetVerticesDirty();
SetMaterialDirty();
}
internal void CopyFrom(UIEffectContext c)
{
m_ToneFilter = c.toneFilter;
m_ToneIntensity = c.toneIntensity;
m_ToneParams = c.toneParams;
m_ColorFilter = c.colorFilter;
m_Color = c.color;
m_ColorIntensity = c.colorIntensity;
m_SamplingFilter = c.samplingFilter;
m_SamplingIntensity = c.samplingIntensity;
m_TransitionFilter = c.transitionFilter;
m_TransitionRate = c.transitionRate;
m_TransitionReverse = c.transitionReverse;
m_TransitionTex = c.transitionTex;
m_TransitionTexScale = c.transitionTexScale;
m_TransitionTexOffset = c.transitionTexOffset;
m_TransitionRotation = c.transitionRotation;
m_TransitionKeepAspectRatio = c.transitionKeepAspectRatio;
m_TransitionWidth = c.transitionWidth;
m_TransitionSoftness = c.transitionSoftness;
m_TransitionColor = c.transitionColor;
m_TransitionColorFilter = c.transitionColorFilter;
m_TargetMode = c.targetMode;
m_TargetColor = c.targetColor;
m_TargetRange = c.targetRange;
m_TargetSoftness = c.targetSoftness;
m_SrcBlendMode = c.srcBlendMode;
m_DstBlendMode = c.dstBlendMode;
m_BlendType = (m_SrcBlendMode, m_DstBlendMode).Convert();
m_ShadowMode = c.shadowMode;
m_ShadowDistance = c.shadowDistance;
m_ShadowIteration = c.shadowIteration;
m_ShadowFade = c.shadowFade;
m_ShadowEffectOnOrigin = c.shadowEffectOnOrigin;
m_ShadowMirrorScale = c.shadowMirrorScale;
UpdateContext(context);
ApplyContextToMaterial();
SetVerticesDirty();
SetMaterialDirty();
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 938fce054c42f40a3969e27a88d9bdd8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 617344605838670728, guid: ba0cc6c34514c480c878314286014b4a, type: 2}
userData:
assetBundleName:
assetBundleVariant:
+344
View File
@@ -0,0 +1,344 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using Coffee.UIEffectInternal;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Profiling;
using UnityEngine.UI;
using UnityEditor;
#if TMP_ENABLE
using TMPro;
#endif
[assembly: InternalsVisibleTo("UIEffect")]
[assembly: InternalsVisibleTo("Coffee.UIEffect.Editor")]
namespace Coffee.UIEffects
{
[ExecuteAlways]
[DisallowMultipleComponent]
public abstract class UIEffectBase : UIBehaviour, IMeshModifier, IMaterialModifier, ICanvasRaycastFilter
{
private static readonly VertexHelper s_VertexHelper = new VertexHelper();
private static Mesh s_Mesh;
private static readonly Dictionary<int, string> s_ShaderNameCache = new Dictionary<int, string>();
private static readonly ObjectPool<UIEffectContext> s_ContextPool =
new ObjectPool<UIEffectContext>(() => new UIEffectContext(), x => true, x => x.Reset());
private Graphic _graphic;
private Material _material;
private UIEffectContext _context;
public Graphic graphic => _graphic ? _graphic : _graphic = GetComponent<Graphic>();
public virtual uint effectId => (uint)GetInstanceID();
public virtual UIEffectContext context
{
get
{
if (_context == null)
{
_context = s_ContextPool.Rent();
UpdateContext(_context);
}
return _context;
}
}
public virtual RectTransform transitionRoot => transform as RectTransform;
protected override void OnEnable()
{
UpdateContext(context);
SetMaterialDirty();
SetVerticesDirty();
}
protected override void OnDisable()
{
MaterialRepository.Release(ref _material);
SetMaterialDirty();
SetVerticesDirty();
}
protected override void OnDestroy()
{
s_ContextPool.Return(ref _context);
}
public void ModifyMesh(Mesh mesh)
{
}
public virtual void ModifyMesh(VertexHelper vh)
{
if (!isActiveAndEnabled || context == null) return;
context.ModifyMesh(graphic, transitionRoot, vh);
}
public virtual Material GetModifiedMaterial(Material baseMaterial)
{
if (baseMaterial == null || !isActiveAndEnabled || context == null || !context.willModifyMaterial)
{
MaterialRepository.Release(ref _material);
return baseMaterial;
}
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, 0, 0);
if (!MaterialRepository.Valid(hash, _material))
{
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial > Get or create material");
MaterialRepository.Get(hash, ref _material, x => new Material(x)
{
shader = FindShader(x),
hideFlags = HideFlags.HideAndDontSave
}, baseMaterial);
Profiler.EndSample();
}
ApplyContextToMaterial();
Profiler.EndSample();
return _material;
}
private static Shader FindShader(Material material)
{
var shader = material.shader;
var hash = shader.GetInstanceID();
if (!s_ShaderNameCache.TryGetValue(hash, out var shaderName))
{
shaderName = shader.name;
if (!shaderName.Contains("(UIEffect)"))
{
shaderName = $"Hidden/{shaderName} (UIEffect)";
}
var uiEffectShader = Shader.Find(shaderName);
if (!uiEffectShader)
{
shaderName = "Hidden/UI/Default (UIEffect)";
uiEffectShader = Shader.Find(shaderName);
}
s_ShaderNameCache[hash] = shaderName;
return uiEffectShader;
}
return Shader.Find(shaderName);
}
#if UNITY_EDITOR
protected override void OnValidate()
{
UpdateContext(context);
ApplyContextToMaterial();
SetVerticesDirty();
SetMaterialDirty();
if (!EditorApplication.isPlaying)
{
EditorApplication.QueuePlayerLoopUpdate();
}
}
protected override void Reset()
{
OnValidate();
}
#endif
protected override void OnRectTransformDimensionsChange()
{
if (!isActiveAndEnabled) return;
SetVerticesDirty();
}
protected override void OnDidApplyAnimationProperties()
{
UpdateContext(context);
ApplyContextToMaterial();
}
public virtual void SetVerticesDirty()
{
#if TMP_ENABLE
if (graphic is TextMeshProUGUI textMeshProUGUI && textMeshProUGUI.isActiveAndEnabled)
{
if (isActiveAndEnabled)
{
OnTMPChanged(textMeshProUGUI);
var canvas = graphic.canvas;
if (canvas && graphic.isActiveAndEnabled)
{
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord2;
}
}
else if (0 < textMeshProUGUI.textInfo?.meshInfo?.Length
&& 0 < textMeshProUGUI.textInfo.meshInfo[0].vertexCount)
{
textMeshProUGUI.UpdateVertexData();
}
}
else
#endif
if (graphic)
{
graphic.SetVerticesDirty();
var canvas = graphic.canvas;
if (canvas && graphic.isActiveAndEnabled)
{
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord1;
}
}
}
public virtual void SetMaterialDirty()
{
if (graphic)
{
graphic.SetMaterialDirty();
}
}
protected abstract void UpdateContext(UIEffectContext c);
public virtual void ApplyContextToMaterial()
{
if (!isActiveAndEnabled || context == null) return;
context.ApplyToMaterial(_material);
#if UNITY_EDITOR
UIEffectProjectSettings.RegisterVariant(_material);
if (!EditorApplication.isPlaying)
{
EditorApplication.QueuePlayerLoopUpdate();
}
#endif
}
#if TMP_ENABLE
#if UNITY_EDITOR
private class MyAllPostprocessor : AssetPostprocessor
{
private static void OnPostprocessAllAssets(string[] _, string[] __, string[] ___, string[] ____)
{
if (Application.isBatchMode || BuildPipeline.isBuildingPlayer) return;
s_ShaderNameCache.Clear();
#if UNITY_2021_3 || UNITY_2022_2_OR_NEWER
foreach (var effect in FindObjectsByType<UIEffectBase>(FindObjectsSortMode.None))
#else
foreach (var effect in FindObjectsOfType<UIEffectBase>())
#endif
{
if (!effect.isActiveAndEnabled) continue;
if (!(effect.graphic is TextMeshProUGUI tmp) || !tmp.isActiveAndEnabled) continue;
effect.SetMaterialDirty();
}
EditorApplication.QueuePlayerLoopUpdate();
}
}
#endif
#if UNITY_EDITOR
[InitializeOnLoadMethod]
#else
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
#endif
private static void InitializeOnLoad()
{
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(obj =>
{
if (obj is TextMeshProUGUI textMeshProUGUI)
{
OnTMPChanged(textMeshProUGUI);
}
});
}
private static void OnTMPChanged(TextMeshProUGUI textMeshProUGUI)
{
if (!textMeshProUGUI.TryGetComponent<UIEffectBase>(out var effect)) return;
if (!effect || !effect.isActiveAndEnabled) return;
if (!s_Mesh)
{
s_Mesh = new Mesh();
s_Mesh.MarkDynamic();
}
var target = effect is UIEffect uiEffect
? uiEffect
: effect is UIEffectReplica parentReplica
? parentReplica.target
: null;
var subMeshes = ListPool<TMP_SubMeshUI>.Rent();
var modifiers = ListPool<IMeshModifier>.Rent();
textMeshProUGUI.GetComponentsInChildren(subMeshes, 1);
for (var i = 0; i < textMeshProUGUI.textInfo.meshInfo.Length; i++)
{
var meshInfo = textMeshProUGUI.textInfo.meshInfo[i];
s_VertexHelper.Clear();
meshInfo.mesh.CopyTo(s_VertexHelper, meshInfo.vertexCount, meshInfo.vertexCount * 6 / 4);
if (i == 0)
{
textMeshProUGUI.GetComponents(modifiers);
foreach (var modifier in modifiers)
{
modifier.ModifyMesh(s_VertexHelper);
}
s_VertexHelper.FillMesh(s_Mesh);
textMeshProUGUI.canvasRenderer.SetMesh(s_Mesh);
}
else if (i - 1 < subMeshes.Count)
{
var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material);
if (!target || !subMeshUI) break;
var replica = subMeshUI.GetOrAddComponent<UIEffectReplica>();
replica.target = target;
subMeshUI.GetComponents(modifiers);
foreach (var modifier in modifiers)
{
modifier.ModifyMesh(s_VertexHelper);
}
s_VertexHelper.FillMesh(s_Mesh);
replica.ApplyContextToMaterial();
subMeshUI.canvasRenderer.SetMesh(s_Mesh);
}
else
{
break;
}
}
ListPool<IMeshModifier>.Return(ref modifiers);
ListPool<TMP_SubMeshUI>.Return(ref subMeshes);
s_Mesh.Clear(false);
}
private static TMP_SubMeshUI GetSubMeshUI(List<TMP_SubMeshUI> subMeshes, Material material)
{
for (var j = 0; j < subMeshes.Count; j++)
{
if (subMeshes[j].sharedMaterial == material) return subMeshes[j];
}
return null;
}
#endif
public abstract void SetRate(float rate, UIEffectTweener.CullingMask cullingMask);
public abstract bool IsRaycastLocationValid(Vector2 sp, Camera eventCamera);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 45155dfa7f0d3439aad2fcb51c8ffa18
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+681
View File
@@ -0,0 +1,681 @@
using System;
using System.Collections.Generic;
using Coffee.UIEffectInternal;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.Rendering;
using UnityEngine.UI;
#if TMP_ENABLE
using TMPro;
#endif
namespace Coffee.UIEffects
{
public class UIEffectContext
{
private const float k_MaxEffectDistance = 600f;
private static readonly UIEffectContext s_DefaultContext = new UIEffectContext();
private static readonly List<UIVertex> s_WorkingVertices = new List<UIVertex>();
private static readonly int s_SrcBlend = Shader.PropertyToID("_SrcBlend");
private static readonly int s_DstBlend = Shader.PropertyToID("_DstBlend");
private static readonly int s_ToneIntensity = Shader.PropertyToID("_ToneIntensity");
private static readonly int s_ToneParams = Shader.PropertyToID("_ToneParams");
private static readonly int s_ColorValue = Shader.PropertyToID("_ColorValue");
private static readonly int s_ColorIntensity = Shader.PropertyToID("_ColorIntensity");
private static readonly int s_SamplingIntensity = Shader.PropertyToID("_SamplingIntensity");
private static readonly int s_TransitionRate = Shader.PropertyToID("_TransitionRate");
private static readonly int s_TransitionReverse = Shader.PropertyToID("_TransitionReverse");
private static readonly int s_TransitionTex = Shader.PropertyToID("_TransitionTex");
private static readonly int s_TransitionTex_ST = Shader.PropertyToID("_TransitionTex_ST");
private static readonly int s_TransitionWidth = Shader.PropertyToID("_TransitionWidth");
private static readonly int s_TransitionSoftness = Shader.PropertyToID("_TransitionSoftness");
private static readonly int s_TransitionColor = Shader.PropertyToID("_TransitionColor");
private static readonly int s_TransitionColorFilter = Shader.PropertyToID("_TransitionColorFilter");
private static readonly int s_TargetColor = Shader.PropertyToID("_TargetColor");
private static readonly int s_TargetRange = Shader.PropertyToID("_TargetRange");
private static readonly int s_TargetSoftness = Shader.PropertyToID("_TargetSoftness");
private static readonly string[] s_ToneKeywords =
{
"",
"TONE_GRAYSCALE",
"TONE_SEPIA",
"TONE_NEGATIVE",
"TONE_RETRO",
"TONE_POSTERIZE"
};
private static readonly string[] s_ColorKeywords =
{
"",
"COLOR_MULTIPLY",
"COLOR_ADDITIVE",
"COLOR_SUBTRACTIVE",
"COLOR_REPLACE",
"COLOR_MULTIPLY_LUMINANCE",
"COLOR_MULTIPLY_ADDITIVE",
"COLOR_HSV_MODIFIER",
"COLOR_CONTRAST"
};
private static readonly string[] s_SamplingKeywords =
{
"",
"SAMPLING_BLUR_FAST",
"SAMPLING_BLUR_MEDIUM",
"SAMPLING_BLUR_DETAIL",
"SAMPLING_PIXELATION",
"SAMPLING_RGB_SHIFT",
"SAMPLING_EDGE_LUMINANCE",
"SAMPLING_EDGE_ALPHA"
};
private static readonly string[] s_TransitionKeywords =
{
"",
"TRANSITION_FADE",
"TRANSITION_CUTOFF",
"TRANSITION_DISSOLVE",
"TRANSITION_SHINY",
"TRANSITION_MASK",
"TRANSITION_MELT",
"TRANSITION_BURN"
};
private static readonly string[] s_TransitionColorKeywords =
{
"",
"TRANSITION_COLOR_MULTIPLY",
"TRANSITION_COLOR_ADDITIVE",
"TRANSITION_COLOR_SUBTRACTIVE",
"TRANSITION_COLOR_REPLACE",
"TRANSITION_COLOR_MULTIPLY_LUMINANCE",
"TRANSITION_COLOR_MULTIPLY_ADDITIVE",
"TRANSITION_COLOR_HSV_MODIFIER",
"TRANSITION_COLOR_CONTRAST"
};
private static readonly string[] s_TargetKeywords =
{
"",
"TARGET_HUE",
"TARGET_LUMINANCE"
};
public ToneFilter toneFilter = ToneFilter.None;
public float toneIntensity = 1;
public Vector4 toneParams = new Vector4(0, 0, 0, 0);
public ColorFilter colorFilter = ColorFilter.None;
public float colorIntensity = 1;
public Color color = Color.white;
public SamplingFilter samplingFilter = SamplingFilter.None;
public float samplingIntensity = 0.5f;
public TransitionFilter transitionFilter = TransitionFilter.None;
public float transitionRate = 0.5f;
public bool transitionReverse;
public Texture transitionTex;
public Vector2 transitionTexScale = new Vector2(1, 1);
public Vector2 transitionTexOffset = new Vector2(0, 0);
public float transitionRotation = 0;
public bool transitionKeepAspectRatio = true;
public float transitionWidth = 0.2f;
public float transitionSoftness = 0.2f;
public ColorFilter transitionColorFilter = ColorFilter.MultiplyAdditive;
public Color transitionColor = new Color(0f, 0.5f, 1.0f, 1.0f);
public TargetMode targetMode = TargetMode.None;
public Color targetColor = Color.white;
public float targetRange = 1;
public float targetSoftness = 0.5f;
public BlendMode srcBlendMode = BlendMode.One;
public BlendMode dstBlendMode = BlendMode.OneMinusSrcAlpha;
public ShadowMode shadowMode = ShadowMode.None;
public Vector2 shadowDistance = new Vector2(1f, -1f);
public int shadowIteration = 1;
public float shadowFade = 0.9f;
public bool shadowEffectOnOrigin = false;
public float shadowMirrorScale = 0.5f;
// public RectTransform transitionRoot;
public bool willModifyMaterial => samplingFilter != SamplingFilter.None
|| transitionFilter != TransitionFilter.None
|| toneFilter != ToneFilter.None
|| colorFilter != ColorFilter.None
|| srcBlendMode != BlendMode.One
|| dstBlendMode != BlendMode.OneMinusSrcAlpha;
public void Reset()
{
CopyFrom(s_DefaultContext);
}
public void CopyFrom(UIEffectContext preset)
{
toneFilter = preset.toneFilter;
toneIntensity = preset.toneIntensity;
toneParams = preset.toneParams;
colorFilter = preset.colorFilter;
color = preset.color;
colorIntensity = preset.colorIntensity;
samplingFilter = preset.samplingFilter;
samplingIntensity = preset.samplingIntensity;
transitionFilter = preset.transitionFilter;
transitionRate = preset.transitionRate;
transitionReverse = preset.transitionReverse;
transitionTex = preset.transitionTex;
transitionTexScale = preset.transitionTexScale;
transitionTexOffset = preset.transitionTexOffset;
transitionKeepAspectRatio = preset.transitionKeepAspectRatio;
transitionRotation = preset.transitionRotation;
transitionWidth = preset.transitionWidth;
transitionSoftness = preset.transitionSoftness;
transitionColor = preset.transitionColor;
transitionColorFilter = preset.transitionColorFilter;
targetMode = preset.targetMode;
targetColor = preset.targetColor;
targetRange = preset.targetRange;
targetSoftness = preset.targetSoftness;
srcBlendMode = preset.srcBlendMode;
dstBlendMode = preset.dstBlendMode;
shadowMode = preset.shadowMode;
shadowDistance = preset.shadowDistance;
shadowIteration = preset.shadowIteration;
shadowFade = preset.shadowFade;
shadowEffectOnOrigin = preset.shadowEffectOnOrigin;
}
public void ApplyToMaterial(Material material)
{
if (!material) return;
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
material.SetInt(s_SrcBlend, (int)srcBlendMode);
material.SetInt(s_DstBlend, (int)dstBlendMode);
material.SetFloat(s_ToneIntensity, Mathf.Clamp01(toneIntensity));
material.SetVector(s_ToneParams, toneParams);
material.SetColor(s_ColorValue, color);
material.SetFloat(s_ColorIntensity, Mathf.Clamp01(colorIntensity));
material.SetFloat(s_SamplingIntensity, Mathf.Clamp01(samplingIntensity));
material.SetFloat(s_TransitionRate, Mathf.Clamp01(transitionRate));
material.SetInt(s_TransitionReverse, transitionReverse ? 1 : 0);
material.SetTexture(s_TransitionTex, transitionTex);
material.SetVector(s_TransitionTex_ST,
new Vector4(transitionTexScale.x, transitionTexScale.y,
transitionTexOffset.x, transitionTexOffset.y));
material.SetFloat(s_TransitionWidth, Mathf.Clamp01(transitionWidth));
material.SetFloat(s_TransitionSoftness, Mathf.Clamp01(transitionSoftness));
material.SetColor(s_TransitionColor, transitionColor);
material.SetInt(s_TransitionColorFilter, (int)transitionColorFilter);
material.SetColor(s_TargetColor, targetColor);
material.SetFloat(s_TargetRange, Mathf.Clamp01(targetRange));
material.SetFloat(s_TargetSoftness, Mathf.Clamp01(targetSoftness));
SetKeyword(material, s_ToneKeywords, (int)toneFilter);
SetKeyword(material, s_ColorKeywords, (int)colorFilter);
SetKeyword(material, s_SamplingKeywords, (int)samplingFilter);
SetKeyword(material, s_TransitionKeywords, (int)transitionFilter);
switch (transitionFilter)
{
case TransitionFilter.None:
case TransitionFilter.Fade:
case TransitionFilter.Cutoff:
SetKeyword(material, s_TransitionColorKeywords, (int)ColorFilter.None);
break;
case TransitionFilter.Dissolve:
case TransitionFilter.Shiny:
case TransitionFilter.Mask:
case TransitionFilter.Melt:
case TransitionFilter.Burn:
SetKeyword(material, s_TransitionColorKeywords, (int)transitionColorFilter);
break;
}
SetKeyword(material, s_TargetKeywords, (int)targetMode);
Profiler.EndSample();
}
private static void SetKeyword(Material material, string[] keywords, int index)
{
for (var i = 0; i < keywords.Length; i++)
{
if (i != index)
{
material.DisableKeyword(keywords[i]);
}
else if (!string.IsNullOrEmpty(keywords[i]))
{
material.EnableKeyword(keywords[i]);
}
}
}
public void ModifyMesh(Graphic graphic, RectTransform transitionRoot, VertexHelper vh)
{
// var graphic = uiEffect.graphic;
// var transitionRoot = uiEffect.transitionRoot;
#if TMP_ENABLE
var isTextMeshPro = graphic is TextMeshProUGUI || graphic is TMP_SubMeshUI;
var isText = isTextMeshPro || graphic is Text;
// Sprite mode.
if (graphic is TMP_SubMeshUI sub && sub.spriteAsset && sub.sharedMaterial == sub.spriteAsset.material)
{
isTextMeshPro = false;
}
#else
var isTextMeshPro = false;
var isText = graphic is Text;
#endif
var expandSize = GetExpandSize();
var useExpand = expandSize != Vector2.zero;
// Update capacity of workingVertices if needed.
var count = vh.currentIndexCount;
var neededCapacity = Mathf.NextPowerOfTwo(count * GetVertexCountMultiply());
if (s_WorkingVertices.Capacity < neededCapacity)
{
s_WorkingVertices.Capacity = neededCapacity;
}
// Get the rectangle to calculate the normalized position.
vh.GetUIVertexStream(s_WorkingVertices);
var bundleSize = isText ? 6 : count;
var rot = Matrix4x4.Rotate(Quaternion.Euler(0, 0, transitionRotation));
var v1 = rot.MultiplyPoint3x4(new Vector3(1, 1, 0));
var multiplier = Mathf.Max(Mathf.Abs(v1.x), Mathf.Abs(v1.y));
Rect rect;
if (transitionRoot)
{
rect = transitionRoot.rect;
rot *= Matrix4x4.Scale(new Vector3(1 / multiplier, 1 / multiplier, 1))
* transitionRoot.worldToLocalMatrix
* graphic.rectTransform.localToWorldMatrix;
}
else
{
rect = graphic.rectTransform.rect;
rot *= Matrix4x4.Scale(new Vector3(multiplier, multiplier, 1));
}
if (transitionKeepAspectRatio && transitionTex)
{
var center = rect.center;
var aspectRatio = (float)transitionTex.width / transitionTex.height;
if (rect.width < rect.height)
{
rect.width = rect.height * aspectRatio;
}
else
{
rect.height = rect.width / aspectRatio;
}
rect.center = center;
}
// Modify vertices for each bundled-quad.
for (var i = 0; i < count; i += bundleSize)
{
// min/max for bundled-quad
GetBounds(s_WorkingVertices, i, bundleSize, out var bounds, out var uvMask);
// Quad (6 vertices)
for (var j = 0; j < bundleSize; j += 6)
{
var size = default(Vector3);
var extendPos = default(Vector3);
var extendUV = default(Vector3);
var posLB = s_WorkingVertices[i + j + 1].position;
var posRT = s_WorkingVertices[i + j + 4].position;
var willExpand = useExpand
&& (bundleSize == 6 // Text or simple quad
|| !bounds.Contains(posLB) ||
!bounds.Contains(posRT)); // Outer 9-sliced quad
if (willExpand)
{
var uvLB = s_WorkingVertices[i + j + 1].uv0;
var uvRT = s_WorkingVertices[i + j + 4].uv0;
var posCenter = (posLB + posRT) / 2;
var uvCenter = (uvLB + uvRT) / 2;
size = posLB - posRT;
size.x = 1 + expandSize.x / Mathf.Abs(size.x);
size.y = 1 + expandSize.y / Mathf.Abs(size.y);
size.z = 1;
extendPos = posCenter - Vector3.Scale(size, posCenter);
extendUV = uvCenter - Vector4.Scale(size, uvCenter);
}
// Set vertex position, uv, uvMask and local normalized position.
for (var k = 0; k < 6; k++)
{
var vt = s_WorkingVertices[i + j + k];
var pos = vt.position;
var uv0 = vt.uv0;
// Expand edge vertex
if (willExpand)
{
if (pos.x < bounds.xMin || bounds.xMax < pos.x)
{
pos.x = pos.x * size.x + extendPos.x;
uv0.x = uv0.x * size.x + extendUV.x;
}
if (pos.y < bounds.yMin || bounds.yMax < pos.y)
{
pos.y = pos.y * size.y + extendPos.y;
uv0.y = uv0.y * size.y + extendUV.y;
}
}
ModifyVertex(isTextMeshPro, ref vt, pos, uv0, uvMask, rect, rot);
s_WorkingVertices[i + j + k] = vt;
}
}
}
if (shadowMode != ShadowMode.None)
{
var start = 0;
var end = count;
if (shadowMode == ShadowMode.Mirror)
{
var rect2 = transitionRoot.rect;
var pivot = transitionRoot.pivot.y;
var height = rect2.height;
var rate = shadowDistance.x;
var scale = shadowMirrorScale;
var offset = shadowDistance.y - (scale + 1) * pivot * height;
var range = new Vector2(rect2.yMin, rect2.yMax);
ApplyMirror(s_WorkingVertices, count, rate, range, scale, offset, shadowFade);
}
else
{
var d = Vector2.zero;
var a = 1f;
var distance = new Vector2(Mathf.Clamp(shadowDistance.x, -k_MaxEffectDistance, k_MaxEffectDistance),
Mathf.Clamp(shadowDistance.y, -k_MaxEffectDistance, k_MaxEffectDistance));
for (var i = 0; i < shadowIteration; i++)
{
d += distance / (i + 1);
a *= shadowFade;
ApplyShadow(s_WorkingVertices, ref start, ref end, d, shadowMode, a);
}
}
// Mark as origin vertices.
if (!shadowEffectOnOrigin)
{
for (var i = s_WorkingVertices.Count - count; i < s_WorkingVertices.Count; i++)
{
var vt = s_WorkingVertices[i];
if (isTextMeshPro)
{
vt.uv1.z -= 8;
vt.uv1.w -= 8;
}
else
{
vt.uv0.z -= 8;
vt.uv0.w -= 8;
}
s_WorkingVertices[i] = vt;
}
}
}
vh.Clear();
vh.AddUIVertexTriangleStream(s_WorkingVertices);
}
private int GetVertexCountMultiply()
{
switch (shadowMode)
{
case ShadowMode.Shadow: return 1 + shadowIteration * 1;
case ShadowMode.Shadow3: return 1 + shadowIteration * 3;
case ShadowMode.Outline: return 1 + shadowIteration * 4;
case ShadowMode.Outline8: return 1 + shadowIteration * 8;
case ShadowMode.Mirror: return 1 + 1;
default: return 1;
}
}
private Vector2 GetExpandSize()
{
var expandSize = Vector2.zero;
switch (samplingFilter)
{
case SamplingFilter.BlurFast:
expandSize.x += 10;
expandSize.y += 10;
break;
case SamplingFilter.BlurMedium:
expandSize.x += 15;
expandSize.y += 15;
break;
case SamplingFilter.BlurDetail:
expandSize.x += 20;
expandSize.y += 20;
break;
case SamplingFilter.RgbShift:
expandSize.x += 40;
expandSize.y += 40;
break;
}
switch (transitionFilter)
{
case TransitionFilter.Melt:
case TransitionFilter.Burn:
expandSize.y += 40;
break;
}
return expandSize;
}
private static void ModifyVertex(bool isTextMeshPro, ref UIVertex vt, Vector2 pos, Vector2 uv, Rect uvMask,
Rect rect, Matrix4x4 m)
{
vt.position = pos;
pos = m.MultiplyPoint3x4(pos);
var normalizedX = Mathf.InverseLerp(rect.xMin, rect.xMax, pos.x);
var normalizedY = Mathf.InverseLerp(rect.yMin, rect.yMax, pos.y);
if (isTextMeshPro)
{
vt.uv0.x = uv.x;
vt.uv0.y = uv.y;
vt.uv1.z = normalizedX;
vt.uv1.w = normalizedY;
vt.uv2 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
}
else
{
vt.uv0 = new Vector4(uv.x, uv.y, normalizedX, normalizedY);
vt.uv1 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
}
}
private static void GetBounds(List<UIVertex> verts, int start, int count, out Rect posBounds,
out Rect uvBounds)
{
var minPos = new Vector2(float.MaxValue, float.MaxValue);
var maxPos = new Vector2(float.MinValue, float.MinValue);
var minUV = new Vector2(float.MaxValue, float.MaxValue);
var maxUV = new Vector2(float.MinValue, float.MinValue);
for (var i = start; i < start + count; i++)
{
var vt = verts[i];
var uv = vt.uv0;
var pos = vt.position;
// Left-Bottom
if (minPos.x >= pos.x && minPos.y >= pos.y)
{
minPos = pos;
}
// Right-Top
else if (maxPos.x <= pos.x && maxPos.y <= pos.y)
{
maxPos = pos;
}
// Left-Bottom
if (minUV.x >= uv.x && minUV.y >= uv.y)
{
minUV = uv;
}
// Right-Top
else if (maxUV.x <= uv.x && maxUV.y <= uv.y)
{
maxUV = uv;
}
}
// Shrink coordinate to avoid uv edge
posBounds = new Rect(minPos.x + 0.001f, minPos.y + 0.001f,
maxPos.x - minPos.x - 0.002f, maxPos.y - minPos.y - 0.002f);
uvBounds = new Rect(minUV.x, minUV.y, maxUV.x - minUV.x, maxUV.y - minUV.y);
}
private static void ApplyMirror(List<UIVertex> verts, int count, float rate, Vector2 range, float scale,
float offset, float alpha)
{
rate = Mathf.Clamp01(rate);
var start = 0;
var end = count;
ApplyShadowZeroAlloc(verts, ref start, ref end, 0, 0, alpha);
for (var i = 0; i < count; i += 6)
{
var lb = s_WorkingVertices[i];
var lbRate = Mathf.InverseLerp(range.x, range.y, lb.position.y);
var lt = s_WorkingVertices[i + 1];
var ltRate = Mathf.InverseLerp(range.x, range.y, lt.position.y);
var rt = s_WorkingVertices[i + 2];
var rtRate = Mathf.InverseLerp(range.x, range.y, rt.position.y);
var rb = s_WorkingVertices[i + 4];
var rbRate = Mathf.InverseLerp(range.x, range.y, rb.position.y);
lb.color.a = (byte)(Mathf.InverseLerp(rate, 0, lbRate) * lb.color.a);
lt.color.a = (byte)(Mathf.InverseLerp(rate, 0, ltRate) * lt.color.a);
rt.color.a = (byte)(Mathf.InverseLerp(rate, 0, rtRate) * rt.color.a);
rb.color.a = (byte)(Mathf.InverseLerp(rate, 0, rbRate) * rb.color.a);
if (lbRate < rate && rate < ltRate)
{
var t = (rate - lbRate) / (ltRate - lbRate);
lt.position = Vector3.Lerp(lb.position, lt.position, t);
lt.uv0 = Vector4.Lerp(lb.uv0, lt.uv0, t);
lt.uv1 = Vector4.Lerp(lb.uv1, lt.uv1, t);
lt.uv2 = Vector4.Lerp(lb.uv2, lt.uv2, t);
lt.color = Color.Lerp(lb.color, lt.color, t);
}
if (rbRate < rate && rate < rtRate)
{
var t = (rate - rbRate) / (rtRate - rbRate);
rt.position = Vector3.Lerp(rb.position, rt.position, t);
rt.uv0 = Vector4.Lerp(rb.uv0, rt.uv0, t);
rt.uv1 = Vector4.Lerp(rb.uv1, rt.uv1, t);
rt.uv2 = Vector4.Lerp(rb.uv2, rt.uv2, t);
rt.color = Color.Lerp(rb.color, rt.color, t);
}
lb.position.y = -lb.position.y * scale + offset;
lt.position.y = -lt.position.y * scale + offset;
rt.position.y = -rt.position.y * scale + offset;
rb.position.y = -rb.position.y * scale + offset;
s_WorkingVertices[i] = s_WorkingVertices[i + 5] = lb;
s_WorkingVertices[i + 1] = lt;
s_WorkingVertices[i + 2] = s_WorkingVertices[i + 3] = rt;
s_WorkingVertices[i + 4] = rb;
}
}
/// <summary>
/// Append shadow vertices.
/// * It is similar to Shadow component implementation.
/// </summary>
private static void ApplyShadow(List<UIVertex> verts, ref int start, ref int end, Vector2 distance,
ShadowMode mode, float alpha)
{
if (mode == ShadowMode.None) return;
var x = distance.x;
var y = distance.y;
switch (mode)
{
case ShadowMode.Shadow:
ApplyShadowZeroAlloc(verts, ref start, ref end, x, y, alpha);
break;
case ShadowMode.Shadow3:
ApplyShadowZeroAlloc(verts, ref start, ref end, x, y, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, x, 0, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, 0, y, alpha);
break;
case ShadowMode.Outline:
ApplyShadowZeroAlloc(verts, ref start, ref end, x, y, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, x, -y, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, y, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, -y, alpha);
break;
case ShadowMode.Outline8:
ApplyShadowZeroAlloc(verts, ref start, ref end, x, y, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, x, -y, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, y, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, -y, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, x, 0, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, 0, y, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, -x, 0, alpha);
ApplyShadowZeroAlloc(verts, ref start, ref end, 0, -y, alpha);
break;
}
}
/// <summary>
/// Append shadow vertices.
/// * It is similar to Shadow component implementation.
/// </summary>
private static void ApplyShadowZeroAlloc(List<UIVertex> verts, ref int start, ref int end, float x, float y,
float alpha)
{
var count = end - start;
for (var i = 0; i < count; i++)
{
// The original vertices is pushed backward.
verts.Add(verts[end - count + i]);
// Set shadow vertex.
var vt = verts[start + i];
vt.position.x += x;
vt.position.y += y;
vt.color.a = (byte)(alpha * vt.color.a);
verts[start + i] = vt;
}
// Update next shadow offset.
start = end;
end = verts.Count;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e77b2d031cabd4b49b951ba8fe42a0fe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1a317ae5eb1744395a2cbae4110e7ea6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+433
View File
@@ -0,0 +1,433 @@
#ifndef UI_EFFECT_INCLUDED
#define UI_EFFECT_INCLUDED
uniform float4 _MainTex_TexelSize;
uniform float _ToneIntensity;
uniform half4 _ColorValue;
uniform float _ColorIntensity;
uniform float _SamplingIntensity;
uniform sampler2D _TransitionTex;
uniform float4 _TransitionTex_ST;
uniform float _TransitionRate;
uniform int _TransitionReverse;
uniform half4 _TransitionColor;
uniform float _TransitionSoftness;
uniform float _TransitionWidth;
uniform fixed4 _TargetColor;
uniform float _TargetRange;
uniform float _TargetSoftness;
// For performance reasons, limit the sampling of blur in TextMeshPro.
#ifdef UIEFFECT_TEXTMESHPRO
#ifdef SAMPLING_BLUR_MEDIUM
#undef SAMPLING_BLUR_MEDIUM
#define SAMPLING_BLUR_FAST 1
#endif
#ifdef SAMPLING_BLUR_DETAIL
#undef SAMPLING_BLUR_DETAIL
#define SAMPLING_BLUR_FAST 1
#endif
#endif
#define TONE_NONE (!TONE_GRAYSCALE && !TONE_SEPIA && !TONE_NEGATIVE && !TONE_RETRO && !TONE_POSTERIZE)
#define COLOR_NONE (!COLOR_MULTIPLY && !COLOR_ADDITIVE && !COLOR_SUBTRACTIVE && !COLOR_REPLACE && !COLOR_MULTIPLY_LUMINANCE && !COLOR_MULTIPLY_ADDITIVE && !COLOR_HSV_MODIFIER && !COLOR_CONTRAST)
#define SAMPLING_NONE (!SAMPLING_BLUR_FAST && !SAMPLING_BLUR_MEDIUM && !SAMPLING_BLUR_DETAIL && !SAMPLING_PIXELATION && !SAMPLING_RGB_SHIFT && !SAMPLING_EDGE)
#define TRANSITION_NONE (!TRANSITION_FADE && !TRANSITION_CUTOFF && !TRANSITION_DISSOLVE && !TRANSITION_SHINY && !TRANSITION_MASK && !TRANSITION_MELT && !TRANSITION_BURN)
#define TRANSITION_COLOR_NONE (!TRANSITION_COLOR_MULTIPLY && !TRANSITION_COLOR_ADDITIVE && !TRANSITION_COLOR_SUBTRACTIVE && !TRANSITION_COLOR_REPLACE && !TRANSITION_COLOR_MULTIPLY_LUMINANCE && !TRANSITION_COLOR_MULTIPLY_ADDITIVE && !TRANSITION_COLOR_HSV_MODIFIER && !TRANSITION_COLOR_CONTRAST)
#define TARGET_NONE (!TARGET_HUE && !TARGET_LUMINANCE)
#define UIEFFECT_SAMPLE(uv) uieffect_frag(uv)
#define UIEFFECT_SAMPLE_CLAMP(uv, uvMask) uieffect_frag(uv) \
* step(uvMask.x, uv.x) * step(uv.x, uvMask.z) \
* step(uvMask.y, uv.y) * step(uv.y, uvMask.w)
float3 rgb_to_hsv(float3 c)
{
const float4 K = float4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
const float4 p = lerp(float4(c.bg, K.wz), float4(c.gb, K.xy), step(c.b, c.g));
const float4 q = lerp(float4(p.xyw, c.r), float4(c.r, p.yzx), step(p.x, c.r));
const float d = q.x - min(q.w, q.y);
const float e = 1.0e-4;
return float3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
float3 hsv_to_rgb(float3 c)
{
const float4 K = float4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
const float3 p = abs(frac(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * lerp(K.xxx, saturate(p - K.xxx), c.y);
}
float inv_lerp(const float from, const float to, const float value)
{
return saturate(max(0, value - from) / max(0.001, to - from));
}
float transition_alpha(float2 uvLocal)
{
#if TRANSITION_NONE
return 1;
#endif
const float2 uv = uvLocal * _TransitionTex_ST.xy + _TransitionTex_ST.zw;
const float alpha = tex2D(_TransitionTex, uv).a;
return (1 - alpha) * _TransitionReverse + alpha * (1 - _TransitionReverse);
}
half get_target_rate(const half3 color)
{
#if TARGET_NONE
return 1;
#endif
if (1 <= _TargetRange) return 1;
if (_TargetRange <= 0) return 0;
half diff = 0;
#if TARGET_HUE // Target.Hue
{
const half value = rgb_to_hsv(color).x;
const half target = rgb_to_hsv(_TargetColor).x;
diff = abs(target - value);
diff = min(diff, 1 - diff);
}
#elif TARGET_LUMINANCE // Target.Luminance
{
const half value = Luminance(color);
const half target = Luminance(_TargetColor);
diff = abs(target - value);
}
#endif
return 1 - inv_lerp(_TargetRange * (1 - _TargetSoftness), _TargetRange, diff);
}
half4 apply_tone_filter(half4 color)
{
#if TONE_GRAYSCALE // Tone.Grayscale
color.rgb = lerp(color.rgb, Luminance(color.rgb), _ToneIntensity);
#elif TONE_SEPIA // Tone.Sepia
color.rgb = lerp(color.rgb, Luminance(color.rgb) * half3(1.07, 0.74, 0.43), _ToneIntensity);
#elif TONE_NEGATIVE // Tone.Negative
color.rgb = lerp(color.rgb, (1 - color.rgb) * color.a, _ToneIntensity);
#elif TONE_RETRO // Tone.Retro
const fixed l = Luminance(color.rgb);
const fixed r0 = step(l, 0.25);
const fixed r1 = step(l, 0.5);
const fixed r2 = step(l, 0.75);
const fixed3 retro = fixed3(0.06, 0.22, 0.06) * r0 // 0.0-0.25: (15, 56, 15)
+ fixed3(0.19, 0.38, 0.19) * (1 - r0) * r1 // 0.25-0.5: (48, 98, 48)
+ fixed3(0.54, 0.67, 0.06) * (1 - r1) * r2 // 0.5-0.75: (139, 172, 15)
+ fixed3(0.60, 0.74, 0.06) * (1 - r2); // 0.75-1.0: (155, 188, 15)
color.rgb = lerp(color.rgb, retro * color.a, _ToneIntensity);
#elif TONE_POSTERIZE // Tone.Posterize
const half3 hsv = rgb_to_hsv(color.rgb);
const int div = round(lerp(48, 4, _ToneIntensity) / 2) * 2;
color.rgb = hsv_to_rgb((floor(hsv * div) + 0.5) / div) * color.a;
#endif
return color;
}
half4 apply_color_filter(half4 color, const half4 factor, const float intensity)
{
const half4 inColor = color;
#if COLOR_NONE // Color.None
{
return color;
}
#elif COLOR_MULTIPLY // Color.Multiply
{
color.rgb = color.rgb * factor.rgb;
}
#elif COLOR_ADDITIVE // Color.Additive
{
color.rgb = color.rgb + factor.rgb * color.a;
}
#elif COLOR_SUBTRACTIVE // Color.Subtractive
{
color.rgb = color.rgb - factor.rgb * color.a;
}
#elif COLOR_REPLACE // Color.Replace
{
color.rgb = factor.rgb * color.a;
}
#elif COLOR_MULTIPLY_LUMINANCE // Color.MultiplyLuminance
{
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
}
#elif COLOR_MULTIPLY_ADDITIVE // Color.MultiplyAdditive
{
color.rgb = color.rgb * (1 + factor.rgb);
}
#elif COLOR_HSV_MODIFIER // Color.HsvModifier
{
const float3 hsv = rgb_to_hsv(color.rgb);
color.rgb = hsv_to_rgb(hsv + factor.rgb) * color.a * factor.a;
color.a = color.a * factor.a;
}
#elif COLOR_CONTRAST // Color.Contrast
{
color.rgb = ((color.rgb - 0.5) * (factor.r + 1) + 0.5 + factor.g * 1.5) * color.a * factor.a;
color.a = color.a * factor.a;
}
#endif
return lerp(inColor, color, intensity);
}
half4 apply_transition_color_filter(half4 color, const half4 factor, const float intensity)
{
const half4 inColor = color;
#if TRANSITION_COLOR_NONE // Color.None
{
return color;
}
#elif TRANSITION_COLOR_MULTIPLY // Color.Multiply
{
color.rgb = color.rgb * factor.rgb;
}
#elif TRANSITION_COLOR_ADDITIVE // Color.Additive
{
color.rgb = color.rgb + factor.rgb * color.a;
}
#elif TRANSITION_COLOR_SUBTRACTIVE // Color.Subtractive
{
color.rgb = color.rgb - factor.rgb * color.a;
}
#elif TRANSITION_COLOR_REPLACE // Color.Replace
{
color.rgb = factor.rgb * color.a;
}
#elif TRANSITION_COLOR_MULTIPLY_LUMINANCE // Color.MultiplyLuminance
{
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
}
#elif TRANSITION_COLOR_MULTIPLY_ADDITIVE // Color.MultiplyAdditive
{
color.rgb = color.rgb * (1 + factor.rgb);
}
#elif TRANSITION_COLOR_HSV_MODIFIER // Color.HsvModifier
{
const float3 hsv = rgb_to_hsv(color.rgb);
color.rgb = hsv_to_rgb(hsv + factor.rgb) * color.a * factor.a;
color.a = color.a * factor.a;
}
#elif TRANSITION_COLOR_CONTRAST // Color.Contrast
{
color.rgb = ((color.rgb - 0.5) * (factor.r + 1) + 0.5 + factor.g * 1.5) * color.a * factor.a;
color.a = color.a * factor.a;
}
#endif
return lerp(inColor, color, intensity);
}
half4 apply_sampling_filter(float2 uv, const float4 uvMask, const float2 uvLocal)
{
#if SAMPLING_BLUR_FAST || SAMPLING_BLUR_MEDIUM || SAMPLING_BLUR_DETAIL
{
if (0 < _SamplingIntensity && -4 < uvLocal.x + uvLocal.y)
{
#if SAMPLING_BLUR_FAST
const int KERNEL_SIZE = 5;
const float KERNEL_[5] = {0.2486, 0.7046, 1.0, 0.7046, 0.2486};
#elif SAMPLING_BLUR_MEDIUM
const int KERNEL_SIZE = 9;
const float KERNEL_[9] = { 0.0438, 0.1719, 0.4566, 0.8204, 1.0, 0.8204, 0.4566, 0.1719, 0.0438};
#elif SAMPLING_BLUR_DETAIL
const int KERNEL_SIZE = 13;
const float KERNEL_[13] = { 0.0438, 0.1138, 0.2486, 0.4566, 0.7046, 0.9141, 1.0, 0.9141, 0.7046, 0.4566, 0.2486, 0.1138, 0.0438};
#endif
float4 o = 0;
float sum = 0;
float2 shift = 0;
const half2 blur = _MainTex_TexelSize.xy * _SamplingIntensity * 2;
for (int x = 0; x < KERNEL_SIZE; x++)
{
shift.x = blur.x * (float(x) - KERNEL_SIZE / 2);
for (int y = 0; y < KERNEL_SIZE; y++)
{
shift.y = blur.y * (float(y) - KERNEL_SIZE / 2);
const float2 bluredUv = uv + shift;
const float weight = KERNEL_[x] * KERNEL_[y]
* step(uvMask.x, bluredUv.x) * step(bluredUv.x, uvMask.z)
* step(uvMask.y, bluredUv.y) * step(bluredUv.y, uvMask.w);
o += UIEFFECT_SAMPLE(bluredUv) * weight;
sum += weight;
}
}
return 0 < sum ? o / sum : 0;
}
}
#endif
return UIEFFECT_SAMPLE_CLAMP(uv, uvMask);
}
float2 move_transition_filter(const float4 uvMask, const float alpha)
{
// Transition.Melt/Burn
#if !TRANSITION_MELT && !TRANSITION_BURN
{
return 0;
}
#endif
const float factor = alpha - _TransitionRate * (1 + _TransitionWidth * 1.5) + _TransitionWidth;
const float band = max(0, _TransitionWidth - factor);
#if TRANSITION_MELT
{
return float2(0, +band * band * (uvMask.w - uvMask.y) / max(0.01, _TransitionWidth));
}
#elif TRANSITION_BURN
{
return float2(0, -band * band * (uvMask.w - uvMask.y) / max(0.01, _TransitionWidth));
}
#endif
return 0;
}
half4 apply_transition_filter(half4 color, const float alpha)
{
#if TRANSITION_FADE // Transition.Fade
{
color *= saturate(alpha + 1 - _TransitionRate * 2);
}
#elif TRANSITION_CUTOFF // Transition.Cutoff
{
color *= step(0.001, color.a * alpha - _TransitionRate);
}
// Transition.Dissolve/Shiny/ShinyOnly/Melt
#elif TRANSITION_DISSOLVE || TRANSITION_SHINY || TRANSITION_MASK || TRANSITION_MELT || TRANSITION_BURN
{
const float factor = alpha - _TransitionRate * (1 + _TransitionWidth) + _TransitionWidth;
const float softness = max(0.0001, _TransitionWidth * _TransitionSoftness);
// const fixed bandLerp = step(factor, color.a) * saturate((_TransitionWidth - factor) * 1 / softness);
const fixed bandLerp = saturate((_TransitionWidth - factor) * 1 / softness);
const fixed softLerp = saturate(factor * 2 / softness);
half4 bandColor = apply_transition_color_filter(half4(color.rgb, 1), half4(_TransitionColor.rgb, 1),
_TransitionColor.a);
// bandColor.a *= color.a;
bandColor *= color.a;
#if TRANSITION_MELT
{
color = lerp(color, bandColor, bandLerp);
// return color * color.a;
return color;
}
#elif TRANSITION_BURN
{
color = lerp(color, bandColor, bandLerp * 1.25);
color.a *= 1 - inv_lerp(0.85, 1.0, bandLerp * 1.25);
color.rgb *= (1 - inv_lerp(0.85, 1.0, bandLerp * 1.3)) * color.a;
return color;
}
#endif
color.rgb = lerp(color.rgb, bandColor, bandLerp * softLerp);
#if TRANSITION_DISSOLVE
{
color *= softLerp;
}
#elif TRANSITION_MASK
{
color *= bandLerp * softLerp;
}
#endif
}
#endif
return color;
}
half to_value(float4 c)
{
#if SAMPLING_EDGE_LUMINANCE
return Luminance(c) * c.a;
#elif SAMPLING_EDGE_ALPHA
return c.a;
#endif
return 0;
}
half4 uieffect_internal(float2 uv, const float4 uvMask, const float2 uvLocal)
{
const half alpha = transition_alpha(uvLocal);
uv += move_transition_filter(uvMask, alpha);
half4 color = apply_sampling_filter(uv, uvMask, uvLocal);
color = apply_tone_filter(color);
color = apply_transition_filter(color, alpha);
if (-4 <= uvLocal.x + uvLocal.y)
{
color = apply_color_filter(color, _ColorValue, _ColorIntensity);
}
return color;
}
half4 uieffect(float2 uv, const float4 uvMask, const float2 uvLocal)
{
const fixed4 origin = UIEFFECT_SAMPLE_CLAMP(uv, uvMask);
const half rate = get_target_rate(origin);
// Sampling.Pixelation
#if SAMPLING_PIXELATION
{
const half2 pixelSize = max(2, (1 - lerp(0.5, 0.95, _SamplingIntensity)) * _MainTex_TexelSize.zw);
uv = round(uv * pixelSize) / pixelSize;
}
// Sampling.RgbShift
#elif SAMPLING_RGB_SHIFT
{
const half2 offset = half2(_SamplingIntensity * _MainTex_TexelSize.x * 20, 0);
const half2 r = uieffect_internal(uv + offset, uvMask, uvLocal).ra;
const half2 g = uieffect_internal(uv, uvMask, uvLocal).ga;
const half2 b = uieffect_internal(uv - offset, uvMask, uvLocal).ba;
return half4(r.x * r.y, g.x * g.y, b.x * b.y, (r.y + g.y + b.y) / 3);
}
// Sampling.EdgeLuminance/EdgeAlpha
#elif SAMPLING_EDGE_LUMINANCE || SAMPLING_EDGE_ALPHA
{
// Pixel size
const float dx = _MainTex_TexelSize.x;
const float dy = _MainTex_TexelSize.y;
// Pixel values around the current pixel (3x3, 8 neighbors)
const float2 uv00 = uv + half2(-dx, -dy);
const half v00 = to_value(UIEFFECT_SAMPLE_CLAMP(uv00, uvMask));
const float2 uv01 = uv + half2(-dx, 0.0);
const half v01 = to_value(UIEFFECT_SAMPLE_CLAMP(uv01, uvMask));
const float2 uv02 = uv + half2(-dx, +dy);
const half v02 = to_value(UIEFFECT_SAMPLE_CLAMP(uv02, uvMask));
const float2 uv10 = uv + half2(0.0, -dy);
const half v10 = to_value(UIEFFECT_SAMPLE_CLAMP(uv10, uvMask));
const float2 uv12 = uv + half2(0.0, +dy);
const half v12 = to_value(UIEFFECT_SAMPLE_CLAMP(uv12, uvMask));
const float2 uv20 = uv + half2(+dx, -dy);
const half v20 = to_value(UIEFFECT_SAMPLE_CLAMP(uv20, uvMask));
const float2 uv21 = uv + half2(+dx, 0.0);
const half v21 = to_value(UIEFFECT_SAMPLE_CLAMP(uv21, uvMask));
const float2 uv22 = uv + half2(+dx, +dy);
const half v22 = to_value(UIEFFECT_SAMPLE_CLAMP(uv22, uvMask));
// Apply Sobel operator
half sobel_h = v00 * -1.0 + v01 * -2.0 + v02 * -1.0 + v20 * 1.0 + v21 * 2.0 + v22 * 1.0;
half sobel_v = v00 * -1.0 + v10 * -2.0 + v20 * -1.0 + v02 * 1.0 + v12 * 2.0 + v22 * 1.0;
const half sobel = sqrt(sobel_h * sobel_h + sobel_v * sobel_v) * _SamplingIntensity;
return lerp(0, uieffect_internal(uv, uvMask, uvLocal), inv_lerp(0.5, 1, sobel));
}
#endif
return lerp(origin, uieffect_internal(uv, uvMask, uvLocal), rate);
}
#endif // UI_EFFECT_INCLUDED
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2dd0ed35b98b345218d9aa8ac5a3ad6b
ShaderIncludeImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+173
View File
@@ -0,0 +1,173 @@
Shader "Hidden/UI/Default (UIEffect)"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
_StencilWriteMask ("Stencil Write Mask", Float) = 255
_StencilReadMask ("Stencil Read Mask", Float) = 255
_ColorMask ("Color Mask", Float) = 15
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Stencil
{
Ref [_Stencil]
Comp [_StencilComp]
Pass [_StencilOp]
ReadMask [_StencilReadMask]
WriteMask [_StencilWriteMask]
}
Cull Off
Lighting Off
ZWrite Off
ZTest [unity_GUIZTestMode]
Blend [_SrcBlend] [_DstBlend]
ColorMask [_ColorMask]
Pass
{
Name "Default"
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#include "UnityCG.cginc"
#include "UnityUI.cginc"
#pragma multi_compile_local_fragment _ UNITY_UI_CLIP_RECT
#pragma multi_compile_local_fragment _ UNITY_UI_ALPHACLIP
// ==== UIEFFECT START ====
#pragma shader_feature_local_fragment _ TONE_GRAYSCALE TONE_SEPIA TONE_NEGATIVE TONE_RETRO TONE_POSTERIZE
#pragma shader_feature_local_fragment _ COLOR_MULTIPLY COLOR_ADDITIVE COLOR_SUBTRACTIVE COLOR_REPLACE COLOR_MULTIPLY_LUMINANCE COLOR_MULTIPLY_ADDITIVE COLOR_HSV_MODIFIER COLOR_CONTRAST
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN
#pragma shader_feature_local_fragment _ TRANSITION_COLOR_MULTIPLY TRANSITION_COLOR_ADDITIVE TRANSITION_COLOR_SUBTRACTIVE TRANSITION_COLOR_REPLACE TRANSITION_COLOR_MULTIPLY_LUMINANCE TRANSITION_COLOR_MULTIPLY_ADDITIVE TRANSITION_COLOR_HSV_MODIFIER TRANSITION_COLOR_CONTRAST
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
// ==== UIEFFECT END ====
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float4 texcoord : TEXCOORD0;
// ==== UIEFFECT START ====
float4 uvMask : TEXCOORD1;
// ==== UIEFFECT END ====
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord : TEXCOORD0;
float4 worldPosition : TEXCOORD1;
float4 mask : TEXCOORD2;
// ==== UIEFFECT START ====
float4 uvMask : TEXCOORD3;
float2 uvLocal : TEXCOORD4;
// ==== UIEFFECT END ====
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _MainTex;
fixed4 _Color;
fixed4 _TextureSampleAdd;
float4 _ClipRect;
float4 _MainTex_ST;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
int _UIVertexColorAlwaysGammaSpace;
v2f vert(appdata_t v)
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
float4 vPosition = UnityObjectToClipPos(v.vertex);
OUT.worldPosition = v.vertex;
OUT.vertex = vPosition;
float2 pixelSize = vPosition.w;
pixelSize /= float2(1, 1) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
float2 maskUV = (v.vertex.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
OUT.texcoord = TRANSFORM_TEX(v.texcoord.xy, _MainTex);
OUT.mask = float4(v.vertex.xy * 2 - clampedRect.xy - clampedRect.zw,
0.25 / (0.25 * half2(_UIMaskSoftnessX, _UIMaskSoftnessY) + abs(pixelSize.xy)));
if (_UIVertexColorAlwaysGammaSpace)
{
if (!IsGammaSpace())
{
v.color.rgb = GammaToLinearSpace(v.color.rgb);
}
}
OUT.color = v.color * _Color;
OUT.uvMask = v.uvMask;
OUT.uvLocal = v.texcoord.zw;
return OUT;
}
// ==== UIEFFECT START ====
v2f _fragInput;
fixed4 uieffect_frag(float2 uv)
{
v2f IN = _fragInput;
//Round up the alpha color coming from the interpolator (to 1.0/256.0 steps)
//The incoming alpha could have numerical instability, which makes it very sensible to
//HDR color transparency blend, when it blends with the world's texture.
const half alphaPrecision = half(0xff);
const half invAlphaPrecision = half(1.0 / alphaPrecision);
IN.color.a = round(IN.color.a * alphaPrecision) * invAlphaPrecision;
half4 color = IN.color * (tex2D(_MainTex, uv) + _TextureSampleAdd);
color.rgb *= color.a;
return color;
}
#include "Packages/com.coffee.ui-effect/Shaders/UIEffect.cginc"
// ==== UIEFFECT END ====
half4 frag(v2f IN) : SV_Target
{
_fragInput = IN;
half4 c = uieffect(_fragInput.texcoord, _fragInput.uvMask, _fragInput.uvLocal);
#ifdef UNITY_UI_CLIP_RECT
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
c *= m.x * m.y;
#endif
#ifdef UNITY_UI_ALPHACLIP
clip (c.a - 0.001);
#endif
return c;
}
ENDCG
}
}
}
+10
View File
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 96246b1ead49a4c5a996fd477bc5a117
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:
+46
View File
@@ -0,0 +1,46 @@
{
"name": "com.coffee.ui-effect",
"displayName": "UI Effect",
"description": "UIEffect is an open-source package that allows you to intuitively apply rich UI effects directly from the Inspector or via code.\nCombine various filters, such as grayscale, blur, and dissolve, to decorate your UI with a unique visual style!",
"version": "5.0.0",
"unity": "2020.3",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/mob-sakai/UIEffect.git"
},
"author": {
"name": "mob-sakai",
"email": "sakai861104@gmail.com",
"url": "https://github.com/mob-sakai"
},
"dependencies": {
"com.unity.ugui": "1.0.0"
},
"keywords": [
"ui",
"effect"
],
"samples": [
{
"displayName": "Demo",
"description": "UI Effect Demo",
"path": "Samples~/Demo"
},
{
"displayName": "v4 Compatible Components",
"description": "v4 Compatible Components",
"path": "Samples~/v4 Compatible Components"
},
{
"displayName": "TextMeshPro Support",
"description": "TextMeshPro Support",
"path": "Samples~/TextMeshPro Support~"
},
{
"displayName": "TextMeshPro Support (Unity 6)",
"description": "TextMeshPro Support (Unity 6)",
"path": "Samples~/TextMeshPro Support (Unity 6)~"
}
]
}
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 546af75b6221c4768be79d67c9cea1fb
timeCreated: 1547605752
licenseType: Pro
TextScriptImporter:
userData:
assetBundleName:
assetBundleVariant: