mirror of
https://github.com/mob-sakai/UIEffect.git
synced 2026-11-20 01:33:09 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c3bf0724fe |
@@ -27,3 +27,4 @@ UserSettings/
|
|||||||
*.app/
|
*.app/
|
||||||
Build/
|
Build/
|
||||||
Assets/TextMeshPro Support*
|
Assets/TextMeshPro Support*
|
||||||
|
Assets/UniText Support*
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 39d1ffdf7437242d88b354142d4c7148
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 32977ee1433f447db9160bda9852bc14
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: c1f8983beb12bb84796c28939f4596ab, type: 3}
|
||||||
|
m_Name: UniTextSettings
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
gradients: {fileID: 11400000, guid: 25571032a92321f4997329d90f499d06, type: 2}
|
||||||
|
defaultFontStack: {fileID: 11400000, guid: 72f6e3edfbc82804791ebe8e4814fa46, type: 2}
|
||||||
|
defaultAppearance: {fileID: 11400000, guid: 36ee3940d360ced43a59dd530844bf3d, type: 2}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d2306542229b2418d8d9d4e76b80ed9e
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
"com.unity.ide.rider": "3.0.38",
|
"com.unity.ide.rider": "3.0.38",
|
||||||
"com.unity.test-framework": "1.1.33",
|
"com.unity.test-framework": "1.1.33",
|
||||||
"com.unity.textmeshpro": "3.0.9",
|
"com.unity.textmeshpro": "3.0.9",
|
||||||
|
"media.lightside.unitext": "https://github.com/mob-sakai/UniText.git",
|
||||||
"com.unity.modules.animation": "1.0.0"
|
"com.unity.modules.animation": "1.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,16 @@
|
|||||||
"com.unity.modules.imgui": "1.0.0"
|
"com.unity.modules.imgui": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"media.lightside.unitext": {
|
||||||
|
"version": "https://github.com/mob-sakai/UniText.git",
|
||||||
|
"depth": 0,
|
||||||
|
"source": "git",
|
||||||
|
"dependencies": {
|
||||||
|
"com.unity.ugui": "1.0.0",
|
||||||
|
"com.unity.modules.ui": "1.0.0"
|
||||||
|
},
|
||||||
|
"hash": "5fd42d0037fab4467a82299391ae54cd7faf8466"
|
||||||
|
},
|
||||||
"com.unity.modules.animation": {
|
"com.unity.modules.animation": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"depth": 0,
|
"depth": 0,
|
||||||
@@ -136,7 +146,7 @@
|
|||||||
},
|
},
|
||||||
"com.unity.modules.ui": {
|
"com.unity.modules.ui": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"depth": 2,
|
"depth": 1,
|
||||||
"source": "builtin",
|
"source": "builtin",
|
||||||
"dependencies": {}
|
"dependencies": {}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
"rootNamespace": "",
|
"rootNamespace": "",
|
||||||
"references": [
|
"references": [
|
||||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||||
"GUID:f06555f75b070af458a003d92f9efb00"
|
"GUID:f06555f75b070af458a003d92f9efb00",
|
||||||
|
"GUID:6572381e8157783499bf6ce8f56b9292"
|
||||||
],
|
],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
@@ -32,7 +33,12 @@
|
|||||||
"name": "com.unity.textmeshpro",
|
"name": "com.unity.textmeshpro",
|
||||||
"expression": "[1.0.0,3.2.0-pre.1)",
|
"expression": "[1.0.0,3.2.0-pre.1)",
|
||||||
"define": "LEGACY_TMP_ENABLE"
|
"define": "LEGACY_TMP_ENABLE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "media.lightside.unitext",
|
||||||
|
"expression": "",
|
||||||
|
"define": "UNITEXT_ENABLE"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"noEngineReferences": false
|
"noEngineReferences": false
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,10 @@ namespace Coffee.UIEffects
|
|||||||
|
|
||||||
// ShaderGraph Support
|
// ShaderGraph Support
|
||||||
("Shader Graphs/UISample (UIEffect)", "ShaderGraph Support (Unity 6 BuiltIn)", "v5.9.0"),
|
("Shader Graphs/UISample (UIEffect)", "ShaderGraph Support (Unity 6 BuiltIn)", "v5.9.0"),
|
||||||
("Shader Graphs/UISampleURP (UIEffect)", "ShaderGraph Support (Unity 6 URP)", "v5.9.0")
|
("Shader Graphs/UISampleURP (UIEffect)", "ShaderGraph Support (Unity 6 URP)", "v5.9.0"),
|
||||||
|
|
||||||
|
// UniText Support
|
||||||
|
("Hidden/UniText/Mobile/SDF (UIEffect)", "UniText Support", "v5.9.0")
|
||||||
});
|
});
|
||||||
ShaderSampleImporter.RegisterShaderAliases(new[]
|
ShaderSampleImporter.RegisterShaderAliases(new[]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
#if UNITEXT_ENABLE
|
||||||
|
using System;
|
||||||
|
using Coffee.UIEffectInternal;
|
||||||
|
using LightSide;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace Coffee.UIEffects
|
||||||
|
{
|
||||||
|
internal sealed class UniTextProxy : GraphicProxy
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the graphic is valid for this proxy.
|
||||||
|
/// </summary>
|
||||||
|
protected override bool IsValid(Graphic graphic)
|
||||||
|
{
|
||||||
|
if (!graphic) return false;
|
||||||
|
if (graphic is UniTextProxyRenderer sub && sub.material != EmojiFont.Material) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if the graphic is a text.
|
||||||
|
/// </summary>
|
||||||
|
public override bool IsText(Graphic graphic)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called before modifying the mesh.
|
||||||
|
/// </summary>
|
||||||
|
public override void OnPreModifyMesh(Graphic graphic, Canvas canvas)
|
||||||
|
{
|
||||||
|
UIVertexUtil.onLerpVertex = s_OnLerpVertex;
|
||||||
|
ShadowUtil.onMarkAsShadow = s_OnMarkAsShadow;
|
||||||
|
UIEffectContext.onModifyVertex = s_OnModifyVertex;
|
||||||
|
|
||||||
|
if (canvas)
|
||||||
|
{
|
||||||
|
canvas.additionalShaderChannels |= AdditionalCanvasShaderChannels.TexCoord2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetVerticesDirty(Graphic graphic, bool enabled)
|
||||||
|
{
|
||||||
|
graphic.SetVerticesDirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly Func<UIVertex, UIVertex, UIVertex, float, UIVertex> s_OnLerpVertex = null;
|
||||||
|
|
||||||
|
private static readonly Func<UIVertex, float, UIVertex> s_OnMarkAsShadow =
|
||||||
|
(vt, s) =>
|
||||||
|
{
|
||||||
|
vt.uv2.x -= s;
|
||||||
|
return vt;
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly Func<UIVertex, Rect, UIVertex> s_OnModifyVertex =
|
||||||
|
(vt, uvMask) =>
|
||||||
|
{
|
||||||
|
vt.uv2 = new Vector4(uvMask.xMin, uvMask.yMin, uvMask.xMax, uvMask.yMax);
|
||||||
|
return vt;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
[InitializeOnLoadMethod]
|
||||||
|
#else
|
||||||
|
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||||
|
#endif
|
||||||
|
private static void InitializeOnLoad()
|
||||||
|
{
|
||||||
|
Register(new UniTextProxy());
|
||||||
|
UniText.OnChanged -= ModifyMesh;
|
||||||
|
UniText.OnChanged += ModifyMesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ModifyMesh(UniText uniText)
|
||||||
|
{
|
||||||
|
if (!uniText.TryGetComponent<UIEffectBase>(out var effect)) return;
|
||||||
|
|
||||||
|
var renderData = uniText.RenderData;
|
||||||
|
var subMeshRenderers = uniText.SubMeshRenderers;
|
||||||
|
for (var i = 0; i < renderData.Count; i++)
|
||||||
|
{
|
||||||
|
var r = subMeshRenderers[i].renderer;
|
||||||
|
if (!r) continue;
|
||||||
|
|
||||||
|
if (!r.TryGetComponent<UIEffectReplica>(out var replica))
|
||||||
|
{
|
||||||
|
replica = r.gameObject.AddComponent<UIEffectReplica>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!r.TryGetComponent<UniTextProxyRenderer>(out var proxyRenderer))
|
||||||
|
{
|
||||||
|
proxyRenderer = r.gameObject.AddComponent<UniTextProxyRenderer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = renderData[i];
|
||||||
|
replica.SetTarget(effect);
|
||||||
|
proxyRenderer.Rebuild(data.mesh, data.material, data.texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
Misc.QueuePlayerLoopUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 827a8f25c24894cce88887db90b28c1d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#if UNITEXT_ENABLE
|
||||||
|
using Coffee.UIEffectInternal;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace Coffee.UIEffects
|
||||||
|
{
|
||||||
|
[ExecuteAlways]
|
||||||
|
public class UniTextProxyRenderer : MaskableGraphic
|
||||||
|
{
|
||||||
|
public override Texture mainTexture => _texture;
|
||||||
|
private Mesh _mesh;
|
||||||
|
private Texture _texture;
|
||||||
|
|
||||||
|
private UniTextProxyRenderer()
|
||||||
|
{
|
||||||
|
useLegacyMeshGeneration = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPopulateMesh(VertexHelper vh)
|
||||||
|
{
|
||||||
|
_mesh.CopyTo(vh);
|
||||||
|
|
||||||
|
var count = vh.currentVertCount;
|
||||||
|
UIVertex vt = default;
|
||||||
|
for (var i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
vh.PopulateUIVertex(ref vt, i);
|
||||||
|
vt.position = new Vector3(vt.position.x, vt.position.y);
|
||||||
|
vh.SetUIVertex(vt, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Material GetModifiedMaterial(Material baseMaterial)
|
||||||
|
{
|
||||||
|
return baseMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Rebuild(Mesh mesh, Material mat, Texture texture)
|
||||||
|
{
|
||||||
|
_mesh = mesh;
|
||||||
|
_texture = texture;
|
||||||
|
m_Material = mat;
|
||||||
|
|
||||||
|
SetVerticesDirty();
|
||||||
|
SetMaterialDirty();
|
||||||
|
Rebuild(CanvasUpdate.PreRender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 443aaaf5e624a48f7b7d799c1314bba1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,298 @@
|
|||||||
|
// [OptionalShader] com.coffee.softmask-for-ugui: Hidden/UniText/Mobile/SDF (UIEffect)
|
||||||
|
// [OptionalShader] com.coffee.ui-effect: Hidden/UniText/Mobile/SDF (SoftMaskable)
|
||||||
|
// Simplified SDF shader (single-pass):
|
||||||
|
// - No Shading Option (bevel / bump / env map)
|
||||||
|
// - No Glow Option
|
||||||
|
// - Renders Face, Outline, and Underlay in one pass
|
||||||
|
|
||||||
|
Shader "Hidden/UniText/Mobile/SDF (UIEffect)" {
|
||||||
|
|
||||||
|
Properties {
|
||||||
|
_FaceColor ("Face Color", Color) = (1,1,1,1)
|
||||||
|
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
|
||||||
|
|
||||||
|
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
|
||||||
|
_OutlineDilate ("Outline Dilate", Range(-1,1)) = 0
|
||||||
|
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
|
||||||
|
|
||||||
|
_UnderlayColor ("Border Color", Color) = (0,0,0,.5)
|
||||||
|
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
|
||||||
|
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
|
||||||
|
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
|
||||||
|
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0
|
||||||
|
|
||||||
|
_WeightNormal ("Weight Normal", float) = 0
|
||||||
|
_WeightBold ("Weight Bold", float) = 1
|
||||||
|
|
||||||
|
_ShaderFlags ("Flags", float) = 0
|
||||||
|
_ScaleRatioA ("Scale RatioA", float) = 1
|
||||||
|
_ScaleRatioB ("Scale RatioB", float) = 1
|
||||||
|
_ScaleRatioC ("Scale RatioC", float) = 1
|
||||||
|
|
||||||
|
_MainTex ("Font Atlas", 2D) = "white" {}
|
||||||
|
_ScaleX ("Scale X", float) = 1
|
||||||
|
_ScaleY ("Scale Y", float) = 1
|
||||||
|
_PerspectiveFilter ("Perspective Correction", Range(0, 1)) = 0.875
|
||||||
|
_Sharpness ("Sharpness", Range(-1,1)) = 0
|
||||||
|
|
||||||
|
_VertexOffsetX ("Vertex OffsetX", float) = 0
|
||||||
|
_VertexOffsetY ("Vertex OffsetY", float) = 0
|
||||||
|
|
||||||
|
_ClipRect ("Clip Rect", vector) = (-32767, -32767, 32767, 32767)
|
||||||
|
_MaskSoftnessX ("Mask SoftnessX", float) = 0
|
||||||
|
_MaskSoftnessY ("Mask SoftnessY", float) = 0
|
||||||
|
|
||||||
|
_StencilComp ("Stencil Comparison", Float) = 8
|
||||||
|
_Stencil ("Stencil ID", Float) = 0
|
||||||
|
_StencilOp ("Stencil Operation", Float) = 0
|
||||||
|
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||||
|
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||||
|
|
||||||
|
_CullMode ("Cull Mode", Float) = 0
|
||||||
|
_ColorMask ("Color Mask", Float) = 15
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader {
|
||||||
|
Tags
|
||||||
|
{
|
||||||
|
"Queue"="Transparent"
|
||||||
|
"IgnoreProjector"="True"
|
||||||
|
"RenderType"="Transparent"
|
||||||
|
}
|
||||||
|
|
||||||
|
Stencil
|
||||||
|
{
|
||||||
|
Ref [_Stencil]
|
||||||
|
Comp [_StencilComp]
|
||||||
|
Pass [_StencilOp]
|
||||||
|
ReadMask [_StencilReadMask]
|
||||||
|
WriteMask [_StencilWriteMask]
|
||||||
|
}
|
||||||
|
|
||||||
|
Cull [_CullMode]
|
||||||
|
ZWrite Off
|
||||||
|
Lighting Off
|
||||||
|
Fog { Mode Off }
|
||||||
|
ZTest [unity_GUIZTestMode]
|
||||||
|
// ==== UIEFFECT START ====
|
||||||
|
Blend [_SrcBlend] [_DstBlend]
|
||||||
|
// ==== UIEFFECT END ====
|
||||||
|
ColorMask [_ColorMask]
|
||||||
|
|
||||||
|
Pass {
|
||||||
|
CGPROGRAM
|
||||||
|
#pragma vertex VertShader
|
||||||
|
#pragma fragment PixShader
|
||||||
|
#pragma shader_feature __ OUTLINE_ON
|
||||||
|
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
|
||||||
|
|
||||||
|
#pragma multi_compile __ UNITY_UI_CLIP_RECT
|
||||||
|
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||||
|
|
||||||
|
// ==== UIEFFECT START ====
|
||||||
|
#pragma shader_feature_local_fragment _ TONE_GRAYSCALE TONE_SEPIA TONE_NEGATIVE TONE_RETRO TONE_POSTERIZE
|
||||||
|
#pragma shader_feature_local_fragment _ COLOR_FILTER
|
||||||
|
#pragma shader_feature_local_fragment _ SAMPLING_BLUR_FAST SAMPLING_BLUR_MEDIUM SAMPLING_BLUR_DETAIL SAMPLING_PIXELATION SAMPLING_RGB_SHIFT SAMPLING_EDGE_LUMINANCE SAMPLING_EDGE_ALPHA
|
||||||
|
#pragma shader_feature_local_fragment _ TRANSITION_FADE TRANSITION_CUTOFF TRANSITION_DISSOLVE TRANSITION_SHINY TRANSITION_MASK TRANSITION_MELT TRANSITION_BURN TRANSITION_PATTERN TRANSITION_BLAZE
|
||||||
|
#pragma shader_feature_local_fragment _ EDGE_PLAIN EDGE_SHINY
|
||||||
|
#pragma shader_feature_local_fragment _ DETAIL_MASKING DETAIL_MULTIPLY DETAIL_ADDITIVE DETAIL_SUBTRACTIVE DETAIL_REPLACE DETAIL_MULTIPLY_ADDITIVE
|
||||||
|
#pragma shader_feature_local_fragment _ TARGET_HUE TARGET_LUMINANCE
|
||||||
|
#pragma shader_feature_local_fragment _ GRADATION_GRADIENT GRADATION_COLOR2 GRADATION_COLOR4
|
||||||
|
#pragma shader_feature_fragment _ UIEFFECT_EDITOR
|
||||||
|
// ==== UIEFFECT END ====
|
||||||
|
|
||||||
|
// ==== SOFTMASKABLE START ====
|
||||||
|
#pragma shader_feature_fragment _ SOFTMASK_EDITOR
|
||||||
|
#pragma shader_feature_local_fragment _ SOFTMASKABLE
|
||||||
|
#if SOFTMASKABLE
|
||||||
|
#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
|
||||||
|
#endif
|
||||||
|
// ==== SOFTMASKABLE END ====
|
||||||
|
|
||||||
|
#include "Packages/media.lightside.unitext/Shaders/UniText_SDF-Mobile-Common.cginc"
|
||||||
|
|
||||||
|
// Unity auto-generated: (1/width, 1/height, width, height)
|
||||||
|
float4 _MainTex_TexelSize;
|
||||||
|
|
||||||
|
struct sdf_vertex_tV2
|
||||||
|
{
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
float4 vertex : POSITION;
|
||||||
|
float3 normal : NORMAL;
|
||||||
|
fixed4 color : COLOR;
|
||||||
|
float4 texcoord0 : TEXCOORD0; // xy = UV, z = gradientScale, w = xScaleVal
|
||||||
|
float4 texcoord1 : TEXCOORD1; // x = spreadRatio (Padding / PointSize)
|
||||||
|
// // ==== UIEFFECT START ====
|
||||||
|
float4 texcoord2 : TEXCOORD2;
|
||||||
|
// // ==== UIEFFECT END ====
|
||||||
|
};
|
||||||
|
#define sdf_vertex_t sdf_vertex_tV2
|
||||||
|
|
||||||
|
struct pixel_t
|
||||||
|
{
|
||||||
|
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||||
|
UNITY_VERTEX_OUTPUT_STEREO
|
||||||
|
float4 vertex : SV_POSITION;
|
||||||
|
fixed4 faceColor : COLOR;
|
||||||
|
fixed4 outlineColor : COLOR1;
|
||||||
|
float2 uv : TEXCOORD0;
|
||||||
|
half4 param : TEXCOORD1; // scale, faceBias, outlineBias, alpha
|
||||||
|
half4 mask : TEXCOORD2;
|
||||||
|
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||||
|
float2 underlayUV : TEXCOORD3;
|
||||||
|
half2 underlayParam: TEXCOORD4; // scale, bias
|
||||||
|
#endif
|
||||||
|
// ==== UIEFFECT START ====
|
||||||
|
float4 uvMask : TEXCOORD5;
|
||||||
|
float4 worldPosition : TEXCOORD6;
|
||||||
|
// ==== UIEFFECT END ====
|
||||||
|
};
|
||||||
|
|
||||||
|
pixel_t VertShader(sdf_vertex_t input)
|
||||||
|
{
|
||||||
|
pixel_t output;
|
||||||
|
|
||||||
|
UNITY_INITIALIZE_OUTPUT(pixel_t, output);
|
||||||
|
UNITY_SETUP_INSTANCE_ID(input);
|
||||||
|
UNITY_TRANSFER_INSTANCE_ID(input, output);
|
||||||
|
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||||
|
|
||||||
|
float4 vert = ApplyVertexOffset(input.vertex);
|
||||||
|
float4 vPosition = UnityObjectToClipPos(vert);
|
||||||
|
|
||||||
|
float2 pixelSize = vPosition.w;
|
||||||
|
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
|
||||||
|
|
||||||
|
// Get scale (for AA) and normFactor (for effect normalization)
|
||||||
|
float2 scaleAndNorm = ComputeScaleAndNorm(vPosition, input.normal, vert, input.texcoord0, input.texcoord1);
|
||||||
|
float scale = scaleAndNorm.x;
|
||||||
|
float normFactor = scaleAndNorm.y;
|
||||||
|
|
||||||
|
float baseWeight = ComputeBaseWeight(input.texcoord0);
|
||||||
|
|
||||||
|
// Face bias (effects normalized via normFactor for independence from atlas settings)
|
||||||
|
float faceBias = ComputeBias(baseWeight, _FaceDilate, scale, normFactor);
|
||||||
|
|
||||||
|
// Outline bias (same logic, different dilate)
|
||||||
|
float outlineBias = ComputeBias(baseWeight, _FaceDilate + _OutlineDilate, scale, normFactor);
|
||||||
|
|
||||||
|
fixed4 color = GammaToLinearIfNeeded(input.color);
|
||||||
|
float opacity = color.a;
|
||||||
|
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||||
|
opacity = 1.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fixed4 faceColor = fixed4(color.rgb, opacity) * _FaceColor;
|
||||||
|
faceColor.rgb *= faceColor.a;
|
||||||
|
|
||||||
|
fixed4 outlineColor = _OutlineColor;
|
||||||
|
outlineColor.a *= opacity;
|
||||||
|
outlineColor.rgb *= outlineColor.a;
|
||||||
|
|
||||||
|
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||||
|
// Underlay parameters (effects normalized via normFactor)
|
||||||
|
float softnessFactor = _UnderlaySoftness * _ScaleRatioC * normFactor;
|
||||||
|
float layerScale = scale / (1 + softnessFactor);
|
||||||
|
float underlayDilate = _FaceDilate * _ScaleRatioA + _UnderlayDilate * _ScaleRatioC;
|
||||||
|
float layerBias = ComputeBias(baseWeight, underlayDilate, layerScale, normFactor);
|
||||||
|
|
||||||
|
// Underlay UV offset (independent of atlas settings)
|
||||||
|
// Uses PointSize-proportional factor instead of spreadRatio-dependent
|
||||||
|
float gradientScaleVal = input.texcoord0.z;
|
||||||
|
float offsetFactor = ComputeUnderlayOffsetFactor(gradientScaleVal, normFactor);
|
||||||
|
float2 layerOffset = float2(
|
||||||
|
-(_UnderlayOffsetX * _ScaleRatioC) * offsetFactor * _MainTex_TexelSize.x,
|
||||||
|
-(_UnderlayOffsetY * _ScaleRatioC) * offsetFactor * _MainTex_TexelSize.y
|
||||||
|
);
|
||||||
|
|
||||||
|
output.underlayUV = input.texcoord0.xy + layerOffset;
|
||||||
|
output.underlayParam = half2(layerScale, layerBias);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
output.vertex = vPosition;
|
||||||
|
output.faceColor = faceColor;
|
||||||
|
output.outlineColor = outlineColor;
|
||||||
|
output.uv = input.texcoord0.xy;
|
||||||
|
output.param = half4(scale, faceBias, outlineBias, color.a);
|
||||||
|
output.mask = ComputeMask(vert, pixelSize);
|
||||||
|
|
||||||
|
|
||||||
|
// ==== UIEFFECT START ====
|
||||||
|
output.uvMask = input.texcoord2;
|
||||||
|
output.worldPosition = input.vertex;
|
||||||
|
// ==== UIEFFECT END ====
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
fixed4 uieffect_frag(pixel_t input, float2 uv)
|
||||||
|
{
|
||||||
|
float2 uvAdd = uv - input.uv;
|
||||||
|
half d = tex2D(_MainTex, input.uv + uvAdd).a * input.param.x;
|
||||||
|
half4 result = half4(0, 0, 0, 0);
|
||||||
|
|
||||||
|
// Underlay layer (behind everything)
|
||||||
|
#if UNDERLAY_ON
|
||||||
|
half ud = tex2D(_MainTex, input.underlayUV + uvAdd).a * input.underlayParam.x;
|
||||||
|
half4 underlayColor = float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a);
|
||||||
|
result = SDFLayer(ud, input.underlayParam.y, underlayColor);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNDERLAY_INNER
|
||||||
|
half ud = tex2D(_MainTex, input.underlayUV + uvAdd).a * input.underlayParam.x;
|
||||||
|
half4 underlayColor = float4(_UnderlayColor.rgb * _UnderlayColor.a, _UnderlayColor.a);
|
||||||
|
half faceMask = saturate(d - input.param.y);
|
||||||
|
result = underlayColor * (1 - saturate(ud - input.underlayParam.y)) * faceMask;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Outline layer
|
||||||
|
#ifdef OUTLINE_ON
|
||||||
|
half4 outlineResult = SDFLayer(d, input.param.z, input.outlineColor);
|
||||||
|
result = BlendOver(result, outlineResult);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Face layer (on top)
|
||||||
|
half4 faceResult = SDFLayer(d, input.param.y, input.faceColor);
|
||||||
|
result = BlendOver(result, faceResult);
|
||||||
|
|
||||||
|
// Apply vertex alpha for underlay
|
||||||
|
#if (UNDERLAY_ON | UNDERLAY_INNER)
|
||||||
|
result *= input.param.w;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ApplyClipping(result, input.mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define UIEFFECT_TEXTMESHPRO 1
|
||||||
|
#define UIEFFECT_UNITEXT 1
|
||||||
|
#define UIEFFECT_FRAG_STRUCT pixel_t
|
||||||
|
#include "Packages/com.coffee.ui-effect/Shaders/UIEffect.cginc"
|
||||||
|
fixed4 PixShader(pixel_t input) : SV_Target
|
||||||
|
{
|
||||||
|
UNITY_SETUP_INSTANCE_ID(input);
|
||||||
|
half4 faceColor = uieffect(input.uv, input.uvMask, input.worldPosition, input);
|
||||||
|
// faceColor *= input.faceColor.a;
|
||||||
|
|
||||||
|
#if UNITY_UI_CLIP_RECT
|
||||||
|
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * input.mask.zw);
|
||||||
|
faceColor *= m.x * m.y;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ==== SOFTMASKABLE START ====
|
||||||
|
#if SOFTMASKABLE
|
||||||
|
faceColor *= SoftMask(input.position, input.worldPosition, faceColor.a);
|
||||||
|
#endif
|
||||||
|
// ==== SOFTMASKABLE END ====
|
||||||
|
|
||||||
|
#if UNITY_UI_ALPHACLIP
|
||||||
|
clip(faceColor.a - 0.001);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return faceColor;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomEditor "LightSide.UniText_SDFShaderGUI"
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2b59af9d686c54416a887aa007efbc41
|
||||||
|
ShaderImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
defaultTextures:
|
||||||
|
- _MainTex: {instanceID: 0}
|
||||||
|
nonModifiableTextures: []
|
||||||
|
userData: v5.9.0
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dee20160ea4174bdda8f2db637c74b64
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: ba1d671b8df1409294a2e77970855f56, type: 3}
|
||||||
|
m_Name: UniTextAppearance
|
||||||
|
m_EditorClassIdentifier: LightSide.UniText::UniTextAppearance
|
||||||
|
defaultMaterials:
|
||||||
|
items:
|
||||||
|
- {fileID: 2100000, guid: 576afc17f1fccc544aef5b2388b8def2, type: 2}
|
||||||
|
fontMaterials:
|
||||||
|
items: []
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a2480bd12ed0b436d89f5f3f17ae1bfb
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -8,8 +8,10 @@
|
|||||||
#ifndef CANVAS_SHADERGRAPH
|
#ifndef CANVAS_SHADERGRAPH
|
||||||
uniform const int _SrcBlend;
|
uniform const int _SrcBlend;
|
||||||
uniform const int _DstBlend;
|
uniform const int _DstBlend;
|
||||||
|
#ifndef UIEFFECT_UNITEXT
|
||||||
uniform const float4 _MainTex_TexelSize;
|
uniform const float4 _MainTex_TexelSize;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform const float _ToneIntensity;
|
uniform const float _ToneIntensity;
|
||||||
uniform const int _ColorFilter;
|
uniform const int _ColorFilter;
|
||||||
|
|||||||
@@ -51,6 +51,11 @@
|
|||||||
"displayName": "ShaderGraph Support (Unity 6 URP)",
|
"displayName": "ShaderGraph Support (Unity 6 URP)",
|
||||||
"description": "ShaderGraph Support (Unity 6 URP)",
|
"description": "ShaderGraph Support (Unity 6 URP)",
|
||||||
"path": "Samples~/ShaderGraph Support (Unity 6 URP)~"
|
"path": "Samples~/ShaderGraph Support (Unity 6 URP)~"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"displayName": "UniText Support",
|
||||||
|
"description": "UniText Support",
|
||||||
|
"path": "Samples~/UniText Support~"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
m_EditorVersion: 2020.3.49f1
|
m_EditorVersion: 2022.3.62f2
|
||||||
m_EditorVersionWithRevision: 2020.3.49f1 (18249dd5551b)
|
m_EditorVersionWithRevision: 2022.3.62f2 (7670c08855a9)
|
||||||
|
|||||||
@@ -19,7 +19,12 @@
|
|||||||
"m_From": "Assets/TextMeshPro Support (Unity 6)",
|
"m_From": "Assets/TextMeshPro Support (Unity 6)",
|
||||||
"m_To": "../Packages/src/Samples~/TextMeshPro Support (Unity 6)~",
|
"m_To": "../Packages/src/Samples~/TextMeshPro Support (Unity 6)~",
|
||||||
"m_Define": "UNITY_2023_2_OR_NEWER"
|
"m_Define": "UNITY_2023_2_OR_NEWER"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"m_From": "Assets/UniText Support",
|
||||||
|
"m_To": "../Packages/src/Samples~/UniText Support~",
|
||||||
|
"m_Define": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"gradients": "25571032a92321f4997329d90f499d06",
|
||||||
|
"defaultFontStack": "72f6e3edfbc82804791ebe8e4814fa46",
|
||||||
|
"defaultAppearance": "36ee3940d360ced43a59dd530844bf3d"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user