mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-19 17:22:37 +08:00
feat: add EdgeMode feature
This commit is contained in:
@@ -81,6 +81,14 @@ namespace Coffee.UIEffects.Editors
|
||||
private SerializedProperty _gradationScale;
|
||||
private SerializedProperty _gradationRotation;
|
||||
|
||||
private SerializedProperty _edgeMode;
|
||||
private SerializedProperty _edgeWidth;
|
||||
private SerializedProperty _edgeColorFilter;
|
||||
private SerializedProperty _edgeColor;
|
||||
private SerializedProperty _edgeShinyWidth;
|
||||
private SerializedProperty _edgeShinyAutoPlaySpeed;
|
||||
private SerializedProperty _patternArea;
|
||||
|
||||
private bool _expandOthers = true;
|
||||
private SerializedProperty _allowToModifyMeshShape;
|
||||
|
||||
@@ -136,6 +144,14 @@ namespace Coffee.UIEffects.Editors
|
||||
_shadowColor = serializedObject.FindProperty("m_ShadowColor");
|
||||
_shadowColorGlow = serializedObject.FindProperty("m_ShadowColorGlow");
|
||||
|
||||
_edgeMode = serializedObject.FindProperty("m_EdgeMode");
|
||||
_edgeWidth = serializedObject.FindProperty("m_EdgeWidth");
|
||||
_edgeColorFilter = serializedObject.FindProperty("m_EdgeColorFilter");
|
||||
_edgeColor = serializedObject.FindProperty("m_EdgeColor");
|
||||
_edgeShinyWidth = serializedObject.FindProperty("m_EdgeShinyWidth");
|
||||
_edgeShinyAutoPlaySpeed = serializedObject.FindProperty("m_EdgeShinyAutoPlaySpeed");
|
||||
_patternArea = serializedObject.FindProperty("m_PatternArea");
|
||||
|
||||
_gradationMode = serializedObject.FindProperty("m_GradationMode");
|
||||
_gradationColor1 = serializedObject.FindProperty("m_GradationColor1");
|
||||
_gradationColor2 = serializedObject.FindProperty("m_GradationColor2");
|
||||
@@ -339,6 +355,32 @@ namespace Coffee.UIEffects.Editors
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
// Edge Mode
|
||||
DrawSeparator();
|
||||
if (DrawHeaderPopup(_edgeMode))
|
||||
{
|
||||
EditorGUILayout.PropertyField(_edgeWidth);
|
||||
prevColorFilter = (ColorFilter)_edgeColorFilter.intValue;
|
||||
EditorGUILayout.PropertyField(_edgeColorFilter);
|
||||
DrawColor(_edgeColorFilter, _edgeColor, prevColorFilter);
|
||||
|
||||
if ((EdgeMode)_edgeMode.intValue == EdgeMode.Shiny)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_edgeShinyWidth);
|
||||
EditorGUILayout.PropertyField(_edgeShinyAutoPlaySpeed);
|
||||
|
||||
if (!Mathf.Approximately(0, _edgeShinyAutoPlaySpeed.floatValue))
|
||||
{
|
||||
EditorApplication.QueuePlayerLoopUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
if (_transitionFilter.intValue == (int)TransitionFilter.Pattern)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_patternArea);
|
||||
}
|
||||
}
|
||||
|
||||
DrawSeparator();
|
||||
_expandOthers = EditorGUILayout.BeginFoldoutHeaderGroup(_expandOthers, "Others");
|
||||
if (_expandOthers)
|
||||
|
||||
@@ -76,6 +76,20 @@ namespace Coffee.UIEffects
|
||||
Mirror
|
||||
}
|
||||
|
||||
public enum EdgeMode
|
||||
{
|
||||
None = 0,
|
||||
Plain,
|
||||
Shiny
|
||||
}
|
||||
|
||||
public enum PatternArea
|
||||
{
|
||||
All = 0,
|
||||
Inner = 1,
|
||||
Edge = 2
|
||||
}
|
||||
|
||||
public enum GradationMode
|
||||
{
|
||||
None = 0,
|
||||
|
||||
@@ -171,6 +171,30 @@ namespace Coffee.UIEffects
|
||||
[SerializeField]
|
||||
protected bool m_AllowToModifyMeshShape = true;
|
||||
|
||||
[SerializeField]
|
||||
protected EdgeMode m_EdgeMode = EdgeMode.None;
|
||||
|
||||
[Range(0, 1)]
|
||||
[SerializeField]
|
||||
protected float m_EdgeWidth = 0.5f;
|
||||
|
||||
[SerializeField]
|
||||
protected ColorFilter m_EdgeColorFilter = ColorFilter.Replace;
|
||||
|
||||
[SerializeField]
|
||||
protected Color m_EdgeColor = Color.white;
|
||||
|
||||
[Range(0, 1)]
|
||||
[SerializeField]
|
||||
protected float m_EdgeShinyWidth = 0.5f;
|
||||
|
||||
[Range(-5, 5)]
|
||||
[SerializeField]
|
||||
protected float m_EdgeShinyAutoPlaySpeed = 1f;
|
||||
|
||||
[SerializeField]
|
||||
protected PatternArea m_PatternArea = PatternArea.Inner;
|
||||
|
||||
/// <summary>
|
||||
/// Tone filter for rendering.
|
||||
/// </summary>
|
||||
@@ -657,6 +681,86 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
public EdgeMode edgeMode
|
||||
{
|
||||
get => m_EdgeMode;
|
||||
set
|
||||
{
|
||||
if (m_EdgeMode == value) return;
|
||||
context.edgeMode = m_EdgeMode = value;
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float edgeWidth
|
||||
{
|
||||
get => m_EdgeWidth;
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (Mathf.Approximately(m_EdgeWidth, value)) return;
|
||||
context.edgeWidth = m_EdgeWidth = value;
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public ColorFilter edgeColorFilter
|
||||
{
|
||||
get => m_EdgeColorFilter;
|
||||
set
|
||||
{
|
||||
if (m_EdgeColorFilter == value) return;
|
||||
context.edgeColorFilter = m_EdgeColorFilter = value;
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public Color edgeColor
|
||||
{
|
||||
get => m_EdgeColor;
|
||||
set
|
||||
{
|
||||
if (m_EdgeColor == value) return;
|
||||
context.edgeColor = m_EdgeColor = value;
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float edgeShinyWidth
|
||||
{
|
||||
get => m_EdgeShinyWidth;
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, 0, 1);
|
||||
if (Mathf.Approximately(m_EdgeShinyWidth, value)) return;
|
||||
context.edgeShinyWidth = m_EdgeShinyWidth = value;
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float edgeShinyAutoPlaySpeed
|
||||
{
|
||||
get => m_EdgeShinyAutoPlaySpeed;
|
||||
set
|
||||
{
|
||||
value = Mathf.Clamp(value, -5, 5);
|
||||
if (Mathf.Approximately(m_EdgeShinyAutoPlaySpeed, value)) return;
|
||||
context.edgeShinyAutoPlaySpeed = m_EdgeShinyAutoPlaySpeed = value;
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public PatternArea patternArea
|
||||
{
|
||||
get => m_PatternArea;
|
||||
set
|
||||
{
|
||||
if (m_PatternArea == value) return;
|
||||
context.patternArea = m_PatternArea = value;
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public GradationMode gradationMode
|
||||
{
|
||||
get => m_GradationMode;
|
||||
@@ -842,6 +946,14 @@ namespace Coffee.UIEffects
|
||||
c.shadowColor = m_ShadowColor;
|
||||
c.shadowColorGlow = m_ShadowColorGlow;
|
||||
|
||||
c.edgeMode = m_EdgeMode;
|
||||
c.edgeWidth = m_EdgeWidth;
|
||||
c.edgeColorFilter = m_EdgeColorFilter;
|
||||
c.edgeColor = m_EdgeColor;
|
||||
c.edgeShinyWidth = m_EdgeShinyWidth;
|
||||
c.edgeShinyAutoPlaySpeed = m_EdgeShinyAutoPlaySpeed;
|
||||
c.patternArea = m_PatternArea;
|
||||
|
||||
c.gradationMode = m_GradationMode;
|
||||
c.gradationColor1 = m_GradationColor1;
|
||||
c.gradationColor2 = m_GradationColor2;
|
||||
@@ -968,6 +1080,14 @@ namespace Coffee.UIEffects
|
||||
m_ShadowColor = preset.m_ShadowColor;
|
||||
m_ShadowColorGlow = preset.m_ShadowColorGlow;
|
||||
|
||||
m_EdgeMode = preset.m_EdgeMode;
|
||||
m_EdgeWidth = preset.m_EdgeWidth;
|
||||
m_EdgeColorFilter = preset.m_EdgeColorFilter;
|
||||
m_EdgeColor = preset.m_EdgeColor;
|
||||
m_EdgeShinyWidth = preset.m_EdgeShinyWidth;
|
||||
m_EdgeShinyAutoPlaySpeed = preset.m_EdgeShinyAutoPlaySpeed;
|
||||
m_PatternArea = preset.m_PatternArea;
|
||||
|
||||
m_GradationMode = preset.m_GradationMode;
|
||||
m_GradationColor1 = preset.m_GradationColor1;
|
||||
m_GradationColor2 = preset.m_GradationColor2;
|
||||
@@ -1030,6 +1150,14 @@ namespace Coffee.UIEffects
|
||||
m_ShadowColor = c.shadowColor;
|
||||
m_ShadowColorGlow = c.shadowColorGlow;
|
||||
|
||||
m_EdgeMode = c.edgeMode;
|
||||
m_EdgeWidth = c.edgeWidth;
|
||||
m_EdgeColorFilter = c.edgeColorFilter;
|
||||
m_EdgeColor = c.edgeColor;
|
||||
m_EdgeShinyWidth = c.edgeShinyWidth;
|
||||
m_EdgeShinyAutoPlaySpeed = c.edgeShinyAutoPlaySpeed;
|
||||
m_PatternArea = c.patternArea;
|
||||
|
||||
m_GradationMode = c.gradationMode;
|
||||
m_GradationColor1 = c.gradationColor1;
|
||||
m_GradationColor2 = c.gradationColor2;
|
||||
|
||||
@@ -37,6 +37,11 @@ namespace Coffee.UIEffects
|
||||
private static readonly int s_ShadowColor = Shader.PropertyToID("_ShadowColor");
|
||||
private static readonly int s_ShadowBlurIntensity = Shader.PropertyToID("_ShadowBlurIntensity");
|
||||
private static readonly int s_ShadowColorGlow = Shader.PropertyToID("_ShadowColorGlow");
|
||||
private static readonly int s_EdgeWidth = Shader.PropertyToID("_EdgeWidth");
|
||||
private static readonly int s_EdgeColor = Shader.PropertyToID("_EdgeColor");
|
||||
private static readonly int s_EdgeShinyAutoPlaySpeed = Shader.PropertyToID("_EdgeShinyAutoPlaySpeed");
|
||||
private static readonly int s_EdgeShinyWidth = Shader.PropertyToID("_EdgeShinyWidth");
|
||||
private static readonly int s_PatternArea = Shader.PropertyToID("_PatternArea");
|
||||
|
||||
private static readonly string[] s_ToneKeywords =
|
||||
{
|
||||
@@ -118,6 +123,26 @@ namespace Coffee.UIEffects
|
||||
"SHADOW_COLOR_CONTRAST"
|
||||
};
|
||||
|
||||
private static readonly string[] s_EdgeKeywords =
|
||||
{
|
||||
"",
|
||||
"EDGE_PLAIN",
|
||||
"EDGE_SHINY"
|
||||
};
|
||||
|
||||
private static readonly string[] s_EdgeColorKeywords =
|
||||
{
|
||||
"",
|
||||
"EDGE_COLOR_MULTIPLY",
|
||||
"EDGE_COLOR_ADDITIVE",
|
||||
"EDGE_COLOR_SUBTRACTIVE",
|
||||
"EDGE_COLOR_REPLACE",
|
||||
"EDGE_COLOR_MULTIPLY_LUMINANCE",
|
||||
"EDGE_COLOR_MULTIPLY_ADDITIVE",
|
||||
"EDGE_COLOR_HSV_MODIFIER",
|
||||
"EDGE_COLOR_CONTRAST"
|
||||
};
|
||||
|
||||
private static readonly Vector2[][] s_ShadowVectors = new[]
|
||||
{
|
||||
Array.Empty<Vector2>(), // None
|
||||
@@ -177,6 +202,14 @@ namespace Coffee.UIEffects
|
||||
public Color shadowColor;
|
||||
public bool shadowColorGlow;
|
||||
|
||||
public EdgeMode edgeMode;
|
||||
public float edgeWidth;
|
||||
public ColorFilter edgeColorFilter;
|
||||
public Color edgeColor;
|
||||
public float edgeShinyWidth;
|
||||
public float edgeShinyAutoPlaySpeed;
|
||||
public PatternArea patternArea;
|
||||
|
||||
public GradationMode gradationMode;
|
||||
public Color gradationColor1;
|
||||
public Color gradationColor2;
|
||||
@@ -192,7 +225,8 @@ namespace Coffee.UIEffects
|
||||
|| colorFilter != ColorFilter.None
|
||||
|| srcBlendMode != BlendMode.One
|
||||
|| dstBlendMode != BlendMode.OneMinusSrcAlpha
|
||||
|| shadowMode != ShadowMode.None;
|
||||
|| shadowMode != ShadowMode.None
|
||||
|| edgeMode != EdgeMode.None;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
@@ -247,6 +281,14 @@ namespace Coffee.UIEffects
|
||||
shadowColor = preset.shadowColor;
|
||||
shadowColorGlow = preset.shadowColorGlow;
|
||||
|
||||
edgeMode = preset.edgeMode;
|
||||
edgeWidth = preset.edgeWidth;
|
||||
edgeColorFilter = preset.edgeColorFilter;
|
||||
edgeColor = preset.edgeColor;
|
||||
edgeShinyAutoPlaySpeed = preset.edgeShinyAutoPlaySpeed;
|
||||
edgeShinyWidth = preset.edgeShinyWidth;
|
||||
patternArea = preset.patternArea;
|
||||
|
||||
gradationMode = preset.gradationMode;
|
||||
gradationColor1 = preset.gradationColor1;
|
||||
gradationColor2 = preset.gradationColor2;
|
||||
@@ -312,6 +354,12 @@ namespace Coffee.UIEffects
|
||||
material.SetColor(s_ShadowColor, shadowColor);
|
||||
material.SetInt(s_ShadowColorGlow, shadowColorGlow ? 1 : 0);
|
||||
|
||||
material.SetFloat(s_EdgeWidth, Mathf.Clamp01(edgeWidth));
|
||||
material.SetColor(s_EdgeColor, edgeColor);
|
||||
material.SetFloat(s_EdgeShinyWidth, Mathf.Clamp01(edgeShinyWidth));
|
||||
material.SetFloat(s_EdgeShinyAutoPlaySpeed, edgeShinyAutoPlaySpeed);
|
||||
material.SetInt(s_PatternArea, edgeMode != EdgeMode.None ? (int)patternArea : 0);
|
||||
|
||||
SetKeyword(material, s_ToneKeywords, (int)toneFilter);
|
||||
SetKeyword(material, s_ColorKeywords, (int)colorFilter);
|
||||
SetKeyword(material, s_SamplingKeywords, (int)samplingFilter);
|
||||
@@ -323,11 +371,7 @@ namespace Coffee.UIEffects
|
||||
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:
|
||||
default:
|
||||
SetKeyword(material, s_TransitionColorKeywords, (int)transitionColorFilter);
|
||||
break;
|
||||
}
|
||||
@@ -342,6 +386,19 @@ namespace Coffee.UIEffects
|
||||
break;
|
||||
}
|
||||
|
||||
SetKeyword(material, s_EdgeKeywords, (int)edgeMode);
|
||||
|
||||
switch (edgeMode)
|
||||
{
|
||||
case EdgeMode.None:
|
||||
SetKeyword(material, s_EdgeColorKeywords, (int)ColorFilter.None);
|
||||
break;
|
||||
default:
|
||||
SetKeyword(material, s_EdgeColorKeywords, (int)edgeColorFilter);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
SetKeyword(material, s_TargetKeywords, (int)targetMode);
|
||||
|
||||
Profiler.EndSample();
|
||||
|
||||
@@ -1,28 +1,36 @@
|
||||
#ifndef UI_EFFECT_INCLUDED
|
||||
#define UI_EFFECT_INCLUDED
|
||||
|
||||
uniform float4 _MainTex_TexelSize;
|
||||
uniform float _ToneIntensity;
|
||||
uniform half4 _ColorValue;
|
||||
uniform float _ColorIntensity;
|
||||
uniform int _ColorGlow;
|
||||
uniform float _SamplingIntensity;
|
||||
uniform float _SamplingWidth;
|
||||
uniform float _SamplingScale;
|
||||
uniform sampler2D _TransitionTex;
|
||||
uniform float4 _TransitionTex_ST;
|
||||
uniform float _TransitionRate;
|
||||
uniform int _TransitionReverse;
|
||||
uniform half4 _TransitionColor;
|
||||
uniform int _TransitionColorGlow;
|
||||
uniform float _TransitionSoftness;
|
||||
uniform float _TransitionWidth;
|
||||
uniform fixed4 _TargetColor;
|
||||
uniform float _TargetRange;
|
||||
uniform float _TargetSoftness;
|
||||
uniform float _ShadowBlurIntensity;
|
||||
uniform half4 _ShadowColor;
|
||||
uniform int _ShadowColorGlow;
|
||||
uniform const float4 _MainTex_TexelSize;
|
||||
uniform const float _ToneIntensity;
|
||||
uniform const half4 _ColorValue;
|
||||
uniform const float _ColorIntensity;
|
||||
uniform const int _ColorGlow;
|
||||
uniform const float _SamplingIntensity;
|
||||
uniform const float _SamplingWidth;
|
||||
uniform const float _SamplingScale;
|
||||
uniform const sampler2D _TransitionTex;
|
||||
uniform const float4 _TransitionTex_ST;
|
||||
uniform const float _TransitionRate;
|
||||
uniform const int _TransitionReverse;
|
||||
uniform const half4 _TransitionColor;
|
||||
uniform const int _TransitionColorGlow;
|
||||
uniform const float _TransitionSoftness;
|
||||
uniform const float2 _TransitionRange;
|
||||
uniform const float _TransitionWidth;
|
||||
uniform const int _TransitionPatternReverse;
|
||||
uniform const float _TransitionAutoPlaySpeed;
|
||||
uniform const fixed4 _TargetColor;
|
||||
uniform const float _TargetRange;
|
||||
uniform const float _TargetSoftness;
|
||||
uniform const float _ShadowBlurIntensity;
|
||||
uniform const half4 _ShadowColor;
|
||||
uniform const int _ShadowColorGlow;
|
||||
uniform const float _EdgeWidth;
|
||||
uniform const float _EdgeShinyAutoPlaySpeed;
|
||||
uniform const float _EdgeShinyWidth;
|
||||
uniform const half4 _EdgeColor;
|
||||
uniform const int _PatternArea;
|
||||
|
||||
#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
|
||||
@@ -30,6 +38,8 @@ uniform int _ShadowColorGlow;
|
||||
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN TRANSITION_PATTERN
|
||||
#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 _ SHADOW_COLOR_MULTIPLY SHADOW_COLOR_ADDITIVE SHADOW_COLOR_SUBTRACTIVE SHADOW_COLOR_REPLACE SHADOW_COLOR_MULTIPLY_LUMINANCE SHADOW_COLOR_MULTIPLY_ADDITIVE SHADOW_COLOR_HSV_MODIFIER SHADOW_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ EDGE_PLAIN EDGE_SHINY
|
||||
#pragma shader_feature_local_fragment _ EDGE_COLOR_MULTIPLY EDGE_COLOR_ADDITIVE EDGE_COLOR_SUBTRACTIVE EDGE_COLOR_REPLACE EDGE_COLOR_MULTIPLY_LUMINANCE EDGE_COLOR_MULTIPLY_ADDITIVE EDGE_COLOR_HSV_MODIFIER EDGE_COLOR_CONTRAST
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
|
||||
// For performance reasons, limit the sampling of blur in TextMeshPro.
|
||||
@@ -299,6 +309,57 @@ half4 apply_shadow_color_filter(half4 color, const half4 factor, const float int
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_edge_color_filter(half4 color, const half4 factor, const float intensity)
|
||||
{
|
||||
const half4 inColor = color;
|
||||
#if EDGE_COLOR_NONE // Color.None
|
||||
{
|
||||
return color;
|
||||
}
|
||||
#elif EDGE_COLOR_MULTIPLY // Color.Multiply
|
||||
{
|
||||
color.rgb = color.rgb * factor.rgb;
|
||||
}
|
||||
#elif EDGE_COLOR_ADDITIVE // Color.Additive
|
||||
{
|
||||
color.rgb = color.rgb + factor.rgb * color.a;
|
||||
}
|
||||
#elif EDGE_COLOR_SUBTRACTIVE // Color.Subtractive
|
||||
{
|
||||
color.rgb = color.rgb - factor.rgb * color.a;
|
||||
}
|
||||
#elif EDGE_COLOR_REPLACE // Color.Replace
|
||||
{
|
||||
color.rgb = factor.rgb * color.a;
|
||||
}
|
||||
#elif EDGE_COLOR_MULTIPLY_LUMINANCE // Color.MultiplyLuminance
|
||||
{
|
||||
color.rgb = (1 + Luminance(color.rgb)) * factor.rgb / 2 * color.a;
|
||||
}
|
||||
#elif EDGE_COLOR_MULTIPLY_ADDITIVE // Color.MultiplyAdditive
|
||||
{
|
||||
color.rgb = color.rgb * (1 + factor.rgb);
|
||||
}
|
||||
#elif EDGE_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 EDGE_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;
|
||||
}
|
||||
#else
|
||||
{
|
||||
return color;
|
||||
}
|
||||
#endif
|
||||
color = lerp(inColor, color, intensity);
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_sampling_filter(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
{
|
||||
#if SAMPLING_BLUR_FAST || SAMPLING_BLUR_MEDIUM || SAMPLING_BLUR_DETAIL
|
||||
@@ -435,9 +496,46 @@ half to_value(float4 c)
|
||||
return 0;
|
||||
}
|
||||
|
||||
float edge(float2 uv, const float4 uvMask, float width)
|
||||
{
|
||||
#if EDGE_PLAIN || EDGE_SHINY
|
||||
const float2 d = texel_size() * lerp(1, 20, width);
|
||||
float e = 1.0;
|
||||
|
||||
// Minimum alpha around the current pixel (12 neighbors)
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(1.0, 0.0)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(0.866025, 0.5)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(0.5, 0.866025)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(0.0, 1.0)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(-0.5, 0.866025)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(-0.866025, 0.5)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(-1.0, 0.0)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(-0.866025, -0.5)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(-0.5, -0.866025)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(0.0, -1.0)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(0.5, -0.866025)), uvMask)).a);
|
||||
e = min(e, (TEX_SAMPLE_CLAMP((uv + d * float2(0.866025, -0.5)), uvMask)).a);
|
||||
|
||||
return 1 - inv_lerp(0.15, 0.3, e);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int is_edge_shiny(const float2 uvLocal)
|
||||
{
|
||||
#if EDGE_SHINY
|
||||
const float deg = atan2(uvLocal.y - 0.5, uvLocal.x - 0.5) / UNITY_PI;
|
||||
return frac(_Time.y * _EdgeShinyAutoPlaySpeed + deg) < _EdgeShinyWidth;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
half4 uieffect_internal(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
{
|
||||
const half alpha = transition_alpha(uvLocal);
|
||||
const float edgeFactor = edge(uv, uvMask, _EdgeWidth);
|
||||
uv += move_transition_filter(uvMask, alpha);
|
||||
half4 color = apply_sampling_filter(uv, uvMask, uvLocal);
|
||||
color = apply_tone_filter(color);
|
||||
@@ -445,14 +543,23 @@ half4 uieffect_internal(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
|
||||
if (-4 <= uvLocal.x + uvLocal.y)
|
||||
{
|
||||
color = apply_color_filter(color, _ColorValue, _ColorIntensity);
|
||||
#if EDGE_PLAIN || EDGE_SHINY
|
||||
{
|
||||
color = apply_color_filter(color, _ColorValue, _ColorIntensity);
|
||||
const half4 edgeColor = apply_edge_color_filter(color, _EdgeColor, 1);
|
||||
const int isEdgeShiny = is_edge_shiny(uvLocal);
|
||||
return lerp(color, edgeColor, edgeFactor * isEdgeShiny);
|
||||
}
|
||||
#else
|
||||
{
|
||||
return apply_color_filter(color, _ColorValue, _ColorIntensity);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
color = apply_shadow_color_filter(color, _ShadowColor, 1);
|
||||
return apply_shadow_color_filter(color, _ShadowColor, 1);
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 uieffect(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
|
||||
Reference in New Issue
Block a user