Compare commits

...

9 Commits

Author SHA1 Message Date
semantic-release-bot 451cbe4302 chore(release): 5.10.1 [skip ci]
## [5.10.1](https://github.com/mob-sakai/UIEffect/compare/5.10.0...5.10.1) (2025-10-06)

### Bug Fixes

* [improve performance] `UpdateViewMatrix` is called even though (direct-)parent canvas is disabled ([533d7b8](https://github.com/mob-sakai/UIEffect/commit/533d7b8c0a33871b1849fbda862d4fa1899822f4)), closes [#373](https://github.com/mob-sakai/UIEffect/issues/373)
2025-10-06 07:00:33 +00:00
mob-sakai 3cae638bdd chore: game-ci/unity-builder action no longer supports .Net3.5 2025-10-06 15:06:00 +09:00
mob-sakai 533d7b8c0a fix: [improve performance] UpdateViewMatrix is called even though (direct-)parent canvas is disabled
close #373
2025-10-06 10:23:40 +09:00
semantic-release-bot 9380f96572 chore(release): 5.10.0 [skip ci]
# [5.10.0](https://github.com/mob-sakai/UIEffect/compare/5.9.7...5.10.0) (2025-09-26)

### Bug Fixes

* `TmpProxy` causes loss of modifications from other `IMeshModifiers` ([c4202b4](https://github.com/mob-sakai/UIEffect/commit/c4202b45d28fa84567a5671baaef8fa3e3df85dc)), closes [#371](https://github.com/mob-sakai/UIEffect/issues/371)
* display may disappear when using TMP SubMesh (multi-language or sprites, etc.) ([b4adb32](https://github.com/mob-sakai/UIEffect/commit/b4adb325120eeed64af1d9cb2468a1e1e8e10812)), closes [#372](https://github.com/mob-sakai/UIEffect/issues/372)
* TMP Text sprite submesh lost when changing fontMaterial ([59874dd](https://github.com/mob-sakai/UIEffect/commit/59874ddffe356f927dc8ff9b157c54043e149522)), closes [#368](https://github.com/mob-sakai/UIEffect/issues/368)

### Features

* [improve performance] merged apply_color function and reduced shader compilation size ([ce69258](https://github.com/mob-sakai/UIEffect/commit/ce692580a33c0c433fd7fadb64a3dcda0121b2ff))
* [improve performance] various view matrices are only updated when necessary ([6c808aa](https://github.com/mob-sakai/UIEffect/commit/6c808aa3417450fd1ce0fc6fbfe0adffdff9a79a))
2025-09-26 08:30:19 +00:00
mob-sakai b4adb32512 fix: display may disappear when using TMP SubMesh (multi-language or sprites, etc.)
close #372
2025-09-26 09:17:33 +09:00
mob-sakai 59874ddffe fix: TMP Text sprite submesh lost when changing fontMaterial
close #368
2025-09-25 19:26:50 +09:00
mob-sakai c4202b45d2 fix: TmpProxy causes loss of modifications from other IMeshModifiers
close #371
2025-09-25 19:25:58 +09:00
mob-sakai ce692580a3 feat: [improve performance] merged apply_color function and reduced shader compilation size 2025-09-01 19:06:48 +09:00
mob-sakai 6c808aa341 feat: [improve performance] various view matrices are only updated when necessary 2025-09-01 19:05:02 +09:00
10 changed files with 160 additions and 233 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ run-name: 🧪 Test (${{ github.event.pull_request.title || github.ref_name }})
env:
# MINIMUM_VERSION: The minimum version of Unity.
MINIMUM_VERSION: 2020.3
MINIMUM_VERSION: 2021.3
# EXCLUDE_FILTER: The excluded versions of Unity.
EXCLUDE_FILTER: "(2020.2.0|2021.1|2023.2|2023.3)"
PROJECT_PATH: .
+22
View File
@@ -1,3 +1,25 @@
## [5.10.1](https://github.com/mob-sakai/UIEffect/compare/5.10.0...5.10.1) (2025-10-06)
### Bug Fixes
* [improve performance] `UpdateViewMatrix` is called even though (direct-)parent canvas is disabled ([533d7b8](https://github.com/mob-sakai/UIEffect/commit/533d7b8c0a33871b1849fbda862d4fa1899822f4)), closes [#373](https://github.com/mob-sakai/UIEffect/issues/373)
# [5.10.0](https://github.com/mob-sakai/UIEffect/compare/5.9.7...5.10.0) (2025-09-26)
### Bug Fixes
* `TmpProxy` causes loss of modifications from other `IMeshModifiers` ([c4202b4](https://github.com/mob-sakai/UIEffect/commit/c4202b45d28fa84567a5671baaef8fa3e3df85dc)), closes [#371](https://github.com/mob-sakai/UIEffect/issues/371)
* display may disappear when using TMP SubMesh (multi-language or sprites, etc.) ([b4adb32](https://github.com/mob-sakai/UIEffect/commit/b4adb325120eeed64af1d9cb2468a1e1e8e10812)), closes [#372](https://github.com/mob-sakai/UIEffect/issues/372)
* TMP Text sprite submesh lost when changing fontMaterial ([59874dd](https://github.com/mob-sakai/UIEffect/commit/59874ddffe356f927dc8ff9b157c54043e149522)), closes [#368](https://github.com/mob-sakai/UIEffect/issues/368)
### Features
* [improve performance] merged apply_color function and reduced shader compilation size ([ce69258](https://github.com/mob-sakai/UIEffect/commit/ce692580a33c0c433fd7fadb64a3dcda0121b2ff))
* [improve performance] various view matrices are only updated when necessary ([6c808aa](https://github.com/mob-sakai/UIEffect/commit/6c808aa3417450fd1ce0fc6fbfe0adffdff9a79a))
## [5.9.7](https://github.com/mob-sakai/UIEffect/compare/5.9.6...5.9.7) (2025-09-01)
@@ -6,6 +6,7 @@ using UnityEngine.Profiling;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEditorInternal;
@@ -122,10 +123,15 @@ namespace Coffee.UIEffectInternal
#if UNITY_EDITOR
private readonly HashSet<StringPair> _logVariants = new HashSet<StringPair>();
private readonly StringBuilder _sb = new StringBuilder(1024);
private readonly Dictionary<Hash128, (ShaderVariantCollection.ShaderVariant, StringPair)> _cachedVariants =
new Dictionary<Hash128, (ShaderVariantCollection.ShaderVariant, StringPair)>();
public void ClearCache()
{
_cachedOptionalShaders.Clear();
_cachedVariants.Clear();
}
/// <summary>
@@ -213,21 +219,10 @@ namespace Coffee.UIEffectInternal
if (!material || !material.shader || !m_Asset) return;
Profiler.BeginSample("(EDITOR/COF)[ShaderVariantRegistry] RegisterVariant");
var shaderName = material.shader.name;
var validKeywords = material.shaderKeywords
.Where(x => !Regex.IsMatch(x, "(_EDITOR|EDITOR_)"))
.ToArray();
var keywords = string.Join(" ", validKeywords);
var variant = new ShaderVariantCollection.ShaderVariant
{
shader = material.shader,
keywords = validKeywords
};
// Already registered.
var pair = new StringPair() { key = shaderName, value = keywords };
var (variant, pair) = GetVariant(material);
if (m_Asset.Contains(variant))
{
// Already registered.
m_UnregisteredVariants.Remove(pair);
Profiler.EndSample();
return;
@@ -243,7 +238,8 @@ namespace Coffee.UIEffectInternal
if (_logVariants.Add(pair))
{
keywords = string.IsNullOrEmpty(keywords) ? "no keywords" : keywords;
var shaderName = pair.key;
var keywords = string.IsNullOrEmpty(pair.value) ? "no keywords" : pair.value;
Debug.LogError($"Shader variant '{shaderName} <{keywords}>' is not registered.\n" +
$"Register it in 'ProjectSettings > {path}' to use it in player.", m_Asset);
}
@@ -256,6 +252,44 @@ namespace Coffee.UIEffectInternal
m_UnregisteredVariants.Remove(pair);
Profiler.EndSample();
}
private (ShaderVariantCollection.ShaderVariant, StringPair) GetVariant(Material material)
{
Profiler.BeginSample("(EDITOR/COF)[ShaderVariantRegistry] GetVariant");
var shader = material.shader;
_sb.Length = 0;
foreach (var keyword in material.shaderKeywords)
{
// Ignore editor keyword.
if (keyword.Contains("_EDITOR") || keyword.Contains("EDITOR_")) continue;
_sb.Append(keyword);
_sb.Append(' ');
}
if (0 < _sb.Length)
{
_sb.Length--; // Remove last space.
}
var hash = new Hash128((uint)shader.GetInstanceID(), (uint)_sb.GetHashCode(), 0, 0);
if (_cachedVariants.TryGetValue(hash, out var result))
{
Profiler.EndSample();
return result;
}
var pair = new StringPair() { key = shader.name, value = _sb.ToString() };
var variant = new ShaderVariantCollection.ShaderVariant
{
shader = shader,
keywords = pair.value.Split(' ')
};
_cachedVariants.Add(hash, (variant, pair));
Profiler.EndSample();
return (variant, pair);
}
#endif
}
+32 -5
View File
@@ -32,6 +32,8 @@ namespace Coffee.UIEffects
private Action _onAfterCanvasRebuild;
private bool _canModifyMesh;
private Matrix4x4 _prevTransformHash;
private Canvas _canvas;
private bool _canvasCached = false;
public Material effectMaterial => _material;
public Graphic graphic => _graphic ? _graphic : _graphic = GetComponent<Graphic>();
@@ -39,6 +41,23 @@ namespace Coffee.UIEffects
public virtual float actualSamplingScale => 1;
public virtual bool canModifyShape => true;
protected Canvas canvas
{
get
{
if (_canvasCached) return _canvas;
_canvasCached = true;
_canvas = GetComponentInParent<Canvas>();
if (!_canvas || !_canvas.isActiveAndEnabled)
{
_canvas = null;
}
return _canvas;
}
}
public virtual UIEffectContext context
{
get
@@ -104,7 +123,7 @@ namespace Coffee.UIEffects
s_ContextPool.Return(ref _context);
}
protected virtual void OnBeforeCanvasRebuild()
private void OnBeforeCanvasRebuild()
{
// If the mesh is not modified in the previous frame, try to modify it if possible.
if (!_canModifyMesh && CanModifyMesh())
@@ -114,11 +133,18 @@ namespace Coffee.UIEffects
}
}
protected virtual void OnAfterCanvasRebuild()
private void OnAfterCanvasRebuild()
{
if (!_material || !graphic || !graphic.canvas || context == null) return;
if (!_material || !graphic || !canvas || context == null) return;
if (!context.useViewMatrix) return;
context.UpdateViewMatrix(GetCurrentMaterial(), transitionRoot, graphic.canvas.rootCanvas);
context.UpdateViewMatrix(GetCurrentMaterial(), transitionRoot, canvas.rootCanvas);
}
protected override void OnCanvasHierarchyChanged()
{
_canvasCached = false;
_canvas = null;
}
public void ModifyMesh(Mesh mesh)
@@ -132,13 +158,14 @@ namespace Coffee.UIEffects
_canModifyMesh = CanModifyMesh();
if (_canModifyMesh)
{
context.ModifyMesh(graphic, transitionRoot, vh, canModifyShape);
context.ModifyMesh(graphic, canvas, transitionRoot, vh, canModifyShape);
}
}
private bool CanModifyMesh()
{
if (!graphic || !graphic.isActiveAndEnabled) return false;
if (!isActiveAndEnabled) return false;
// The transitionRoot is same as the transform => true.
var root = transitionRoot;
+9 -3
View File
@@ -258,6 +258,11 @@ namespace Coffee.UIEffects
public bool willModifyVertex => willModifyMaterial;
public bool useViewMatrix => m_TransitionFilter != TransitionFilter.None
|| m_GradationMode != GradationMode.None
|| m_DetailFilter != DetailFilter.None
|| m_EdgeMode == EdgeMode.Shiny;
private Texture2D _gradationRampTex;
private Texture2D _transitionRampTex;
private bool _isGradientDirty = true;
@@ -446,7 +451,7 @@ namespace Coffee.UIEffects
{
if (!material) return;
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
Profiler.BeginSample("(UIE)[UIEffect] ApplyToMaterial");
material.SetInt(s_SrcBlend, (int)m_SrcBlendMode);
material.SetInt(s_DstBlend, (int)m_DstBlendMode);
@@ -701,7 +706,8 @@ namespace Coffee.UIEffects
}
}
public void ModifyMesh(Graphic graphic, RectTransform transitionRoot, VertexHelper vh, bool canModifyShape)
public void ModifyMesh(Graphic graphic, Canvas canvas, RectTransform transitionRoot, VertexHelper vh,
bool canModifyShape)
{
// Apply flip (without effect).
ApplyFlipWithoutEffect(vh, m_Flip);
@@ -711,7 +717,7 @@ namespace Coffee.UIEffects
var effectProxy = GraphicProxy.Find(graphic);
var isText = effectProxy.IsText(graphic);
effectProxy.OnPreModifyMesh(graphic);
effectProxy.OnPreModifyMesh(graphic, canvas);
var verts = s_WorkingVertices;
var expandSize = effectProxy.ModifyExpandSize(graphic, GetExpandSize(canModifyShape));
+2 -2
View File
@@ -124,9 +124,9 @@ namespace Coffee.UIEffects
{
get
{
if (preset && useTargetTransform && !m_CustomRoot && graphic && graphic.canvas)
if (preset && useTargetTransform && !m_CustomRoot && graphic && canvas)
{
return graphic.canvas.transform as RectTransform;
return canvas.transform as RectTransform;
}
if (useTargetTransform && isTargetInScene)
@@ -55,13 +55,12 @@ namespace Coffee.UIEffects
/// <summary>
/// Called before modifying the mesh.
/// </summary>
public virtual void OnPreModifyMesh(Graphic graphic)
public virtual void OnPreModifyMesh(Graphic graphic, Canvas canvas)
{
UIVertexUtil.onLerpVertex = s_OnLerpVertex;
ShadowUtil.onMarkAsShadow = s_OnMarkAsShadow;
UIEffectContext.onModifyVertex = s_OnModifyVertex;
var canvas = graphic.canvas;
if (canvas)
{
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord1;
+29 -5
View File
@@ -40,13 +40,12 @@ namespace Coffee.UIEffects
/// <summary>
/// Called before modifying the mesh.
/// </summary>
public override void OnPreModifyMesh(Graphic graphic)
public override void OnPreModifyMesh(Graphic graphic, Canvas canvas)
{
UIVertexUtil.onLerpVertex = s_OnLerpVertex;
ShadowUtil.onMarkAsShadow = s_OnMarkAsShadow;
UIEffectContext.onModifyVertex = s_OnModifyVertex;
var canvas = graphic.canvas;
if (canvas)
{
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord2;
@@ -131,7 +130,10 @@ namespace Coffee.UIEffects
// When the text is changed, add it to the changed list
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(obj =>
{
if (obj is TextMeshProUGUI textMeshProUGUI && textMeshProUGUI.isActiveAndEnabled)
if (obj is TextMeshProUGUI textMeshProUGUI
&& textMeshProUGUI.isActiveAndEnabled
// fix: `TmpProxy` causes loss of modifications from other `IMeshModifiers` (#371)
&& textMeshProUGUI.TryGetComponent<UIEffectBase>(out var _))
{
s_ChangedInstances.Add(textMeshProUGUI);
}
@@ -229,8 +231,21 @@ namespace Coffee.UIEffects
var meshInfo = textMeshProUGUI.textInfo.meshInfo[i];
if (meshInfo.vertexCount == 0)
{
// Clear mesh if no vertices.
s_Mesh.Clear(false);
textMeshProUGUI.canvasRenderer.SetMesh(s_Mesh);
if (i == 0)
{
textMeshProUGUI.canvasRenderer.SetMesh(s_Mesh);
}
else
{
var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material, i - 1);
if (subMeshUI)
{
subMeshUI.canvasRenderer.SetMesh(s_Mesh);
}
}
continue;
}
@@ -257,7 +272,16 @@ namespace Coffee.UIEffects
var subMeshUI = GetSubMeshUI(subMeshes, meshInfo.material, i - 1);
if (!subMeshUI) break;
var replica = subMeshUI.GetOrAddComponent<UIEffectReplica>();
// fix: TMP Text sprite submesh lost when changing fontMaterial (#368)
if (!subMeshUI.TryGetComponent<UIEffectReplica>(out var replica))
{
replica = subMeshUI.gameObject.AddComponent<UIEffectReplica>();
textMeshProUGUI.RegisterDirtyMaterialCallback(() =>
{
if (subMeshUI) subMeshUI.SetMaterialDirty();
});
}
if (effect is UIEffect pEffect && pEffect.isActiveAndEnabled)
{
replica.target = pEffect;
+15 -200
View File
@@ -223,84 +223,34 @@ half4 apply_tone_filter(half4 color)
return color;
}
half4 apply_color_filter(const half4 inColor, const half4 factor, const float intensity)
half4 apply_color_filter(int mode, half4 inColor, half4 factor, float intensity, float glow)
{
const float glow = _ColorGlow;
const int mode = _ColorFilter;
half4 color = inColor;
if (mode == 1) // Color.Multiply
{
color.rgb = color.rgb * factor.rgb;
color *= factor.a;
}
else if (mode == 2) // Color.Additive
{
color.rgb = color.rgb + factor.rgb * color.a;
color.rgb = color.rgb + factor.rgb * color.a * factor.a;
}
else if (mode == 3) // Color.Subtractive
{
color.rgb = color.rgb - factor.rgb * color.a;
color.rgb = color.rgb - factor.rgb * color.a * factor.a;
}
else if (mode == 4) // Color.Replace
{
color.rgb = factor.rgb * color.a;
color *= factor.a;
}
else if (mode == 5) // Color.MultiplyLuminance
{
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb * factor.a / 2 * color.a;
}
else if (mode == 6) // Color.MultiplyAdditive
{
color.rgb = color.rgb * (1 + factor.rgb);
}
else if (mode == 7) // Color.HsvModifier
{
const float3 hsv = rgb_to_hsv(color.rgb);
color.rgb = hsv_to_rgb(hsv + factor.rgb) * color.a * factor.a;
color.a = inColor.a * factor.a;
}
else if (mode == 8) // 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;
}
if (0 < mode)
{
color = lerp(inColor, color, intensity);
color.a *= 1 - glow * intensity;
}
return color;
}
half4 apply_transition_color_filter(const half4 inColor, const half4 factor, const float intensity)
{
const float glow = _TransitionColorGlow;
const int mode = _TransitionColorFilter;
half4 color = inColor;
if (mode == 1) // Color.Multiply
{
color.rgb = color.rgb * factor.rgb;
}
else if (mode == 2) // Color.Additive
{
color.rgb = color.rgb + factor.rgb * color.a;
}
else if (mode == 3) // Color.Subtractive
{
color.rgb = color.rgb - factor.rgb * color.a;
}
else if (mode == 4) // Color.Replace
{
color.rgb = factor.rgb * color.a;
}
else if (mode == 5) // Color.MultiplyLuminance
{
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
}
else if (mode == 6) // Color.MultiplyAdditive
{
color.rgb = color.rgb * (1 + factor.rgb);
color.rgb = color.rgb * (1 + factor.rgb * factor.a);
}
else if (mode == 7) // Color.HsvModifier
{
@@ -323,106 +273,6 @@ half4 apply_transition_color_filter(const half4 inColor, const half4 factor, con
return color;
}
half4 apply_shadow_color_filter(const half4 inColor, const half4 factor, const float intensity)
{
const float glow = _ShadowColorGlow;
const int mode = _ShadowColorFilter;
half4 color = inColor;
if (mode == 1) // Color.Multiply
{
color.rgb = color.rgb * factor.rgb;
}
else if (mode == 2) // Color.Additive
{
color.rgb = color.rgb + factor.rgb * color.a;
}
else if (mode == 3) // Color.Subtractive
{
color.rgb = color.rgb - factor.rgb * color.a;
}
else if (mode == 4) // Color.Replace
{
color.rgb = factor.rgb * color.a;
}
else if (mode == 5) // Color.MultiplyLuminance
{
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
}
else if (mode == 6) // Color.MultiplyAdditive
{
color.rgb = color.rgb * (1 + factor.rgb);
}
else if (mode == 7) // Color.HsvModifier
{
const float3 hsv = rgb_to_hsv(color.rgb);
color.rgb = hsv_to_rgb(hsv + factor.rgb) * color.a * factor.a;
color.a = inColor.a * factor.a;
}
else if (mode == 8) // 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;
}
if (0 < mode)
{
color = lerp(inColor, color, intensity);
color.a *= 1 - glow * intensity;
}
return color;
}
half4 apply_edge_color_filter(const half4 inColor, const half4 factor, const float intensity)
{
const float glow = _EdgeColorGlow;
const int mode = _EdgeColorFilter;
half4 color = inColor;
if (mode == 1) // Color.Multiply
{
color.rgb = color.rgb * factor.rgb;
}
else if (mode == 2) // Color.Additive
{
color.rgb = color.rgb + factor.rgb * color.a;
}
else if (mode == 3) // Color.Subtractive
{
color.rgb = color.rgb - factor.rgb * color.a;
}
else if (mode == 4) // Color.Replace
{
color.rgb = factor.rgb * color.a;
}
else if (mode == 5) // Color.MultiplyLuminance
{
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
}
else if (mode == 6) // Color.MultiplyAdditive
{
color.rgb = color.rgb * (1 + factor.rgb);
}
else if (mode == 7) // Color.HsvModifier
{
const float3 hsv = rgb_to_hsv(color.rgb);
color.rgb = hsv_to_rgb(hsv + factor.rgb) * color.a * factor.a;
color.a = inColor.a * factor.a;
}
else if (mode == 8) // 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;
}
if (0 < mode)
{
color = lerp(inColor, color, intensity);
color.a *= 1 - glow * intensity;
}
return color;
}
half4 apply_sampling_filter(float2 uv, const float4 uvMask, const float isShadow)
{
#if SAMPLING_BLUR_FAST || SAMPLING_BLUR_MEDIUM || SAMPLING_BLUR_DETAIL
@@ -505,7 +355,7 @@ half4 apply_transition_filter(half4 color, const float alpha, const float2 uvLoc
}
#elif TRANSITION_PATTERN // Transition.Pattern
{
const half4 patternColor = apply_transition_color_filter(half4(color.rgb, 1), half4(_TransitionColor.rgb * color.a, 1), _TransitionColor.a);
const half4 patternColor = apply_color_filter(_TransitionColorFilter, half4(color.rgb, 1), half4(_TransitionColor.rgb * color.a, 1), _TransitionColor.a, _TransitionColorGlow);
float isPattern = min(inv_lerp(_TransitionRange.x, _TransitionRange.y, uvLocal.x), 0.995) < (_TransitionPatternReverse ? alpha : 1 - alpha);
isPattern = _TransitionPatternReverse ? isPattern : 1 - isPattern;
const float patternFactor = _PatternArea == 0 ? 1 : _PatternArea == 1 ? 1 - edgeFactor : edgeFactor;
@@ -518,8 +368,8 @@ half4 apply_transition_filter(half4 color, const float alpha, const float2 uvLoc
const float softness = max(0.0001, _TransitionWidth * _TransitionSoftness);
const half bandLerp = saturate((_TransitionWidth - factor) * 2 / softness);
const half softLerp = saturate(factor * 2 / softness);
half4 bandColor = apply_transition_color_filter(half4(color.rgb, 1), half4(_TransitionColor.rgb, 1),
_TransitionColor.a);
half4 bandColor = apply_color_filter(_TransitionColorFilter, half4(color.rgb, 1),
half4(_TransitionColor.rgb, 1), _TransitionColor.a, _TransitionColorGlow);
bandColor *= color.a;
#if TRANSITION_MELT
@@ -605,42 +455,7 @@ half4 apply_gradation_filter(const half4 inColor, const float2 uvGrad)
}
#endif
const int mode = _GradationColorFilter;
const float intensity = _GradationIntensity;
half4 color = inColor;
if (mode == 1) // Color.Multiply
{
color.rgb = color.rgb * factor.rgb;
color *= factor.a;
}
else if (mode == 2) // Color.Additive
{
color.rgb = color.rgb + factor.rgb * color.a * factor.a;
}
else if (mode == 3) // Color.Subtractive
{
color.rgb = color.rgb - factor.rgb * color.a * factor.a;
}
else if (mode == 4) // Color.Replace
{
color.rgb = factor.rgb * color.a;
color *= factor.a;
}
else if (mode == 5) // Color.MultiplyLuminance
{
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb * factor.a / 2 * color.a;
}
else if (mode == 6) // Color.MultiplyAdditive
{
color.rgb = color.rgb * (1 + factor.rgb * factor.a);
}
if (0 < mode)
{
color = lerp(inColor, color, intensity);
}
return color;
return apply_color_filter(_GradationColorFilter, inColor, factor, _GradationIntensity, 0);
}
half4 apply_detail_filter(half4 color, float2 uvLocal)
@@ -750,20 +565,20 @@ half4 uieffect_internal(float2 uv, float4 uvMask, const float2 uvLocal, const fl
if (0 < isShadow)
{
return apply_shadow_color_filter(color, _ShadowColor, 1);
return apply_color_filter(_ShadowColorFilter, color, _ShadowColor, 1, _ShadowColorGlow);
}
else
{
#if EDGE_PLAIN || EDGE_SHINY
{
color = apply_color_filter(color, _ColorValue, _ColorIntensity);
const half4 edgeColor = apply_edge_color_filter(color, _EdgeColor, 1);
color = apply_color_filter(_ColorFilter, color, _ColorValue, _ColorIntensity, _ColorGlow);
const half4 edgeColor = apply_color_filter(_EdgeColorFilter, color, _EdgeColor, 1, _EdgeColorGlow);
const float isEdgeShiny = is_edge_shiny(uvLocal);
return lerp(color, edgeColor, edgeFactor * isEdgeShiny);
}
#else
{
return apply_color_filter(color, _ColorValue, _ColorIntensity);
return apply_color_filter(_ColorFilter, color, _ColorValue, _ColorIntensity, _ColorGlow);
}
#endif
}
+1 -1
View File
@@ -2,7 +2,7 @@
"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.9.7",
"version": "5.10.1",
"unity": "2020.3",
"license": "MIT",
"repository": {