mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-19 17:22:37 +08:00
feat: calculate the normalized position on the shader side
With this change, UIEffect becomes up to 50% faster. Additionally, gradients are rendered more beautifully. close #323, close #324
This commit is contained in:
@@ -9,7 +9,7 @@ using Debug = UnityEngine.Debug;
|
||||
|
||||
internal static class TextMeshProSupport
|
||||
{
|
||||
private const string k_Version = "userData: v5.6.0";
|
||||
private const string k_Version = "userData: v5.7.0";
|
||||
private const string k_VersionUnity6 = k_Version + " (Unity 6)";
|
||||
|
||||
private static readonly Dictionary<string, string> s_FileGuids = new Dictionary<string, string>()
|
||||
|
||||
@@ -548,7 +548,6 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (Mathf.Approximately(m_TransitionRotation, value)) return;
|
||||
context.transitionRotation = m_TransitionRotation = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -559,7 +558,6 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (m_TransitionKeepAspectRatio == value) return;
|
||||
context.transitionKeepAspectRatio = m_TransitionKeepAspectRatio = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1156,7 +1154,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (m_GradationMode == value) return;
|
||||
context.gradationMode = m_GradationMode = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1167,7 +1165,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (m_GradationColor1 == value) return;
|
||||
context.gradationColor1 = m_GradationColor1 = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1178,7 +1176,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (m_GradationColor2 == value) return;
|
||||
context.gradationColor2 = m_GradationColor2 = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1189,7 +1187,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (m_GradationColor3 == value) return;
|
||||
context.gradationColor3 = m_GradationColor3 = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1200,7 +1198,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (m_GradationColor4 == value) return;
|
||||
context.gradationColor4 = m_GradationColor4 = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1211,7 +1209,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (Mathf.Approximately(m_GradationOffset, value)) return;
|
||||
context.gradationOffset = m_GradationOffset = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1222,7 +1220,7 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (Mathf.Approximately(m_GradationScale, value)) return;
|
||||
context.gradationScale = m_GradationScale = value;
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1234,7 +1232,6 @@ namespace Coffee.UIEffects
|
||||
value = Mathf.Repeat(value, 360);
|
||||
if (Mathf.Approximately(m_GradationRotation, value)) return;
|
||||
context.gradationRotation = m_GradationRotation = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1334,7 +1331,6 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
if (m_CustomRoot == value) return;
|
||||
m_CustomRoot = value;
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1353,11 +1349,58 @@ namespace Coffee.UIEffects
|
||||
? m_CustomRoot
|
||||
: transform as RectTransform;
|
||||
|
||||
private Texture2D _gradationRampTex;
|
||||
private bool _isGradientDirty = true;
|
||||
|
||||
private static readonly Color32[] s_Colors = new Color32[256];
|
||||
|
||||
private static readonly InternalObjectPool<Texture2D> s_TexturePool = new InternalObjectPool<Texture2D>(
|
||||
() =>
|
||||
{
|
||||
var w = 256;
|
||||
var texture = new Texture2D(w, 1, TextureFormat.RGBA32, false, false)
|
||||
{
|
||||
name = "GradationRamp",
|
||||
hideFlags = HideFlags.DontSave,
|
||||
wrapMode = TextureWrapMode.Repeat,
|
||||
anisoLevel = 0
|
||||
};
|
||||
|
||||
return texture;
|
||||
},
|
||||
texture => texture,
|
||||
texture => { });
|
||||
|
||||
private Texture2D gradationRampTex
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_gradationRampTex) _gradationRampTex = s_TexturePool.Rent();
|
||||
if (!_isGradientDirty) return _gradationRampTex;
|
||||
_isGradientDirty = false;
|
||||
|
||||
var w = _gradationRampTex.width;
|
||||
for (var i = 0; i < w; i++)
|
||||
{
|
||||
s_Colors[i] = m_GradationGradient.Evaluate((float)i / (w - 1));
|
||||
}
|
||||
|
||||
_gradationRampTex.filterMode = m_GradationGradient.mode == GradientMode.Blend
|
||||
? FilterMode.Bilinear
|
||||
: FilterMode.Point;
|
||||
|
||||
_gradationRampTex.SetPixels32(s_Colors);
|
||||
_gradationRampTex.Apply();
|
||||
return _gradationRampTex;
|
||||
}
|
||||
}
|
||||
|
||||
public List<UIEffectReplica> replicas => _replicas ??= InternalListPool<UIEffectReplica>.Rent();
|
||||
private List<UIEffectReplica> _replicas;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_isGradientDirty = true;
|
||||
(m_SrcBlendMode, m_DstBlendMode) = (m_BlendType, m_SrcBlendMode, m_DstBlendMode).Convert();
|
||||
base.OnEnable();
|
||||
SetMaterialDirty();
|
||||
@@ -1372,6 +1415,7 @@ namespace Coffee.UIEffects
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
InternalListPool<UIEffectReplica>.Return(ref _replicas);
|
||||
s_TexturePool.Return(ref _gradationRampTex);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@@ -1380,6 +1424,7 @@ namespace Coffee.UIEffects
|
||||
(m_SrcBlendMode, m_DstBlendMode) = (m_BlendType, m_SrcBlendMode, m_DstBlendMode).Convert();
|
||||
context?.SetGradationDirty();
|
||||
base.OnValidate();
|
||||
_isGradientDirty = true;
|
||||
}
|
||||
|
||||
internal override void SetEnablePreviewIfSelected(GameObject[] selection)
|
||||
@@ -1397,15 +1442,6 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
#endif
|
||||
|
||||
protected override void OnBeforeCanvasRebuild()
|
||||
{
|
||||
base.OnBeforeCanvasRebuild();
|
||||
if (CheckTransformChangedWith(customRoot))
|
||||
{
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetVerticesDirty()
|
||||
{
|
||||
base.SetVerticesDirty();
|
||||
@@ -1426,17 +1462,26 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set gradation gradient's keys.
|
||||
/// </summary>
|
||||
public void SetGradientKeys(Gradient gradient)
|
||||
{
|
||||
SetGradientKeys(gradient.colorKeys, gradient.alphaKeys, gradient.mode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set gradation gradient's keys.
|
||||
/// </summary>
|
||||
public void SetGradientKeys(GradientColorKey[] colorKeys, GradientAlphaKey[] alphaKeys,
|
||||
GradientMode mode = GradientMode.Blend)
|
||||
{
|
||||
_isGradientDirty = true;
|
||||
m_GradationGradient ??= new Gradient();
|
||||
m_GradationGradient.SetKeys(colorKeys, alphaKeys);
|
||||
m_GradationGradient.mode = mode;
|
||||
context?.SetGradationDirty();
|
||||
SetVerticesDirty();
|
||||
SetMaterialDirty();
|
||||
}
|
||||
|
||||
internal override void UpdateContext(UIEffectContext c)
|
||||
@@ -1505,7 +1550,7 @@ namespace Coffee.UIEffects
|
||||
c.gradationColor2 = m_GradationColor2;
|
||||
c.gradationColor3 = m_GradationColor3;
|
||||
c.gradationColor4 = m_GradationColor4;
|
||||
c.gradationGradient = m_GradationGradient;
|
||||
c.gradationTex = gradationRampTex;
|
||||
c.gradationOffset = m_GradationOffset;
|
||||
c.gradationScale = m_GradationScale;
|
||||
c.gradationRotation = m_GradationRotation;
|
||||
@@ -1706,9 +1751,7 @@ namespace Coffee.UIEffects
|
||||
m_GradationColor2 = preset.m_GradationColor2;
|
||||
m_GradationColor3 = preset.m_GradationColor3;
|
||||
m_GradationColor4 = preset.m_GradationColor4;
|
||||
m_GradationGradient = new Gradient();
|
||||
m_GradationGradient.SetKeys(preset.m_GradationGradient.colorKeys, preset.m_GradationGradient.alphaKeys);
|
||||
m_GradationGradient.mode = preset.m_GradationGradient.mode;
|
||||
SetGradientKeys(preset.m_GradationGradient);
|
||||
m_GradationOffset = preset.m_GradationOffset;
|
||||
m_GradationScale = preset.m_GradationScale;
|
||||
m_GradationRotation = preset.m_GradationRotation;
|
||||
@@ -1798,9 +1841,6 @@ namespace Coffee.UIEffects
|
||||
m_GradationColor2 = c.gradationColor2;
|
||||
m_GradationColor3 = c.gradationColor3;
|
||||
m_GradationColor4 = c.gradationColor4;
|
||||
m_GradationGradient = new Gradient();
|
||||
m_GradationGradient.SetKeys(c.gradationGradient.colorKeys, c.gradationGradient.alphaKeys);
|
||||
m_GradationGradient.mode = c.gradationGradient.mode;
|
||||
m_GradationOffset = c.gradationOffset;
|
||||
m_GradationScale = c.gradationScale;
|
||||
m_GradationRotation = c.gradationRotation;
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Coffee.UIEffects
|
||||
private Material _material;
|
||||
private UIEffectContext _context;
|
||||
private Action _onBeforeCanvasRebuild;
|
||||
private Action _onAfterCanvasRebuild;
|
||||
private bool _canModifyMesh;
|
||||
private Matrix4x4 _prevTransformHash;
|
||||
|
||||
@@ -46,6 +47,19 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
protected Material GetCurrentMaterial()
|
||||
{
|
||||
if (!isActiveAndEnabled) return null;
|
||||
|
||||
var g = graphic;
|
||||
if (!g) return null;
|
||||
|
||||
var canvasRenderer = g.canvasRenderer;
|
||||
if (!canvasRenderer || canvasRenderer.materialCount == 0) return null;
|
||||
|
||||
return canvasRenderer.GetMaterial();
|
||||
}
|
||||
|
||||
public virtual RectTransform transitionRoot => transform as RectTransform;
|
||||
|
||||
public virtual Flip flip
|
||||
@@ -57,7 +71,9 @@ namespace Coffee.UIEffects
|
||||
protected override void OnEnable()
|
||||
{
|
||||
_onBeforeCanvasRebuild ??= OnBeforeCanvasRebuild;
|
||||
_onAfterCanvasRebuild ??= OnAfterCanvasRebuild;
|
||||
UIExtraCallbacks.onBeforeCanvasRebuild += _onBeforeCanvasRebuild;
|
||||
UIExtraCallbacks.onAfterCanvasRebuild += _onAfterCanvasRebuild;
|
||||
UpdateContext(context);
|
||||
SetMaterialDirty();
|
||||
SetVerticesDirty();
|
||||
@@ -70,6 +86,11 @@ namespace Coffee.UIEffects
|
||||
UIExtraCallbacks.onBeforeCanvasRebuild -= _onBeforeCanvasRebuild;
|
||||
}
|
||||
|
||||
if (_onAfterCanvasRebuild != null)
|
||||
{
|
||||
UIExtraCallbacks.onAfterCanvasRebuild -= _onAfterCanvasRebuild;
|
||||
}
|
||||
|
||||
MaterialRepository.Release(ref _material);
|
||||
SetMaterialDirty();
|
||||
SetVerticesDirty();
|
||||
@@ -90,6 +111,13 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnAfterCanvasRebuild()
|
||||
{
|
||||
if (!_material || !graphic || context == null) return;
|
||||
|
||||
context.UpdateViewMatrix(GetCurrentMaterial(), transitionRoot, graphic.canvas.rootCanvas, flip);
|
||||
}
|
||||
|
||||
public void ModifyMesh(Mesh mesh)
|
||||
{
|
||||
}
|
||||
@@ -127,7 +155,8 @@ namespace Coffee.UIEffects
|
||||
|
||||
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial");
|
||||
var samplingScaleId = (uint)(Mathf.InverseLerp(0.01f, 100, actualSamplingScale) * uint.MaxValue);
|
||||
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, samplingScaleId, 0);
|
||||
var rootId = (uint)(transitionRoot ? transitionRoot.GetInstanceID() : 0);
|
||||
var hash = new Hash128((uint)baseMaterial.GetInstanceID(), effectId, samplingScaleId, rootId);
|
||||
if (!MaterialRepository.Valid(hash, _material))
|
||||
{
|
||||
Profiler.BeginSample("(UIE)[UIEffect] GetModifiedMaterial > Get or create material");
|
||||
@@ -198,14 +227,6 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
protected bool CheckTransformChangedWith(Transform root)
|
||||
{
|
||||
var sensitivity = UIEffectProjectSettings.transformSensitivity;
|
||||
return root
|
||||
&& root != transform
|
||||
&& transform.HasChanged(root, ref _prevTransformHash, sensitivity);
|
||||
}
|
||||
|
||||
internal void ReleaseMaterial()
|
||||
{
|
||||
MaterialRepository.Release(ref _material);
|
||||
|
||||
@@ -53,6 +53,15 @@ namespace Coffee.UIEffects
|
||||
private static readonly int s_DetailTex = Shader.PropertyToID("_DetailTex");
|
||||
private static readonly int s_DetailTex_ST = Shader.PropertyToID("_DetailTex_ST");
|
||||
private static readonly int s_DetailTex_Speed = Shader.PropertyToID("_DetailTex_Speed");
|
||||
private static readonly int s_GradationColor1 = Shader.PropertyToID("_GradationColor1");
|
||||
private static readonly int s_GradationColor2 = Shader.PropertyToID("_GradationColor2");
|
||||
private static readonly int s_GradationColor3 = Shader.PropertyToID("_GradationColor3");
|
||||
private static readonly int s_GradationColor4 = Shader.PropertyToID("_GradationColor4");
|
||||
private static readonly int s_GradationTex = Shader.PropertyToID("_GradationTex");
|
||||
private static readonly int s_GradationTex_ST = Shader.PropertyToID("_GradationTex_ST");
|
||||
private static readonly int s_RootViewMatrix = Shader.PropertyToID("_RootViewMatrix");
|
||||
private static readonly int s_GradViewMatrix = Shader.PropertyToID("_GradViewMatrix");
|
||||
private static readonly int s_CanvasToWorldMatrix = Shader.PropertyToID("_CanvasToWorldMatrix");
|
||||
|
||||
private static readonly string[] s_ToneKeywords =
|
||||
{
|
||||
@@ -165,6 +174,15 @@ namespace Coffee.UIEffects
|
||||
"DETAIL_MULTIPLY_ADDITIVE"
|
||||
};
|
||||
|
||||
private static readonly string[] s_GradationKeywords =
|
||||
{
|
||||
"",
|
||||
"GRADATION_GRADIENT",
|
||||
"GRADATION_RADIAL",
|
||||
"GRADATION_COLOR2",
|
||||
"GRADATION_COLOR4"
|
||||
};
|
||||
|
||||
private static readonly Vector2[][] s_ShadowVectors = new[]
|
||||
{
|
||||
Array.Empty<Vector2>(), // None
|
||||
@@ -178,7 +196,7 @@ namespace Coffee.UIEffects
|
||||
} // Outline8
|
||||
};
|
||||
|
||||
public static Func<UIVertex, Rect, float, float, UIVertex> onModifyVertex;
|
||||
public static Func<UIVertex, Rect, UIVertex> onModifyVertex;
|
||||
public ToneFilter toneFilter = ToneFilter.None;
|
||||
public float toneIntensity = 1;
|
||||
public Vector4 toneParams = new Vector4(0, 0, 0, 0);
|
||||
@@ -243,7 +261,7 @@ namespace Coffee.UIEffects
|
||||
public Color gradationColor2;
|
||||
public Color gradationColor3;
|
||||
public Color gradationColor4;
|
||||
public Gradient gradationGradient;
|
||||
public Texture2D gradationTex;
|
||||
public float gradationOffset;
|
||||
public float gradationScale;
|
||||
public float gradationRotation;
|
||||
@@ -265,10 +283,10 @@ namespace Coffee.UIEffects
|
||||
|| dstBlendMode != BlendMode.OneMinusSrcAlpha
|
||||
|| shadowMode != ShadowMode.None
|
||||
|| edgeMode != EdgeMode.None
|
||||
|| detailFilter != DetailFilter.None;
|
||||
|| detailFilter != DetailFilter.None
|
||||
|| gradationMode != GradationMode.None;
|
||||
|
||||
public bool willModifyVertex => willModifyMaterial
|
||||
|| gradationMode != GradationMode.None;
|
||||
public bool willModifyVertex => willModifyMaterial;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
@@ -276,7 +294,7 @@ namespace Coffee.UIEffects
|
||||
CopyFrom(s_DefaultContext);
|
||||
}
|
||||
|
||||
public void CopyFrom(UIEffectContext preset)
|
||||
private void CopyFrom(UIEffectContext preset)
|
||||
{
|
||||
toneFilter = preset.toneFilter;
|
||||
toneIntensity = preset.toneIntensity;
|
||||
@@ -342,9 +360,9 @@ namespace Coffee.UIEffects
|
||||
gradationColor2 = preset.gradationColor2;
|
||||
gradationColor3 = preset.gradationColor3;
|
||||
gradationColor4 = preset.gradationColor4;
|
||||
gradationGradient = preset.gradationGradient;
|
||||
gradationOffset = preset.gradationOffset;
|
||||
gradationTex = preset.gradationTex;
|
||||
gradationScale = preset.gradationScale;
|
||||
gradationOffset = preset.gradationOffset;
|
||||
gradationRotation = preset.gradationRotation;
|
||||
|
||||
detailFilter = preset.detailFilter;
|
||||
@@ -424,6 +442,14 @@ namespace Coffee.UIEffects
|
||||
material.SetFloat(s_EdgeShinyAutoPlaySpeed, edgeShinyAutoPlaySpeed);
|
||||
material.SetInt(s_PatternArea, edgeMode != EdgeMode.None ? (int)patternArea : 0);
|
||||
|
||||
material.SetTexture(s_GradationTex, gradationMode != 0 ? gradationTex : null);
|
||||
material.SetVector(s_GradationTex_ST, GetGradationScaleAndOffset());
|
||||
|
||||
material.SetColor(s_GradationColor1, gradationColor1);
|
||||
material.SetColor(s_GradationColor2, gradationColor2);
|
||||
material.SetColor(s_GradationColor3, gradationColor3);
|
||||
material.SetColor(s_GradationColor4, gradationColor4);
|
||||
|
||||
material.SetFloat(s_DetailIntensity, Mathf.Clamp01(detailIntensity));
|
||||
material.SetVector(s_DetailThreshold, new Vector2(detailThreshold.min, detailThreshold.max));
|
||||
material.SetTexture(s_DetailTex, detailFilter != 0 ? detailTex : null);
|
||||
@@ -474,6 +500,32 @@ namespace Coffee.UIEffects
|
||||
|
||||
SetKeyword(material, s_TargetKeywords, (int)targetMode);
|
||||
|
||||
switch (gradationMode)
|
||||
{
|
||||
case GradationMode.None:
|
||||
SetKeyword(material, s_GradationKeywords, 0);
|
||||
break;
|
||||
case GradationMode.HorizontalGradient:
|
||||
case GradationMode.VerticalGradient:
|
||||
case GradationMode.AngleGradient:
|
||||
SetKeyword(material, s_GradationKeywords, 1);
|
||||
break;
|
||||
case GradationMode.RadialFast:
|
||||
case GradationMode.RadialDetail:
|
||||
SetKeyword(material, s_GradationKeywords, 2);
|
||||
break;
|
||||
case GradationMode.Horizontal:
|
||||
case GradationMode.Vertical:
|
||||
case GradationMode.DiagonalToRightBottom:
|
||||
case GradationMode.DiagonalToLeftBottom:
|
||||
case GradationMode.Angle:
|
||||
SetKeyword(material, s_GradationKeywords, 3);
|
||||
break;
|
||||
case GradationMode.Diagonal:
|
||||
SetKeyword(material, s_GradationKeywords, 4);
|
||||
break;
|
||||
}
|
||||
|
||||
Profiler.EndSample();
|
||||
}
|
||||
|
||||
@@ -486,6 +538,92 @@ namespace Coffee.UIEffects
|
||||
material.SetFloat(s_EdgeShinyAutoPlaySpeed, enable ? edgeShinyAutoPlaySpeed : 0);
|
||||
}
|
||||
|
||||
public void UpdateViewMatrix(Material material, RectTransform transitionRoot, Canvas canvas, Flip flip)
|
||||
{
|
||||
if (!material) return;
|
||||
|
||||
var size = transitionRoot.rect.size;
|
||||
var scale = new Vector3(1f / size.x, 1f / size.y, 1f);
|
||||
if (transitionKeepAspectRatio && !Mathf.Approximately(scale.x, scale.y))
|
||||
{
|
||||
scale.x = scale.y = Mathf.Min(scale.x, scale.y);
|
||||
}
|
||||
|
||||
if (0 != (flip & Flip.Effect))
|
||||
{
|
||||
scale.x = 0 != (flip & Flip.Horizontal) ? -scale.x : scale.x;
|
||||
scale.y = 0 != (flip & Flip.Vertical) ? -scale.y : scale.y;
|
||||
}
|
||||
|
||||
var pivot = new Vector2(0.5f, 0.5f);
|
||||
var offset = (transitionRoot.pivot - pivot) * size;
|
||||
var w2LMat = Matrix4x4.Translate(offset) * transitionRoot.worldToLocalMatrix;
|
||||
|
||||
var rootRotation = Quaternion.Euler(0, 0, transitionRotation);
|
||||
var rootScale = 1f / GetMultiplier(transitionRotation);
|
||||
material.SetMatrix(s_RootViewMatrix, Matrix4x4.TRS(pivot, rootRotation, scale * rootScale) * w2LMat);
|
||||
|
||||
var gradRotation = Quaternion.Euler(0, 0, GetGradationRotation());
|
||||
var gradScale = 1f / GetMultiplier(GetGradationRotation());
|
||||
material.SetMatrix(s_GradViewMatrix, Matrix4x4.TRS(pivot, gradRotation, scale * gradScale) * w2LMat);
|
||||
|
||||
if (canvas.renderMode == RenderMode.ScreenSpaceOverlay || !canvas.worldCamera)
|
||||
{
|
||||
material.SetMatrix(s_CanvasToWorldMatrix, canvas.transform.localToWorldMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.SetMatrix(s_CanvasToWorldMatrix, Matrix4x4.identity);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector4 GetGradationScaleAndOffset()
|
||||
{
|
||||
var gScale = 1 / gradationScale;
|
||||
switch (gradationMode)
|
||||
{
|
||||
case GradationMode.HorizontalGradient:
|
||||
case GradationMode.VerticalGradient:
|
||||
case GradationMode.AngleGradient:
|
||||
return new Vector4(gScale, 1, -0.5f * (gScale + 1) - gradationOffset, 0);
|
||||
case GradationMode.RadialFast:
|
||||
case GradationMode.RadialDetail:
|
||||
{
|
||||
return new Vector4(gScale, 1, gradationOffset, 0);
|
||||
}
|
||||
default:
|
||||
return new Vector4(gScale, 1, gradationOffset * (gScale + 1) / 2 - gScale * 0.5f + 0.5f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private float GetGradationRotation()
|
||||
{
|
||||
switch (gradationMode)
|
||||
{
|
||||
case GradationMode.DiagonalToLeftBottom:
|
||||
return 135;
|
||||
case GradationMode.DiagonalToRightBottom:
|
||||
return 45;
|
||||
case GradationMode.Vertical:
|
||||
return 90;
|
||||
case GradationMode.VerticalGradient:
|
||||
return -90;
|
||||
case GradationMode.Angle:
|
||||
case GradationMode.AngleGradient:
|
||||
return gradationRotation;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static float GetMultiplier(float deg)
|
||||
{
|
||||
var rad = Mathf.Deg2Rad * deg;
|
||||
var sin = Mathf.Sin(rad);
|
||||
var cos = Mathf.Cos(rad);
|
||||
return Mathf.Max(Mathf.Abs(cos - sin), Mathf.Abs(cos + sin));
|
||||
}
|
||||
|
||||
private static void SetKeyword(Material material, string[] keywords, int index)
|
||||
{
|
||||
for (var i = 0; i < keywords.Length; i++)
|
||||
@@ -520,50 +658,6 @@ namespace Coffee.UIEffects
|
||||
// Get the rectangle to calculate the normalized position.
|
||||
vh.GetUIVertexStream(verts);
|
||||
var bundleSize = isText ? 6 : count;
|
||||
var rectMatrix = Matrix4x4.identity;
|
||||
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;
|
||||
if (transitionRoot != graphic.transform)
|
||||
{
|
||||
rectMatrix = transitionRoot.worldToLocalMatrix
|
||||
* graphic.transform.localToWorldMatrix;
|
||||
}
|
||||
|
||||
rot *= Matrix4x4.Scale(new Vector3(1 / multiplier, 1 / multiplier, 1))
|
||||
* rectMatrix;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect = graphic.rectTransform.rect;
|
||||
rot *= Matrix4x4.Scale(new Vector3(multiplier, multiplier, 1));
|
||||
}
|
||||
|
||||
var normalizeTex = transitionTex
|
||||
? transitionTex
|
||||
: detailTex
|
||||
? detailTex
|
||||
: null;
|
||||
if (transitionKeepAspectRatio && normalizeTex)
|
||||
{
|
||||
var center = rect.center;
|
||||
var aspectRatio = (float)normalizeTex.width / normalizeTex.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)
|
||||
@@ -574,14 +668,19 @@ namespace Coffee.UIEffects
|
||||
for (var j = 0; j < bundleSize; j++)
|
||||
{
|
||||
var vt = verts[i + j];
|
||||
ModifyVertex(ref vt, vt.position, vt.uv0, uvMask, rect, rot);
|
||||
if (onModifyVertex != null)
|
||||
{
|
||||
vt = onModifyVertex(vt, uvMask);
|
||||
}
|
||||
else
|
||||
{
|
||||
vt.uv1 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
|
||||
}
|
||||
|
||||
verts[i + j] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply gradation.
|
||||
ApplyGradation(verts, transitionRoot.rect, rectMatrix, canModifyShape);
|
||||
|
||||
// Apply flip (with effect).
|
||||
ApplyFlipWithEffect(verts, flip);
|
||||
|
||||
@@ -592,115 +691,6 @@ namespace Coffee.UIEffects
|
||||
vh.AddUIVertexTriangleStream(verts);
|
||||
}
|
||||
|
||||
private void ApplyGradation(List<UIVertex> verts, Rect rect, Matrix4x4 m, bool canModifyShape)
|
||||
{
|
||||
if (gradationMode == GradationMode.None) return;
|
||||
|
||||
var a = gradationColor1;
|
||||
var b = gradationColor2;
|
||||
var offset = gradationOffset;
|
||||
var scale = gradationScale;
|
||||
var grad = gradationGradient;
|
||||
var rot = gradationRotation;
|
||||
switch (gradationMode)
|
||||
{
|
||||
case GradationMode.Horizontal:
|
||||
GradientUtil.DoHorizontalGradient(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.Vertical:
|
||||
GradientUtil.DoVerticalGradient(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.Diagonal:
|
||||
GradientUtil.DoDiagonal(verts, a, b, gradationColor3, gradationColor4, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.DiagonalToRightBottom:
|
||||
GradientUtil.DoDiagonalGradientToRightBottom(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.DiagonalToLeftBottom:
|
||||
GradientUtil.DoDiagonalGradientToLeftBottom(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.RadialFast:
|
||||
GradientUtil.DoRadialGradient(verts, a, b, offset, scale, rect, m, 4);
|
||||
break;
|
||||
case GradationMode.RadialDetail:
|
||||
GradientUtil.DoRadialGradient(verts, a, b, offset, scale, rect, m, 12);
|
||||
break;
|
||||
case GradationMode.Angle:
|
||||
rect = GradientUtil.RotateRectAsNormalized(rect, rot);
|
||||
m = Matrix4x4.Rotate(Quaternion.Euler(0, 0, rot)) * m;
|
||||
GradientUtil.DoHorizontalGradient(verts, a, b, offset, scale, rect, m);
|
||||
break;
|
||||
case GradationMode.HorizontalGradient:
|
||||
{
|
||||
if (_keyTimes == null)
|
||||
{
|
||||
_keyTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.GetKeyTimes(grad, _keyTimes);
|
||||
}
|
||||
|
||||
if (canModifyShape)
|
||||
{
|
||||
var splitTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.SplitKeyTimes(_keyTimes, splitTimes, offset, scale);
|
||||
GradientUtil.DoHorizontalGradient(verts, grad, splitTimes, offset, scale, rect, m);
|
||||
InternalListPool<float>.Return(ref splitTimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
GradientUtil.DoHorizontalGradient(verts, grad, offset, scale, rect, m);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GradationMode.VerticalGradient:
|
||||
{
|
||||
if (_keyTimes == null)
|
||||
{
|
||||
_keyTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.GetKeyTimes(grad, _keyTimes);
|
||||
}
|
||||
|
||||
if (canModifyShape)
|
||||
{
|
||||
var splitTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.SplitKeyTimes(_keyTimes, splitTimes, offset, scale);
|
||||
GradientUtil.DoVerticalGradient(verts, grad, splitTimes, offset, scale, rect, m);
|
||||
InternalListPool<float>.Return(ref splitTimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
GradientUtil.DoVerticalGradient(verts, grad, offset, scale, rect, m);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GradationMode.AngleGradient:
|
||||
{
|
||||
if (_keyTimes == null)
|
||||
{
|
||||
_keyTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.GetKeyTimes(grad, _keyTimes);
|
||||
}
|
||||
|
||||
rect = GradientUtil.RotateRectAsNormalized(rect, rot);
|
||||
m = Matrix4x4.Rotate(Quaternion.Euler(0, 0, rot)) * m;
|
||||
if (canModifyShape)
|
||||
{
|
||||
var splitTimes = InternalListPool<float>.Rent();
|
||||
GradientUtil.SplitKeyTimes(_keyTimes, splitTimes, offset, scale);
|
||||
GradientUtil.DoAngleGradient(verts, grad, splitTimes, offset, scale, rect, m);
|
||||
InternalListPool<float>.Return(ref splitTimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
GradientUtil.DoHorizontalGradient(verts, grad, offset, scale, rect, m);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyShadow(List<UIVertex> verts, RectTransform transitionRoot, Flip flip)
|
||||
{
|
||||
var distance = shadowDistance;
|
||||
@@ -783,24 +773,5 @@ namespace Coffee.UIEffects
|
||||
|
||||
return expandSize;
|
||||
}
|
||||
|
||||
private static void ModifyVertex(ref UIVertex vt, Vector2 pos, Vector2 uv, Rect uvMask,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
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 (onModifyVertex != null)
|
||||
{
|
||||
vt = onModifyVertex(vt, uvMask, normalizedX, normalizedY);
|
||||
}
|
||||
else
|
||||
{
|
||||
vt.uv0.z = normalizedX;
|
||||
vt.uv0.w = normalizedY;
|
||||
vt.uv1 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Text.RegularExpressions;
|
||||
using Coffee.UIEffectInternal;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
@@ -82,10 +83,10 @@ namespace Coffee.UIEffects
|
||||
{
|
||||
#if UNITY_2023_2_OR_NEWER
|
||||
const string tmpSupport = "TextMeshPro Support (Unity 6)";
|
||||
const string version = "v5.6.0 (Unity 6)";
|
||||
const string version = "v5.7.0 (Unity 6)";
|
||||
#else
|
||||
const string tmpSupport = "TextMeshPro Support";
|
||||
const string version = "v5.6.0";
|
||||
const string version = "v5.7.0";
|
||||
#endif
|
||||
ShaderSampleImporter.RegisterShaderSamples(new[]
|
||||
{
|
||||
@@ -153,6 +154,30 @@ namespace Coffee.UIEffects
|
||||
c.SetEnablePreviewIfSelected(selection);
|
||||
}
|
||||
};
|
||||
|
||||
if (!Misc.isBatchOrBuilding)
|
||||
{
|
||||
// Enable the 'UIEFFECT_EDITOR' keyword only when drawing in the scene view camera.
|
||||
RenderPipelineManager.beginCameraRendering += (_, c) => EnableEditorMode(true, c);
|
||||
RenderPipelineManager.endCameraRendering += (_, c) => EnableEditorMode(false, c);
|
||||
Camera.onPreRender += c => EnableEditorMode(true, c);
|
||||
Camera.onPostRender += c => EnableEditorMode(false, c);
|
||||
|
||||
void EnableEditorMode(bool begin, Camera cam)
|
||||
{
|
||||
if (cam.cameraType == CameraType.SceneView)
|
||||
{
|
||||
if (begin)
|
||||
{
|
||||
Shader.EnableKeyword("UIEFFECT_EDITOR");
|
||||
}
|
||||
else
|
||||
{
|
||||
Shader.DisableKeyword("UIEFFECT_EDITOR");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<UIEffectBase> FindAll()
|
||||
|
||||
@@ -172,16 +172,6 @@ namespace Coffee.UIEffects
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBeforeCanvasRebuild()
|
||||
{
|
||||
base.OnBeforeCanvasRebuild();
|
||||
|
||||
if (useTargetTransform && isTargetInScene && CheckTransformChangedWith(target.transform))
|
||||
{
|
||||
SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
internal override void UpdateContext(UIEffectContext c)
|
||||
{
|
||||
if (target && !isTargetInScene)
|
||||
|
||||
@@ -1,394 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Coffee.UIEffects
|
||||
{
|
||||
internal static class GradientUtil
|
||||
{
|
||||
public static void DoHorizontalGradient(List<UIVertex> verts, Color a, Color b, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
for (var i = 0; i < verts.Count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
|
||||
var t = Mathf.Clamp01(offset + (x - 0.5f) * scale + 0.5f);
|
||||
vt.color *= Color.Lerp(a, b, t);
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoHorizontalGradient(List<UIVertex> verts, Gradient gradient, List<float> splitTimes,
|
||||
float offset, float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < verts.Count; i += 6)
|
||||
{
|
||||
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
|
||||
if (i + 5 < count)
|
||||
{
|
||||
UIVertexUtil.SplitHorizontalFast(verts, splitTimes, lb, lt, ref rb, ref rt, rect, m);
|
||||
}
|
||||
|
||||
lb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lb.position).x + 0.0005f, offset, scale);
|
||||
lt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lt.position).x + 0.0005f, offset, scale);
|
||||
rt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rt.position).x - 0.0005f, offset, scale);
|
||||
rb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rb.position).x - 0.0005f, offset, scale);
|
||||
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.xMin, rect.xMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoHorizontalGradientFixed(List<UIVertex> verts, Gradient gradient, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i += 3)
|
||||
{
|
||||
var vt0 = verts[i + 0];
|
||||
var vt1 = verts[i + 1];
|
||||
var vt2 = verts[i + 2];
|
||||
var center = m.MultiplyPoint3x4((vt0.position + vt1.position + vt2.position) / 3).x;
|
||||
vt0.color *= Evaluate(gradient, rect, center, offset, scale);
|
||||
vt1.color *= Evaluate(gradient, rect, center, offset, scale);
|
||||
vt2.color *= Evaluate(gradient, rect, center, offset, scale);
|
||||
verts[i + 0] = vt0;
|
||||
verts[i + 1] = vt1;
|
||||
verts[i + 2] = vt2;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.xMin, rect.xMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoHorizontalGradient(List<UIVertex> verts, Gradient gradient, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
vt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(vt.position).x, offset, scale);
|
||||
verts[i] = vt;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.xMin, rect.xMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoVerticalGradient(List<UIVertex> verts, Color a, Color b, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
for (var i = 0; i < verts.Count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
|
||||
var t = Mathf.Clamp01(offset + (0.5f - y) * scale + 0.5f);
|
||||
vt.color *= Color.Lerp(a, b, t);
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoVerticalGradient(List<UIVertex> verts, Gradient gradient, List<float> splitTimes,
|
||||
float offset, float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < verts.Count; i += 6)
|
||||
{
|
||||
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
|
||||
if (i + 5 < count)
|
||||
{
|
||||
UIVertexUtil.SplitVerticalFast(verts, splitTimes, lb, ref lt, rb, ref rt, rect, m);
|
||||
}
|
||||
|
||||
lb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lb.position).y + 0.0005f, offset, scale);
|
||||
lt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(lt.position).y - 0.0005f, offset, scale);
|
||||
rt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rt.position).y - 0.0005f, offset, scale);
|
||||
rb.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(rb.position).y + 0.0005f, offset, scale);
|
||||
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.yMin, rect.yMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoVerticalGradient(List<UIVertex> verts, Gradient gradient, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
vt.color *= Evaluate(gradient, rect, m.MultiplyPoint3x4(vt.position).y, offset, scale);
|
||||
verts[i] = vt;
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color Evaluate(Gradient gradient, Rect rect, float t, float offset, float scale)
|
||||
{
|
||||
t = Mathf.InverseLerp(rect.yMin, rect.yMax, t); // 0-1
|
||||
t = Mathf.Repeat((t - offset * scale - (1 - scale) / 2) / scale, 1); // Revert
|
||||
return gradient.Evaluate(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoDiagonal(List<UIVertex> verts, Color a, Color b, Color c, Color d, float offset,
|
||||
float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
for (var i = 0; i < verts.Count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
|
||||
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
|
||||
var tx = Mathf.Clamp01(offset + (x - 0.5f) * scale + 0.5f);
|
||||
var ty = Mathf.Clamp01(offset + (0.5f - y) * scale + 0.5f);
|
||||
vt.color *= Color.Lerp(Color.Lerp(a, b, tx), Color.Lerp(c, d, tx), ty);
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoDiagonalGradientToRightBottom(List<UIVertex> verts, Color a, Color b, float offset,
|
||||
float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
for (var i = 0; i < verts.Count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
|
||||
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
|
||||
var t = Mathf.Clamp01(0.5f * scale + 0.5f + offset - (1 - x + y) * scale / 2);
|
||||
vt.color *= Color.Lerp(a, b, t);
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoDiagonalGradientToLeftBottom(List<UIVertex> verts, Color a, Color b, float offset,
|
||||
float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
for (var i = 0; i < verts.Count; i++)
|
||||
{
|
||||
var vt = verts[i];
|
||||
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x);
|
||||
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y);
|
||||
var t = Mathf.Clamp01(0.5f * scale + 0.5f + offset - (x + y) * scale / 2);
|
||||
vt.color *= Color.Lerp(a, b, t);
|
||||
verts[i] = vt;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoRadialGradient(List<UIVertex> verts, Color a, Color b, float offset, float scale,
|
||||
Rect rect, Matrix4x4 m, int divide)
|
||||
{
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i += 6)
|
||||
{
|
||||
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
|
||||
for (var j = 1; j < divide; j++)
|
||||
{
|
||||
var min = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(lb.position).x);
|
||||
var max = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(rt.position).x);
|
||||
var time = 1f - (float)j / divide;
|
||||
if (time <= min || max <= time) continue;
|
||||
|
||||
UIVertexUtil.SplitHorizontal(verts, lb, lt, ref rb, ref rt, Mathf.InverseLerp(min, max, time));
|
||||
}
|
||||
|
||||
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
|
||||
}
|
||||
|
||||
count = verts.Count;
|
||||
for (var i = 0; i < verts.Count; i += 6)
|
||||
{
|
||||
UIVertexUtil.GetQuad(verts, i, out var lb, out var lt, out var rt, out var rb);
|
||||
|
||||
if (i + 5 < count)
|
||||
{
|
||||
for (var j = 1; j < divide; j++)
|
||||
{
|
||||
var min = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(lb.position).y);
|
||||
var max = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(rt.position).y);
|
||||
var time = 1f - (float)j / divide;
|
||||
if (time <= min || max <= time) continue;
|
||||
|
||||
UIVertexUtil.SplitVertical(verts, lb, ref lt, rb, ref rt, Mathf.InverseLerp(min, max, time));
|
||||
}
|
||||
}
|
||||
|
||||
lb.color *= DoGradient(lb, a, b, rect, m, offset, scale);
|
||||
lt.color *= DoGradient(lt, a, b, rect, m, offset, scale);
|
||||
rt.color *= DoGradient(rt, a, b, rect, m, offset, scale);
|
||||
rb.color *= DoGradient(rb, a, b, rect, m, offset, scale);
|
||||
UIVertexUtil.SetQuad(verts, i, lb, lt, rt, rb);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static Color DoGradient(UIVertex vt, Color a, Color b, Rect rect, Matrix4x4 m, float offset, float scale)
|
||||
{
|
||||
var x = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(vt.position).x) - 0.5f;
|
||||
var y = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(vt.position).y) - 0.5f;
|
||||
var t = Mathf.Clamp01(offset + Mathf.Sqrt(x * x + y * y) * 2 * scale);
|
||||
return Color.Lerp(a, b, t);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DoAngleGradient(List<UIVertex> verts, Gradient gradient, List<float> splitTimes,
|
||||
float offset, float scale, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
UIVertexUtil.SplitAngle(verts, splitTimes, rect, m);
|
||||
if (gradient.mode == GradientMode.Fixed)
|
||||
{
|
||||
DoHorizontalGradientFixed(verts, gradient, offset, scale, rect, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoHorizontalGradient(verts, gradient, offset, scale, rect, m);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetKeyTimes(Gradient gradient, List<float> results)
|
||||
{
|
||||
results.Clear();
|
||||
var colors = gradient.colorKeys;
|
||||
for (var i = 0; i < colors.Length; i++)
|
||||
{
|
||||
AddKeyTime(results, colors[i].time);
|
||||
}
|
||||
|
||||
var alphas = gradient.alphaKeys;
|
||||
for (var i = 0; i < alphas.Length; i++)
|
||||
{
|
||||
AddKeyTime(results, alphas[i].time);
|
||||
}
|
||||
|
||||
AddKeyTime(results, 0);
|
||||
AddKeyTime(results, 1);
|
||||
results.Sort((a, b) => b.CompareTo(a));
|
||||
|
||||
return;
|
||||
|
||||
static void AddKeyTime(List<float> results, float time)
|
||||
{
|
||||
if (!Contains(results, time))
|
||||
{
|
||||
results.Add(time);
|
||||
}
|
||||
}
|
||||
|
||||
static bool Contains(List<float> list, float v)
|
||||
{
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (Mathf.Abs(list[i] - v) < 0.001f) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SplitKeyTimes(List<float> keyTimes, List<float> results, float offset, float scale)
|
||||
{
|
||||
results.Clear();
|
||||
for (var i = 0; i < keyTimes.Count; i++)
|
||||
{
|
||||
AddSplitTime(results, keyTimes[i], offset, scale);
|
||||
}
|
||||
|
||||
results.Sort((a, b) => b.CompareTo(a));
|
||||
|
||||
return;
|
||||
|
||||
static void AddSplitTime(List<float> results, float time, float offset, float scale)
|
||||
{
|
||||
time = time * scale + offset * scale + (1 - scale) / 2;
|
||||
|
||||
while (0 < time)
|
||||
{
|
||||
time -= scale;
|
||||
}
|
||||
|
||||
while (time <= 1f)
|
||||
{
|
||||
if (0 <= time && !Contains(results, time))
|
||||
{
|
||||
results.Add(time);
|
||||
}
|
||||
|
||||
time += scale;
|
||||
}
|
||||
}
|
||||
|
||||
static bool Contains(List<float> list, float v)
|
||||
{
|
||||
for (var i = 0; i < list.Count; i++)
|
||||
{
|
||||
if (Mathf.Abs(list[i] - v) < 0.001f) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Rect RotateRectAsNormalized(Rect rect, float rot)
|
||||
{
|
||||
var rad = -rot * Mathf.Deg2Rad;
|
||||
var cos = Mathf.Cos(rad);
|
||||
var sin = Mathf.Sin(rad);
|
||||
var dir = new Vector2(cos, sin);
|
||||
var center = rect.center;
|
||||
|
||||
if (Mathf.Abs(dir.x) < 0.0001f)
|
||||
{
|
||||
rect.width = rect.height;
|
||||
}
|
||||
else if (Mathf.Abs(dir.y) < 0.0001f)
|
||||
{
|
||||
rect.height = rect.width;
|
||||
}
|
||||
else
|
||||
{
|
||||
var d0 = GetPointToLineDistance(new Vector2(rect.xMin, rect.yMax), center, dir, out var p0);
|
||||
var d1 = GetPointToLineDistance(new Vector2(rect.xMin, rect.yMin), center, dir, out var p1);
|
||||
var closest = d0 < d1 ? p0 : p1;
|
||||
rect.width = rect.height = Vector2.Distance(center, closest) * 2;
|
||||
}
|
||||
|
||||
rect.center = new Vector2(Vector2.Dot(center, dir), 0);
|
||||
return rect;
|
||||
}
|
||||
|
||||
private static float GetPointToLineDistance(Vector2 point, Vector2 origin, Vector2 dir, out Vector2 closest)
|
||||
{
|
||||
var dirNormalized = dir.normalized;
|
||||
var time = Vector2.Dot(point - origin, dirNormalized);
|
||||
closest = origin + time * dirNormalized;
|
||||
return Vector2.Distance(point, closest);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23cc1f211cd264050a641c01c4a6d77a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -83,16 +83,13 @@ namespace Coffee.UIEffects
|
||||
private static readonly Func<UIVertex, UIVertex> s_OnMarkAsShadow =
|
||||
vt =>
|
||||
{
|
||||
vt.uv0.z -= 8;
|
||||
vt.uv0.w -= 8;
|
||||
vt.uv1.x -= 2;
|
||||
return vt;
|
||||
};
|
||||
|
||||
private static readonly Func<UIVertex, Rect, float, float, UIVertex> s_OnModifyVertex =
|
||||
(vt, uvMask, normalizedX, normalizedY) =>
|
||||
private static readonly Func<UIVertex, Rect, UIVertex> s_OnModifyVertex =
|
||||
(vt, uvMask) =>
|
||||
{
|
||||
vt.uv0.z = normalizedX;
|
||||
vt.uv0.w = normalizedY;
|
||||
vt.uv1 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
|
||||
return vt;
|
||||
};
|
||||
|
||||
@@ -94,16 +94,13 @@ namespace Coffee.UIEffects
|
||||
private static readonly Func<UIVertex, UIVertex> s_OnMarkAsShadow =
|
||||
vt =>
|
||||
{
|
||||
vt.uv1.z -= 8;
|
||||
vt.uv1.w -= 8;
|
||||
vt.uv2.x -= 2;
|
||||
return vt;
|
||||
};
|
||||
|
||||
private static readonly Func<UIVertex, Rect, float, float, UIVertex> s_OnModifyVertex =
|
||||
(vt, uvMask, normalizedX, normalizedY) =>
|
||||
private static readonly Func<UIVertex, Rect, UIVertex> s_OnModifyVertex =
|
||||
(vt, uvMask) =>
|
||||
{
|
||||
vt.uv1.z = normalizedX;
|
||||
vt.uv1.w = normalizedY;
|
||||
vt.uv2 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
|
||||
return vt;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Coffee.UIEffectInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@@ -160,175 +159,5 @@ namespace Coffee.UIEffects
|
||||
if (max.y < value.y) max.y = value.y; // Top
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetQuad(List<UIVertex> verts, int i, out UIVertex lb, out UIVertex lt, out UIVertex rt,
|
||||
out UIVertex rb)
|
||||
{
|
||||
lb = verts[i];
|
||||
lt = verts[i + 1];
|
||||
rt = verts[i + 2];
|
||||
rb = verts[i + 4];
|
||||
}
|
||||
|
||||
public static void SetQuad(List<UIVertex> verts, int i, UIVertex lb, UIVertex lt, UIVertex rt, UIVertex rb)
|
||||
{
|
||||
verts[i] = verts[i + 5] = lb;
|
||||
verts[i + 1] = lt;
|
||||
verts[i + 2] = verts[i + 3] = rt;
|
||||
verts[i + 4] = rb;
|
||||
}
|
||||
|
||||
public static void SplitHorizontalFast(List<UIVertex> verts, List<float> times, UIVertex lb, UIVertex lt,
|
||||
ref UIVertex rb, ref UIVertex rt, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
if (times == null || times.Count == 0) return;
|
||||
|
||||
var min = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(lb.position).x);
|
||||
for (var i = 0; i < times.Count; i++)
|
||||
{
|
||||
var time = times[i];
|
||||
if (time <= 0 || 1 <= time) continue;
|
||||
|
||||
var max = Mathf.InverseLerp(rect.xMin, rect.xMax, m.MultiplyPoint3x4(rt.position).x);
|
||||
if (time <= min || max <= time) continue;
|
||||
|
||||
SplitHorizontal(verts, lb, lt, ref rb, ref rt, Mathf.InverseLerp(min, max, time));
|
||||
}
|
||||
}
|
||||
|
||||
public static void SplitHorizontal(List<UIVertex> verts, UIVertex lb, UIVertex lt, ref UIVertex rb,
|
||||
ref UIVertex rt, float time)
|
||||
{
|
||||
var mb = VertexLerp(lb, rb, time);
|
||||
var mt = VertexLerp(lt, rt, time);
|
||||
verts.Add(mb);
|
||||
verts.Add(mt);
|
||||
verts.Add(rt);
|
||||
verts.Add(rt);
|
||||
verts.Add(rb);
|
||||
verts.Add(mb);
|
||||
rt = mt;
|
||||
rb = mb;
|
||||
}
|
||||
|
||||
public static void SplitVerticalFast(List<UIVertex> verts, List<float> times, UIVertex lb, ref UIVertex lt,
|
||||
UIVertex rb, ref UIVertex rt, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
if (times == null || times.Count == 0) return;
|
||||
|
||||
var min = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(lb.position).y);
|
||||
for (var i = 0; i < times.Count; i++)
|
||||
{
|
||||
var time = times[i];
|
||||
var max = Mathf.InverseLerp(rect.yMin, rect.yMax, m.MultiplyPoint3x4(rt.position).y);
|
||||
if (time <= min || max <= time) continue;
|
||||
|
||||
SplitVertical(verts, lb, ref lt, rb, ref rt, Mathf.InverseLerp(min, max, time));
|
||||
}
|
||||
}
|
||||
|
||||
public static void SplitVertical(List<UIVertex> verts, UIVertex lb, ref UIVertex lt, UIVertex rb,
|
||||
ref UIVertex rt, float time)
|
||||
{
|
||||
var lm = VertexLerp(lb, lt, time);
|
||||
var rm = VertexLerp(rb, rt, time);
|
||||
verts.Add(lm);
|
||||
verts.Add(lt);
|
||||
verts.Add(rt);
|
||||
verts.Add(rt);
|
||||
verts.Add(rm);
|
||||
verts.Add(lm);
|
||||
lt = lm;
|
||||
rt = rm;
|
||||
}
|
||||
|
||||
public static void SplitAngle(List<UIVertex> verts, List<float> times, Rect rect, Matrix4x4 m)
|
||||
{
|
||||
if (times == null || times.Count == 0) return;
|
||||
|
||||
for (var i = 0; i < times.Count; i++)
|
||||
{
|
||||
var x = Mathf.Lerp(rect.xMin, rect.xMax, times[i]);
|
||||
Split(verts, new Vector2(x, 0), new Vector2(0, 1), m);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
static void Split(List<UIVertex> verts, Vector2 p, Vector2 dir, Matrix4x4 m)
|
||||
{
|
||||
// Each triangle
|
||||
var intersections = InternalListPool<UIVertex>.Rent();
|
||||
var count = verts.Count;
|
||||
for (var i = 0; i < count; i += 3)
|
||||
{
|
||||
intersections.Clear();
|
||||
var n = -1;
|
||||
// Each edge
|
||||
for (var j = 0; j < 3; j++)
|
||||
{
|
||||
var start = verts[i + j];
|
||||
var end = verts[i + (j + 1) % 3];
|
||||
|
||||
if (DoesIntersect(start, end, p, dir, m, out var intersection))
|
||||
{
|
||||
intersections.Add(intersection);
|
||||
}
|
||||
else
|
||||
{
|
||||
n = j;
|
||||
}
|
||||
}
|
||||
|
||||
if (intersections.Count == 2)
|
||||
{
|
||||
var vt0 = verts[i + (n + 2) % 3];
|
||||
var vt1 = verts[i + (n + 0) % 3];
|
||||
var vt2 = verts[i + (n + 1) % 3];
|
||||
var it0 = intersections[0];
|
||||
var it1 = intersections[1];
|
||||
var it2 = intersections[(n + 1) % 2];
|
||||
verts[i + 0] = vt0;
|
||||
verts[i + 1] = it0;
|
||||
verts[i + 2] = it1;
|
||||
verts.Add(it2);
|
||||
verts.Add(vt1);
|
||||
verts.Add(vt2);
|
||||
verts.Add(vt2);
|
||||
verts.Add(it0);
|
||||
verts.Add(it1);
|
||||
}
|
||||
}
|
||||
|
||||
InternalListPool<UIVertex>.Return(ref intersections);
|
||||
}
|
||||
|
||||
static bool DoesIntersect(UIVertex start, UIVertex end, Vector2 p, Vector2 dir, Matrix4x4 m,
|
||||
out UIVertex intersection)
|
||||
{
|
||||
intersection = default;
|
||||
var startPosition = (Vector2)m.MultiplyPoint3x4(start.position);
|
||||
var endPosition = (Vector2)m.MultiplyPoint3x4(end.position);
|
||||
var segDir = endPosition - startPosition;
|
||||
var cross = Vector3.Cross(segDir, dir);
|
||||
|
||||
// Parallel.
|
||||
if (cross.magnitude < Mathf.Epsilon)
|
||||
{
|
||||
return false; // 線と線分が平行
|
||||
}
|
||||
|
||||
var diff = p - startPosition;
|
||||
var determinant = Vector3.Dot(cross, cross);
|
||||
var t = Vector3.Dot(Vector3.Cross(diff, dir), cross) / determinant;
|
||||
|
||||
if (0 <= t && t <= 1)
|
||||
{
|
||||
intersection = VertexLerp(start, end, t);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-15
@@ -68,10 +68,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -87,7 +89,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -100,13 +102,8 @@ SubShader {
|
||||
float4 mask : TEXCOORD2;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD3;
|
||||
float2 uvLocal : TEXCOORD4;
|
||||
float4 worldPosition : TEXCOORD4;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD5;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
@@ -149,14 +146,9 @@ SubShader {
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvLocal = v.texcoord1.zw;
|
||||
OUT.uvMask = v.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
OUT.worldPosition = v.vertex;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
}
|
||||
@@ -178,7 +170,7 @@ SubShader {
|
||||
fixed4 frag (v2f IN) : COLOR
|
||||
{
|
||||
_fragInput = IN;
|
||||
half4 color = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 color = uieffect(IN.texcoord0, IN.uvMask, IN.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0 (Unity 6)
|
||||
userData: v5.7.0 (Unity 6)
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -67,10 +67,12 @@ SubShader{
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -86,7 +88,7 @@ SubShader{
|
||||
fixed4 color : COLOR;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -100,13 +102,8 @@ SubShader{
|
||||
float4 mask : TEXCOORD2;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD3;
|
||||
float2 uvLocal : TEXCOORD4;
|
||||
float4 worldPosition : TEXCOORD4;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD5;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
@@ -154,14 +151,9 @@ SubShader{
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvLocal = v.texcoord1.zw;
|
||||
OUT.uvMask = v.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
OUT.worldPosition = v.vertex;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
}
|
||||
@@ -184,7 +176,7 @@ SubShader{
|
||||
fixed4 frag (v2f IN) : SV_Target
|
||||
{
|
||||
_fragInput = IN;
|
||||
half4 color = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 color = uieffect(IN.texcoord0, IN.uvMask, IN.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0 (Unity 6)
|
||||
userData: v5.7.0 (Unity 6)
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -137,10 +137,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -160,7 +162,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -183,13 +185,8 @@ SubShader {
|
||||
float4 textures : TEXCOORD5;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD6;
|
||||
float2 uvLocal : TEXCOORD7;
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD8;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
@@ -276,14 +273,9 @@ SubShader {
|
||||
output.textures = float4(faceUV, outlineUV);
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.position;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -363,7 +355,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 faceColor = uieffect(_fragInput.atlas, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 faceColor = uieffect(input.atlas, input.uvMask, input.worldPosition);
|
||||
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0 (Unity 6)
|
||||
userData: v5.7.0 (Unity 6)
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -138,10 +138,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -161,7 +163,7 @@ SubShader {
|
||||
float4 color : COLOR;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -185,13 +187,8 @@ SubShader {
|
||||
float4 textures : TEXCOORD5;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD6;
|
||||
float2 uvLocal : TEXCOORD7;
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD8;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
@@ -265,14 +262,9 @@ SubShader {
|
||||
output.textures = float4(faceUV, outlineUV);
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.position;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -358,7 +350,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 faceColor = uieffect(_fragInput.atlas, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 faceColor = uieffect(input.atlas, input.uvMask, input.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0 (Unity 6)
|
||||
userData: v5.7.0 (Unity 6)
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -99,10 +99,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -121,7 +123,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -143,13 +145,8 @@ SubShader {
|
||||
#endif
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD5;
|
||||
float2 uvLocal : TEXCOORD6;
|
||||
float4 worldPosition : TEXCOORD6;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
float _UIMaskSoftnessX;
|
||||
@@ -232,14 +229,9 @@ SubShader {
|
||||
#endif
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.vertex;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -284,7 +276,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 c = uieffect(_fragInput.texcoord0.xy, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 c = uieffect(input.texcoord0.xy, input.uvMask, input.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0 (Unity 6)
|
||||
userData: v5.7.0 (Unity 6)
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -102,10 +102,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -123,7 +125,7 @@ SubShader {
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -143,13 +145,8 @@ SubShader {
|
||||
#endif
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD4;
|
||||
float2 uvLocal : TEXCOORD5;
|
||||
float4 worldPosition :TEXCOORD5;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD6;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
float _UIMaskSoftnessX;
|
||||
@@ -224,14 +221,9 @@ SubShader {
|
||||
#endif
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.position;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -298,7 +290,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 faceColor = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 faceColor = uieffect(input.texcoord0, input.uvMask, input.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0 (Unity 6)
|
||||
userData: v5.7.0 (Unity 6)
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -100,10 +100,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -121,7 +123,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -141,13 +143,8 @@ SubShader {
|
||||
#endif
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD5;
|
||||
float2 uvLocal : TEXCOORD6;
|
||||
float4 worldPosition : TEXCOORD6;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
float _UIMaskSoftnessX;
|
||||
@@ -231,14 +228,9 @@ SubShader {
|
||||
#endif
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.vertex;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -285,7 +277,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 c = uieffect(_fragInput.texcoord0.xy, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 c = uieffect(input.texcoord0.xy, input.uvMask, input.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0 (Unity 6)
|
||||
userData: v5.7.0 (Unity 6)
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -137,10 +137,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -160,7 +162,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float4 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -184,13 +186,8 @@ SubShader {
|
||||
float4 textures : TEXCOORD5;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD6;
|
||||
float2 uvLocal : TEXCOORD7;
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD8;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
@@ -277,14 +274,9 @@ SubShader {
|
||||
output.textures = float4(faceUV, outlineUV);
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.position;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -364,7 +356,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 faceColor = uieffect(_fragInput.atlas, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 faceColor = uieffect(input.atlas, input.uvMask, input.worldPosition);
|
||||
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0 (Unity 6)
|
||||
userData: v5.7.0 (Unity 6)
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -68,10 +68,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -85,7 +87,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -97,13 +99,8 @@ SubShader {
|
||||
float4 mask : TEXCOORD2;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD3;
|
||||
float2 uvLocal : TEXCOORD4;
|
||||
float4 worldPosition : TEXCOORD4;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD5;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
@@ -142,14 +139,9 @@ SubShader {
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvLocal = v.texcoord1.zw;
|
||||
OUT.uvMask = v.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
OUT.worldPosition = v.vertex;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
}
|
||||
@@ -172,7 +164,7 @@ SubShader {
|
||||
fixed4 frag (v2f IN) : COLOR
|
||||
{
|
||||
_fragInput = IN;
|
||||
fixed4 color = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
fixed4 color = uieffect(IN.texcoord0, IN.uvMask, IN.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0
|
||||
userData: v5.7.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -67,10 +67,12 @@ SubShader{
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -84,7 +86,7 @@ SubShader{
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -97,13 +99,8 @@ SubShader{
|
||||
float4 mask : TEXCOORD2;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD3;
|
||||
float2 uvLocal : TEXCOORD4;
|
||||
float4 worldPosition : TEXCOORD4;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD5;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
@@ -155,14 +152,9 @@ SubShader{
|
||||
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvLocal = v.texcoord1.zw;
|
||||
OUT.uvMask = v.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
OUT.worldPosition = v.vertex;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
}
|
||||
@@ -186,7 +178,7 @@ SubShader{
|
||||
fixed4 frag (v2f IN) : SV_Target
|
||||
{
|
||||
_fragInput = IN;
|
||||
fixed4 color = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
fixed4 color = uieffect(IN.texcoord0, IN.uvMask, IN.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0
|
||||
userData: v5.7.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -137,10 +137,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -159,7 +161,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -182,13 +184,8 @@ SubShader {
|
||||
float4 textures : TEXCOORD5;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD6;
|
||||
float2 uvLocal : TEXCOORD7;
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD8;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
@@ -270,14 +267,9 @@ SubShader {
|
||||
output.textures = float4(faceUV, outlineUV);
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.position;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -357,7 +349,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 faceColor = uieffect(_fragInput.atlas, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 faceColor = uieffect(input.atlas, input.uvMask, input.worldPosition);
|
||||
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0
|
||||
userData: v5.7.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -137,10 +137,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -159,7 +161,7 @@ SubShader {
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -182,13 +184,8 @@ SubShader {
|
||||
float4 textures : TEXCOORD5;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD6;
|
||||
float2 uvLocal : TEXCOORD7;
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD8;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
@@ -256,14 +253,9 @@ SubShader {
|
||||
output.textures = float4(faceUV, outlineUV);
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.position;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -348,7 +340,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 faceColor = uieffect(_fragInput.atlas, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 faceColor = uieffect(input.atlas, input.uvMask, input.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0
|
||||
userData: v5.7.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -99,10 +99,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -120,7 +122,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -140,13 +142,8 @@ SubShader {
|
||||
#endif
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD5;
|
||||
float2 uvLocal : TEXCOORD6;
|
||||
float4 worldPosition : TEXCOORD6;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
float _UIMaskSoftnessX;
|
||||
@@ -224,14 +221,9 @@ SubShader {
|
||||
#endif
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.vertex;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -276,7 +268,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 c = uieffect(_fragInput.texcoord0.xy, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 c = uieffect(input.texcoord0.xy, input.uvMask, input.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0
|
||||
userData: v5.7.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
+7
-15
@@ -102,10 +102,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -123,7 +125,7 @@ SubShader {
|
||||
float4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -143,13 +145,8 @@ SubShader {
|
||||
#endif
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD4;
|
||||
float2 uvLocal : TEXCOORD5;
|
||||
float4 worldPosition : TEXCOORD5;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD6;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
float _UIMaskSoftnessX;
|
||||
@@ -224,14 +221,9 @@ SubShader {
|
||||
#endif
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.position;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -298,7 +290,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 faceColor = uieffect(_fragInput.texcoord0, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 faceColor = uieffect(input.texcoord0, input.uvMask, input.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0
|
||||
userData: v5.7.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -99,10 +99,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -121,7 +123,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -141,13 +143,8 @@ SubShader {
|
||||
#endif
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD5;
|
||||
float2 uvLocal : TEXCOORD6;
|
||||
float4 worldPosition : TEXCOORD6;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
float _UIMaskSoftnessX;
|
||||
@@ -225,14 +222,9 @@ SubShader {
|
||||
#endif
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.vertex;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -277,7 +269,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 c = uieffect(_fragInput.texcoord0.xy, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 c = uieffect(input.texcoord0.xy, input.uvMask, input.worldPosition);
|
||||
|
||||
// Alternative implementation to UnityGet2DClipping with support for softness.
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0
|
||||
userData: v5.7.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -137,10 +137,12 @@ SubShader {
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -159,7 +161,7 @@ SubShader {
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord0 : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 texcoord1 : TEXCOORD1;
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
float4 texcoord2 : TEXCOORD2;
|
||||
// ==== UIEFFECT END ====
|
||||
};
|
||||
@@ -182,13 +184,8 @@ SubShader {
|
||||
float4 textures : TEXCOORD5;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD6;
|
||||
float2 uvLocal : TEXCOORD7;
|
||||
float4 worldPosition : TEXCOORD7;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
float4 worldPosition : TEXCOORD8;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
};
|
||||
|
||||
// Used by Unity internally to handle Texture Tiling and Offset.
|
||||
@@ -270,14 +267,9 @@ SubShader {
|
||||
output.textures = float4(faceUV, outlineUV);
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
output.uvLocal = input.texcoord1.zw;
|
||||
output.uvMask = input.texcoord2;
|
||||
// ==== UIEFFECT END ====
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#if SOFTMASK_EDITOR
|
||||
output.worldPosition = input.position;
|
||||
#endif
|
||||
// ==== SOFTMASKABLE END ====
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -357,7 +349,7 @@ SubShader {
|
||||
{
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
_fragInput = input;
|
||||
half4 faceColor = uieffect(_fragInput.atlas, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 faceColor = uieffect(input.atlas, input.uvMask, input.worldPosition);
|
||||
|
||||
#if UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||
|
||||
@@ -4,6 +4,6 @@ ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData: v5.6.0
|
||||
userData: v5.7.0
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -41,6 +41,15 @@ uniform const float2 _DetailThreshold;
|
||||
uniform const sampler2D _DetailTex;
|
||||
uniform const float4 _DetailTex_ST;
|
||||
uniform const float2 _DetailTex_Speed;
|
||||
uniform const half4 _GradationColor1;
|
||||
uniform const half4 _GradationColor2;
|
||||
uniform const half4 _GradationColor3;
|
||||
uniform const half4 _GradationColor4;
|
||||
uniform const sampler2D _GradationTex;
|
||||
uniform const float4 _GradationTex_ST;
|
||||
uniform const matrix _RootViewMatrix;
|
||||
uniform const matrix _GradViewMatrix;
|
||||
uniform const matrix _CanvasToWorldMatrix;
|
||||
|
||||
// For performance reasons, limit the sampling of blur in TextMeshPro.
|
||||
#ifdef UIEFFECT_TEXTMESHPRO
|
||||
@@ -67,6 +76,15 @@ uniform const float2 _DetailTex_Speed;
|
||||
* step(uvMask.x, uv.x) * step(uv.x, uvMask.z) \
|
||||
* step(uvMask.y, uv.y) * step(uv.y, uvMask.w)
|
||||
|
||||
float4 object_to_world(float4 pos)
|
||||
{
|
||||
#if UIEFFECT_EDITOR
|
||||
return mul(unity_ObjectToWorld, pos);
|
||||
#else
|
||||
return mul(_CanvasToWorldMatrix, mul(unity_ObjectToWorld, pos));
|
||||
#endif
|
||||
}
|
||||
|
||||
float2 texel_size()
|
||||
{
|
||||
return _MainTex_TexelSize.xy * _SamplingScale;
|
||||
@@ -376,11 +394,11 @@ half4 apply_edge_color_filter(half4 color, const half4 factor, const float inten
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_sampling_filter(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
half4 apply_sampling_filter(float2 uv, const float4 uvMask, const float2 uvLocal, const float isShadow)
|
||||
{
|
||||
#if SAMPLING_BLUR_FAST || SAMPLING_BLUR_MEDIUM || SAMPLING_BLUR_DETAIL
|
||||
{
|
||||
float intensity = -4 < uvLocal.x + uvLocal.y ? _SamplingIntensity : _ShadowBlurIntensity;
|
||||
float intensity = 0 < isShadow ? _ShadowBlurIntensity : _SamplingIntensity;
|
||||
if (0 < intensity)
|
||||
{
|
||||
#if SAMPLING_BLUR_FAST
|
||||
@@ -510,6 +528,35 @@ half4 apply_transition_filter(half4 color, const float alpha, const float2 uvLoc
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_gradation_filter(half4 color, float2 uvGrad)
|
||||
{
|
||||
const float2 uv = uvGrad * _GradationTex_ST.x + _GradationTex_ST.z;
|
||||
|
||||
#if GRADATION_GRADIENT // Gradation.Gradient
|
||||
{
|
||||
return color * tex2D(_GradationTex, uv);
|
||||
}
|
||||
#elif GRADATION_RADIAL // Gradation.Radial
|
||||
{
|
||||
float t = saturate(length((uvGrad - float2(0.5, 0.5)) * 2 * _GradationTex_ST.x) + _GradationTex_ST.z);
|
||||
return color * lerp(_GradationColor1, _GradationColor2, t);
|
||||
}
|
||||
#elif GRADATION_COLOR2 // Gradation.Color2
|
||||
{
|
||||
return color * lerp(_GradationColor1, _GradationColor2, saturate(uv.x));
|
||||
}
|
||||
#elif GRADATION_COLOR4 // Gradation.Color4
|
||||
{
|
||||
return color * lerp(
|
||||
lerp(_GradationColor3, _GradationColor4, saturate(uv.x)),
|
||||
lerp(_GradationColor1, _GradationColor2, saturate(uv.x)),
|
||||
saturate(uv.y));
|
||||
}
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
half4 apply_detail_filter(half4 color, float2 uvLocal)
|
||||
{
|
||||
const half4 inColor = color;
|
||||
@@ -598,17 +645,22 @@ int is_edge_shiny(const float2 uvLocal)
|
||||
#endif
|
||||
}
|
||||
|
||||
half4 uieffect_internal(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
half4 uieffect_internal(float2 uv, float4 uvMask, const float2 uvLocal, const float2 uvGrad, const int isShadow)
|
||||
{
|
||||
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);
|
||||
half4 color = apply_sampling_filter(uv, uvMask, uvLocal, isShadow);
|
||||
color = apply_gradation_filter(color, uvGrad);
|
||||
color = apply_tone_filter(color);
|
||||
color = apply_transition_filter(color, alpha, uvLocal, edgeFactor);
|
||||
color = apply_detail_filter(color, uvLocal);
|
||||
|
||||
if (-4 <= uvLocal.x + uvLocal.y)
|
||||
if (isShadow)
|
||||
{
|
||||
return apply_shadow_color_filter(color, _ShadowColor, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if EDGE_PLAIN || EDGE_SHINY
|
||||
{
|
||||
@@ -623,16 +675,17 @@ half4 uieffect_internal(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
return apply_shadow_color_filter(color, _ShadowColor, 1);
|
||||
}
|
||||
}
|
||||
|
||||
half4 uieffect(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
half4 uieffect(float2 uv, float4 uvMask, const float4 pos)
|
||||
{
|
||||
const fixed4 origin = UIEFFECT_SAMPLE_CLAMP(uv, uvMask);
|
||||
const half rate = get_target_rate(origin);
|
||||
const float4 wpos = object_to_world(pos);
|
||||
const float2 uvLocal = saturate(mul(_RootViewMatrix, wpos));
|
||||
const float2 uvGrad = mul(_GradViewMatrix, wpos);
|
||||
const int isShadow = uvMask.x < 0 ? 1 : 0;
|
||||
uvMask.x += isShadow * 2;
|
||||
|
||||
// Sampling.Pixelation
|
||||
#if SAMPLING_PIXELATION
|
||||
@@ -644,9 +697,9 @@ half4 uieffect(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
#elif SAMPLING_RGB_SHIFT
|
||||
{
|
||||
const half2 offset = half2(_SamplingIntensity * texel_size().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;
|
||||
const half2 r = uieffect_internal(uv + offset, uvMask, uvLocal, uvGrad, isShadow).ra;
|
||||
const half2 g = uieffect_internal(uv, uvMask, uvLocal, uvGrad, isShadow).ga;
|
||||
const half2 b = uieffect_internal(uv - offset, uvMask, uvLocal, uvGrad, isShadow).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
|
||||
@@ -670,11 +723,11 @@ half4 uieffect(float2 uv, const float4 uvMask, const float2 uvLocal)
|
||||
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));
|
||||
return lerp(0, uieffect_internal(uv, uvMask, uvLocal, uvGrad, isShadow), inv_lerp(0.5, 1, sobel));
|
||||
}
|
||||
#endif
|
||||
|
||||
return lerp(origin, uieffect_internal(uv, uvMask, uvLocal), rate);
|
||||
return lerp(origin, uieffect_internal(uv, uvMask, uvLocal, uvGrad, isShadow), rate);
|
||||
}
|
||||
|
||||
#endif // UI_EFFECT_INCLUDED
|
||||
|
||||
@@ -69,10 +69,12 @@ Shader "Hidden/UI/Default (UIEffect)"
|
||||
#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 _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_RADIAL GRADATION_COLOR2 GRADATION_COLOR4
|
||||
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
// ==== SOFTMASKABLE START ====
|
||||
#pragma shader_feature _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||
#if SOFTMASKABLE
|
||||
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||
@@ -83,7 +85,7 @@ Shader "Hidden/UI/Default (UIEffect)"
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD1;
|
||||
// ==== UIEFFECT END ====
|
||||
@@ -99,7 +101,6 @@ Shader "Hidden/UI/Default (UIEffect)"
|
||||
float4 mask : TEXCOORD2;
|
||||
// ==== UIEFFECT START ====
|
||||
float4 uvMask : TEXCOORD3;
|
||||
float2 uvLocal : TEXCOORD4;
|
||||
// ==== UIEFFECT END ====
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
@@ -143,7 +144,6 @@ Shader "Hidden/UI/Default (UIEffect)"
|
||||
|
||||
// ==== UIEFFECT START ====
|
||||
OUT.uvMask = v.uvMask;
|
||||
OUT.uvLocal = v.texcoord.zw;
|
||||
// ==== UIEFFECT END ====
|
||||
|
||||
return OUT;
|
||||
@@ -172,7 +172,7 @@ Shader "Hidden/UI/Default (UIEffect)"
|
||||
IN.color.a = round(IN.color.a * alphaPrecision) * invAlphaPrecision;
|
||||
|
||||
_fragInput = IN;
|
||||
half4 c = uieffect(_fragInput.texcoord, _fragInput.uvMask, _fragInput.uvLocal);
|
||||
half4 c = uieffect(IN.texcoord, IN.uvMask, IN.worldPosition);
|
||||
|
||||
#ifdef UNITY_UI_CLIP_RECT
|
||||
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(IN.mask.xy)) * IN.mask.zw);
|
||||
|
||||
Reference in New Issue
Block a user