Reimport upgraded TextMesh Pro, modified.

This commit is contained in:
2023-02-01 22:14:43 +08:00
parent 623c53f79a
commit bd256ba1a6
293 changed files with 98622 additions and 345 deletions

View File

@@ -1,21 +1,28 @@
using System.Collections.Generic; using System.Collections.Generic;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.TextCore.Text;
using IFont = UnityEngine.Font; using IFont = UnityEngine.Font;
namespace Cryville.Common.Unity.UI { namespace Cryville.Common.Unity.UI {
[RequireComponent(typeof(TextMeshProUGUI))] [RequireComponent(typeof(TextMeshProUGUI))]
public class TMPAutoFont : MonoBehaviour { public class TMPAutoFont : MonoBehaviour {
public static Shader DefaultShader;
public static readonly List<string> Fonts = new List<string> { public static readonly List<string> Fonts = new List<string> {
"Arial", "Arial",
}; };
static TMP_FontAsset _font; static FontAsset _font;
TextMeshProUGUI _text; TextMeshProUGUI _text;
[SerializeField]
Shader m_shader;
void Awake() { void Awake() {
_text = GetComponent<TextMeshProUGUI>(); _text = GetComponent<TextMeshProUGUI>();
if (_font == null) { if (_font == null) {
var _ifont = new IFont("C:/Windows/Fonts/arial.ttf"); var _ifont = new IFont("C:/Windows/Fonts/arial.ttf");
_font = TMP_FontAsset.CreateFontAsset(_ifont); _font = FontAsset.CreateFontAsset(_ifont);
if (m_shader) _font.material.shader = m_shader;
else if (DefaultShader) _font.material.shader = DefaultShader;
} }
_text.font = _font; _text.font = _font;
} }

View File

@@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2
defaultReferences: [] defaultReferences: []
executionOrder: 0 executionOrder: -120
icon: {instanceID: 0} icon: {instanceID: 0}
userData: userData:
assetBundleName: assetBundleName:

View File

@@ -3,6 +3,7 @@ using Cryville.Audio.Source;
using Cryville.Common; using Cryville.Common;
using Cryville.Common.Unity; using Cryville.Common.Unity;
using Cryville.Common.Unity.Input; using Cryville.Common.Unity.Input;
using Cryville.Common.Unity.UI;
using FFmpeg.AutoGen; using FFmpeg.AutoGen;
using Ionic.Zip; using Ionic.Zip;
using Newtonsoft.Json; using Newtonsoft.Json;
@@ -127,6 +128,8 @@ namespace Cryville.Crtr {
Settings.Default.LastRunVersion = Application.version; Settings.Default.LastRunVersion = Application.version;
Settings.Default.Save(); Settings.Default.Save();
TMPAutoFont.DefaultShader = Resources.Load<Shader>("TextMesh Pro/Shaders/TMP_SDF SSD");
Logger.Log("main", 1, "Game", "Initialized"); Logger.Log("main", 1, "Game", "Initialized");
} }

View File

@@ -5,7 +5,7 @@
"GUID:d8ea0e0da3ad53a45b65c912ffcacab0", "GUID:d8ea0e0da3ad53a45b65c912ffcacab0",
"GUID:5686e5ee69d0e084c843d61c240d7fdb", "GUID:5686e5ee69d0e084c843d61c240d7fdb",
"GUID:2922aa74af3b2854e81b8a8b286d8206", "GUID:2922aa74af3b2854e81b8a8b286d8206",
"GUID:6055be8ebefd69e48b49212b09b47b2f" "GUID:da293eebbcb9a4947a212534c52d1a32"
], ],
"includePlatforms": [], "includePlatforms": [],
"excludePlatforms": [], "excludePlatforms": [],

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,178 @@
float2 UnpackUV(float uv)
{
float2 output;
output.x = floor(uv / 4096.0);
output.y = uv - 4096.0 * output.x;
return output * 0.001953125;
}
float4 BlendARGB(float4 overlying, float4 underlying)
{
overlying.rgb *= overlying.a;
underlying.rgb *= underlying.a;
float3 blended = overlying.rgb + ((1 - overlying.a) * underlying.rgb);
float alpha = underlying.a + (1 - underlying.a) * overlying.a;
return float4(blended / alpha, alpha);
}
float3 GetSpecular(float3 n, float3 l)
{
float spec = pow(max(0.0, dot(n, l)), _Reflectivity);
return _SpecularColor.rgb * spec * _SpecularPower;
}
void GetSurfaceNormal_float(texture2D atlas, float textureWidth, float textureHeight, float2 uv, bool isFront, out float3 nornmal)
{
float3 delta = float3(1.0 / textureWidth, 1.0 / textureHeight, 0.0);
// Read "height field"
float4 h = float4(
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv - delta.xz).a,
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv + delta.xz).a,
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv - delta.zy).a,
SAMPLE_TEXTURE2D(atlas, SamplerState_Linear_Clamp, uv + delta.zy).a);
bool raisedBevel = _BevelType;
h += _BevelOffset;
float bevelWidth = max(.01, _BevelWidth);
// Track outline
h -= .5;
h /= bevelWidth;
h = saturate(h + .5);
if (raisedBevel) h = 1 - abs(h * 2.0 - 1.0);
h = lerp(h, sin(h * 3.141592 / 2.0), float4(_BevelRoundness, _BevelRoundness, _BevelRoundness, _BevelRoundness));
h = min(h, 1.0 - float4(_BevelClamp, _BevelClamp, _BevelClamp, _BevelClamp));
h *= _BevelAmount * bevelWidth * _GradientScale * -2.0;
float3 va = normalize(float3(-1.0, 0.0, h.y - h.x));
float3 vb = normalize(float3(0.0, 1.0, h.w - h.z));
float3 f = float3(1, 1, 1);
if (isFront) f = float3(1, 1, -1);
nornmal = cross(va, vb) * f;
}
void EvaluateLight_float(float4 faceColor, float3 n, out float4 color)
{
n.z = abs(n.z);
float3 light = normalize(float3(sin(_LightAngle), cos(_LightAngle), 1.0));
float3 col = max(faceColor.rgb, 0) + GetSpecular(n, light)* faceColor.a;
//faceColor.rgb += col * faceColor.a;
col *= 1 - (dot(n, light) * _Diffuse);
col *= lerp(_Ambient, 1, n.z * n.z);
//fixed4 reflcol = texCUBE(_Cube, reflect(input.viewDir, -n));
//faceColor.rgb += reflcol.rgb * lerp(_ReflectFaceColor.rgb, _ReflectOutlineColor.rgb, saturate(sd + outline * 0.5)) * faceColor.a;
color = float4(col, faceColor.a);
}
// Add custom function to handle time in HDRP
//
void GenerateUV_float(float2 inUV, float4 transform, float2 animSpeed, out float2 outUV)
{
outUV = inUV * transform.xy + transform.zw + (animSpeed * _Time.y);
}
void ComputeUVOffset_float(float texWidth, float texHeight, float2 offset, float SDR, out float2 uvOffset)
{
uvOffset = float2(-offset.x * SDR / texWidth, -offset.y * SDR / texHeight);
}
void ScreenSpaceRatio2_float(float4x4 projection, float4 position, float2 objectScale, float screenWidth, float screenHeight, float fontScale, out float SSR)
{
float2 pixelSize = position.w;
pixelSize /= (objectScale * mul((float2x2)projection, float2(screenWidth, screenHeight)));
SSR = rsqrt(dot(pixelSize, pixelSize)*2) * fontScale;
}
// UV : Texture coordinate of the source distance field texture
// TextureSize : Size of the source distance field texture
// Filter : Enable perspective filter (soften)
void ScreenSpaceRatio_float(float2 UV, float TextureSize, bool Filter, out float SSR)
{
if(Filter)
{
float2 a = float2(ddx(UV.x), ddy(UV.x));
float2 b = float2(ddx(UV.y), ddy(UV.y));
float s = lerp(dot(a,a), dot(b,b), 0.5);
SSR = rsqrt(s) / TextureSize;
}
else
{
float s = rsqrt(abs(ddx(UV.x) * ddy(UV.y) - ddy(UV.x) * ddx(UV.y)));
SSR = s / TextureSize;
}
}
// SSR : Screen Space Ratio
// SD : Signed Distance (encoded : Distance / SDR + .5)
// SDR : Signed Distance Ratio
//
// IsoPerimeter : Dilate / Contract the shape
void ComputeSDF_float(float SSR, float SD, float SDR, float isoPerimeter, float softness, out float outAlpha)
{
softness *= SSR * SDR;
float d = (SD - 0.5) * SDR; // Signed distance to edge, in Texture space
outAlpha = saturate((d * 2.0 * SSR + 0.5 + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness)); // Screen pixel coverage (alpha)
}
void ComputeSDF2_float(float SSR, float SD, float SDR, float2 isoPerimeter, float2 softness, out float2 outAlpha)
{
softness *= SSR * SDR;
float d = (SD - 0.5f) * SDR;
outAlpha = saturate((d * 2.0f * SSR + 0.5f + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness));
}
void ComputeSDF4_float(float SSR, float SD, float SDR, float4 isoPerimeter, float4 softness, out float4 outAlpha)
{
softness *= SSR * SDR;
float d = (SD - 0.5f) * SDR;
outAlpha = saturate((d * 2.0f * SSR + 0.5f + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness));
}
void ComputeSDF44_float(float SSR, float4 SD, float SDR, float4 isoPerimeter, float4 softness, bool outline, out float4 outAlpha)
{
softness *= SSR * SDR;
float4 d = (SD - 0.5f) * SDR;
if(outline) d.w = max(max(d.x, d.y), d.z);
outAlpha = saturate((d * 2.0f * SSR + 0.5f + isoPerimeter * SDR * SSR + softness * 0.5) / (1.0 + softness));
}
void Composite_float(float4 overlying, float4 underlying, out float4 outColor)
{
outColor = BlendARGB(overlying, underlying);
}
// Face only
void Layer1_float(float alpha, float4 color0, out float4 outColor)
{
color0.a *= alpha;
outColor = color0;
}
// Face + 1 Outline
void Layer2_float(float2 alpha, float4 color0, float4 color1, out float4 outColor)
{
color1.a *= alpha.y;
color0.rgb *= color0.a; color1.rgb *= color1.a;
outColor = lerp(color1, color0, alpha.x);
outColor.rgb /= outColor.a;
}
// Face + 3 Outline
void Layer4_float(float4 alpha, float4 color0, float4 color1, float4 color2, float4 color3, out float4 outColor)
{
color3.a *= alpha.w;
color0.rgb *= color0.a; color1.rgb *= color1.a; color2.rgb *= color2.a; color3.rgb *= color3.a;
outColor = lerp(lerp(lerp(color3, color2, alpha.z), color1, alpha.y), color0, alpha.x);
outColor.rgb /= outColor.a;
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 96de908384869cd409c75efa351d5edf
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
preprocessorOverride: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -3,7 +3,7 @@ Shader "TextMeshPro/Bitmap Custom Atlas" {
Properties { Properties {
_MainTex ("Font Atlas", 2D) = "white" {} _MainTex ("Font Atlas", 2D) = "white" {}
_FaceTex ("Font Texture", 2D) = "white" {} _FaceTex ("Font Texture", 2D) = "white" {}
[HDR]_FaceColor ("Text Color", Color) = (1,1,1,1) _FaceColor ("Text Color", Color) = (1,1,1,1)
_VertexOffsetX ("Vertex OffsetX", float) = 0 _VertexOffsetX ("Vertex OffsetX", float) = 0
_VertexOffsetY ("Vertex OffsetY", float) = 0 _VertexOffsetY ("Vertex OffsetY", float) = 0
@@ -56,14 +56,16 @@ SubShader{
#include "UnityCG.cginc" #include "UnityCG.cginc"
struct appdata_t { struct appdata_t
{
float4 vertex : POSITION; float4 vertex : POSITION;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float4 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1; float2 texcoord1 : TEXCOORD1;
}; };
struct v2f { struct v2f
{
float4 vertex : SV_POSITION; float4 vertex : SV_POSITION;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float2 texcoord0 : TEXCOORD0;
@@ -81,15 +83,8 @@ SubShader{
uniform float4 _ClipRect; uniform float4 _ClipRect;
uniform float _MaskSoftnessX; uniform float _MaskSoftnessX;
uniform float _MaskSoftnessY; uniform float _MaskSoftnessY;
uniform float _UIMaskSoftnessX;
float2 UnpackUV(float uv) uniform float _UIMaskSoftnessY;
{
float2 output;
output.x = floor(uv / 4096);
output.y = uv - 4096 * output.x;
return output * 0.001953125;
}
v2f vert (appdata_t v) v2f vert (appdata_t v)
{ {
@@ -108,13 +103,14 @@ SubShader{
OUT.vertex = vPosition; OUT.vertex = vPosition;
OUT.color = faceColor; OUT.color = faceColor;
OUT.texcoord0 = v.texcoord0; OUT.texcoord0 = v.texcoord0;
OUT.texcoord1 = TRANSFORM_TEX(UnpackUV(v.texcoord1), _FaceTex); OUT.texcoord1 = TRANSFORM_TEX(v.texcoord1, _FaceTex);
float2 pixelSize = vPosition.w; float2 pixelSize = vPosition.w;
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1])); pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
// Clamp _ClipRect to 16bit. // Clamp _ClipRect to 16bit.
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10); const float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)); const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
return OUT; return OUT;
} }

View File

@@ -2,7 +2,7 @@ Shader "TextMeshPro/Mobile/Bitmap" {
Properties { Properties {
_MainTex ("Font Atlas", 2D) = "white" {} _MainTex ("Font Atlas", 2D) = "white" {}
[HDR]_Color ("Text Color", Color) = (1,1,1,1) _Color ("Text Color", Color) = (1,1,1,1)
_DiffusePower ("Diffuse Power", Range(1.0,4.0)) = 1.0 _DiffusePower ("Diffuse Power", Range(1.0,4.0)) = 1.0
_VertexOffsetX ("Vertex OffsetX", float) = 0 _VertexOffsetX ("Vertex OffsetX", float) = 0
@@ -56,14 +56,16 @@ SubShader {
#include "UnityCG.cginc" #include "UnityCG.cginc"
struct appdata_t { struct appdata_t
{
float4 vertex : POSITION; float4 vertex : POSITION;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1; float2 texcoord1 : TEXCOORD1;
}; };
struct v2f { struct v2f
{
float4 vertex : POSITION; float4 vertex : POSITION;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float2 texcoord0 : TEXCOORD0;
@@ -79,6 +81,8 @@ SubShader {
uniform float4 _ClipRect; uniform float4 _ClipRect;
uniform float _MaskSoftnessX; uniform float _MaskSoftnessX;
uniform float _MaskSoftnessY; uniform float _MaskSoftnessY;
uniform float _UIMaskSoftnessX;
uniform float _UIMaskSoftnessY;
v2f vert (appdata_t v) v2f vert (appdata_t v)
{ {
@@ -99,8 +103,9 @@ SubShader {
//pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1])); //pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
// Clamp _ClipRect to 16bit. // Clamp _ClipRect to 16bit.
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10); const float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)); const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
return OUT; return OUT;
} }

View File

@@ -3,7 +3,7 @@ Shader "TextMeshPro/Bitmap" {
Properties { Properties {
_MainTex ("Font Atlas", 2D) = "white" {} _MainTex ("Font Atlas", 2D) = "white" {}
_FaceTex ("Font Texture", 2D) = "white" {} _FaceTex ("Font Texture", 2D) = "white" {}
[HDR]_FaceColor ("Text Color", Color) = (1,1,1,1) _FaceColor ("Text Color", Color) = (1,1,1,1)
_VertexOffsetX ("Vertex OffsetX", float) = 0 _VertexOffsetX ("Vertex OffsetX", float) = 0
_VertexOffsetY ("Vertex OffsetY", float) = 0 _VertexOffsetY ("Vertex OffsetY", float) = 0
@@ -55,14 +55,16 @@ SubShader{
#include "UnityCG.cginc" #include "UnityCG.cginc"
struct appdata_t { struct appdata_t
{
float4 vertex : POSITION; float4 vertex : POSITION;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float4 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1; float2 texcoord1 : TEXCOORD1;
}; };
struct v2f { struct v2f
{
float4 vertex : SV_POSITION; float4 vertex : SV_POSITION;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float2 texcoord0 : TEXCOORD0;
@@ -80,15 +82,8 @@ SubShader{
uniform float4 _ClipRect; uniform float4 _ClipRect;
uniform float _MaskSoftnessX; uniform float _MaskSoftnessX;
uniform float _MaskSoftnessY; uniform float _MaskSoftnessY;
uniform float _UIMaskSoftnessX;
float2 UnpackUV(float uv) uniform float _UIMaskSoftnessY;
{
float2 output;
output.x = floor(uv / 4096);
output.y = uv - 4096 * output.x;
return output * 0.001953125;
}
v2f vert (appdata_t v) v2f vert (appdata_t v)
{ {
@@ -107,13 +102,14 @@ SubShader{
OUT.vertex = vPosition; OUT.vertex = vPosition;
OUT.color = faceColor; OUT.color = faceColor;
OUT.texcoord0 = v.texcoord0; OUT.texcoord0 = v.texcoord0;
OUT.texcoord1 = TRANSFORM_TEX(UnpackUV(v.texcoord1), _FaceTex); OUT.texcoord1 = TRANSFORM_TEX(v.texcoord1, _FaceTex);
float2 pixelSize = vPosition.w; float2 pixelSize = vPosition.w;
pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1])); pixelSize /= abs(float2(_ScreenParams.x * UNITY_MATRIX_P[0][0], _ScreenParams.y * UNITY_MATRIX_P[1][1]));
// Clamp _ClipRect to 16bit. // Clamp _ClipRect to 16bit.
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10); const float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)); const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
OUT.mask = float4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
return OUT; return OUT;
} }

View File

@@ -4,10 +4,10 @@ Properties {
_FaceTex ("Face Texture", 2D) = "white" {} _FaceTex ("Face Texture", 2D) = "white" {}
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0 _FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0 _FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1) _FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0 _FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1) _OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineTex ("Outline Texture", 2D) = "white" {} _OutlineTex ("Outline Texture", 2D) = "white" {}
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0 _OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0 _OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
@@ -21,7 +21,7 @@ Properties {
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0 _BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416 _LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
[HDR]_SpecularColor ("Specular", Color) = (1,1,1,1) _SpecularColor ("Specular", Color) = (1,1,1,1)
_SpecularPower ("Specular", Range(0,4)) = 2.0 _SpecularPower ("Specular", Range(0,4)) = 2.0
_Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10 _Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10
_Diffuse ("Diffuse", Range(0,1)) = 0.5 _Diffuse ("Diffuse", Range(0,1)) = 0.5
@@ -37,13 +37,13 @@ Properties {
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0) _EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5) _UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0 _UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0 _UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0 _UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0 _UnderlaySoftness ("Border Softness", Range(0,1)) = 0
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5) _GlowColor ("Color", Color) = (0, 1, 0, 0.5)
_GlowOffset ("Offset", Range(-1,1)) = 0 _GlowOffset ("Offset", Range(-1,1)) = 0
_GlowInner ("Inner", Range(0,1)) = 0.05 _GlowInner ("Inner", Range(0,1)) = 0.05
_GlowOuter ("Outer", Range(0,1)) = 0.05 _GlowOuter ("Outer", Range(0,1)) = 0.05
@@ -127,17 +127,18 @@ SubShader {
#include "TMPro_Properties.cginc" #include "TMPro_Properties.cginc"
#include "TMPro.cginc" #include "TMPro.cginc"
struct vertex_t { struct vertex_t
{
UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_INPUT_INSTANCE_ID
float4 position : POSITION; float4 position : POSITION;
float3 normal : NORMAL; float3 normal : NORMAL;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float4 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1; float2 texcoord1 : TEXCOORD1;
}; };
struct pixel_t
struct pixel_t { {
UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO UNITY_VERTEX_OUTPUT_STEREO
float4 position : SV_POSITION; float4 position : SV_POSITION;
@@ -151,12 +152,15 @@ SubShader {
float4 texcoord2 : TEXCOORD4; // u,v, scale, bias float4 texcoord2 : TEXCOORD4; // u,v, scale, bias
fixed4 underlayColor : COLOR1; fixed4 underlayColor : COLOR1;
#endif #endif
float4 textures : TEXCOORD5; float4 textures : TEXCOORD5;
}; };
// Used by Unity internally to handle Texture Tiling and Offset. // Used by Unity internally to handle Texture Tiling and Offset.
float4 _FaceTex_ST; uniform float4 _FaceTex_ST;
float4 _OutlineTex_ST; uniform float4 _OutlineTex_ST;
uniform float _UIMaskSoftnessX;
uniform float _UIMaskSoftnessY;
pixel_t VertShader(vertex_t input) pixel_t VertShader(vertex_t input)
{ {
@@ -167,7 +171,7 @@ SubShader {
UNITY_TRANSFER_INSTANCE_ID(input,output); UNITY_TRANSFER_INSTANCE_ID(input,output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord1.y, 0); float bold = step(input.texcoord0.w, 0);
float4 vert = input.position; float4 vert = input.position;
vert.x += _VertexOffsetX; vert.x += _VertexOffsetX;
@@ -178,7 +182,7 @@ SubShader {
float2 pixelSize = vPosition.w; float2 pixelSize = vPosition.w;
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy)); pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float scale = rsqrt(dot(pixelSize, pixelSize)); float scale = rsqrt(dot(pixelSize, pixelSize));
scale *= abs(input.texcoord1.y) * _GradientScale * (_Sharpness + 1); scale *= abs(input.texcoord0.w) * _GradientScale * (_Sharpness + 1);
if (UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert))))); if (UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0; float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
@@ -212,7 +216,7 @@ SubShader {
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy); float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
// Support for texture tiling and offset // Support for texture tiling and offset
float2 textureUV = UnpackUV(input.texcoord1.x); float2 textureUV = input.texcoord1;
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex); float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex); float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
@@ -221,7 +225,8 @@ SubShader {
output.color = input.color; output.color = input.color;
output.atlas = input.texcoord0; output.atlas = input.texcoord0;
output.param = float4(alphaClip, scale, bias, weight); output.param = float4(alphaClip, scale, bias, weight);
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)); const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
output.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz); output.viewDir = mul((float3x3)_EnvMatrix, _WorldSpaceCameraPos.xyz - mul(unity_ObjectToWorld, vert).xyz);
#if (UNDERLAY_ON || UNDERLAY_INNER) #if (UNDERLAY_ON || UNDERLAY_INNER)
output.texcoord2 = float4(input.texcoord0 + bOffset, bScale, bBias); output.texcoord2 = float4(input.texcoord0 + bOffset, bScale, bBias);
@@ -307,7 +312,6 @@ SubShader {
return faceColor * input.color.a; return faceColor * input.color.a;
} }
ENDCG ENDCG
} }
} }

View File

@@ -4,10 +4,10 @@ Properties {
_FaceTex ("Face Texture", 2D) = "white" {} _FaceTex ("Face Texture", 2D) = "white" {}
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0 _FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0 _FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1) _FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0 _FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1) _OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineTex ("Outline Texture", 2D) = "white" {} _OutlineTex ("Outline Texture", 2D) = "white" {}
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0 _OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0 _OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
@@ -21,7 +21,7 @@ Properties {
_BevelRoundness ("Bevel Roundness", Range(0,1)) = 0 _BevelRoundness ("Bevel Roundness", Range(0,1)) = 0
_LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416 _LightAngle ("Light Angle", Range(0.0, 6.2831853)) = 3.1416
[HDR]_SpecularColor ("Specular", Color) = (1,1,1,1) _SpecularColor ("Specular", Color) = (1,1,1,1)
_SpecularPower ("Specular", Range(0,4)) = 2.0 _SpecularPower ("Specular", Range(0,4)) = 2.0
_Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10 _Reflectivity ("Reflectivity", Range(5.0,15.0)) = 10
_Diffuse ("Diffuse", Range(0,1)) = 0.5 _Diffuse ("Diffuse", Range(0,1)) = 0.5
@@ -37,13 +37,13 @@ Properties {
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0) _EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0, 0.5) _UnderlayColor ("Border Color", Color) = (0,0,0, 0.5)
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0 _UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0 _UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0 _UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
_UnderlaySoftness ("Border Softness", Range(0,1)) = 0 _UnderlaySoftness ("Border Softness", Range(0,1)) = 0
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5) _GlowColor ("Color", Color) = (0, 1, 0, 0.5)
_GlowOffset ("Offset", Range(-1,1)) = 0 _GlowOffset ("Offset", Range(-1,1)) = 0
_GlowInner ("Inner", Range(0,1)) = 0.05 _GlowInner ("Inner", Range(0,1)) = 0.05
_GlowOuter ("Outer", Range(0,1)) = 0.05 _GlowOuter ("Outer", Range(0,1)) = 0.05
@@ -109,7 +109,8 @@ SubShader {
Blend One OneMinusSrcAlpha Blend One OneMinusSrcAlpha
ColorMask[_ColorMask] ColorMask[_ColorMask]
Pass { Pass
{
CGPROGRAM CGPROGRAM
#pragma target 3.0 #pragma target 3.0
#pragma vertex VertShader #pragma vertex VertShader
@@ -127,17 +128,18 @@ SubShader {
#include "TMPro_Properties.cginc" #include "TMPro_Properties.cginc"
#include "TMPro.cginc" #include "TMPro.cginc"
struct vertex_t { struct vertex_t
{
UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_INPUT_INSTANCE_ID
float4 position : POSITION; float4 position : POSITION;
float3 normal : NORMAL; float3 normal : NORMAL;
float4 color : COLOR; float4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float4 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1; float2 texcoord1 : TEXCOORD1;
}; };
struct pixel_t
struct pixel_t { {
UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO UNITY_VERTEX_OUTPUT_STEREO
float4 position : SV_POSITION; float4 position : SV_POSITION;
@@ -151,14 +153,18 @@ SubShader {
float2 texcoord2 : TEXCOORD4; float2 texcoord2 : TEXCOORD4;
float4 underlayColor : COLOR1; float4 underlayColor : COLOR1;
#endif #endif
float4 textures : TEXCOORD5; float4 textures : TEXCOORD5;
}; };
// Used by Unity internally to handle Texture Tiling and Offset. // Used by Unity internally to handle Texture Tiling and Offset.
float4 _FaceTex_ST; float4 _FaceTex_ST;
float4 _OutlineTex_ST; float4 _OutlineTex_ST;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
float4 SRGBToLinear(float4 rgba) { float4 SRGBToLinear(float4 rgba)
{
return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a); return float4(lerp(rgba.rgb / 12.92f, pow((rgba.rgb + 0.055f) / 1.055f, 2.4f), step(0.04045f, rgba.rgb)), rgba.a);
} }
@@ -171,7 +177,7 @@ SubShader {
UNITY_TRANSFER_INSTANCE_ID(input,output); UNITY_TRANSFER_INSTANCE_ID(input,output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord1.y, 0); float bold = step(input.texcoord0.w, 0);
float4 vert = input.position; float4 vert = input.position;
vert.x += _VertexOffsetX; vert.x += _VertexOffsetX;
@@ -195,7 +201,7 @@ SubShader {
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10); float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
// Support for texture tiling and offset // Support for texture tiling and offset
float2 textureUV = UnpackUV(input.texcoord1.x); float2 textureUV = input.texcoord1;
float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex); float2 faceUV = TRANSFORM_TEX(textureUV, _FaceTex);
float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex); float2 outlineUV = TRANSFORM_TEX(textureUV, _OutlineTex);
@@ -226,9 +232,9 @@ SubShader {
float c = tex2D(_MainTex, input.atlas).a; float c = tex2D(_MainTex, input.atlas).a;
float2 pixelSize = float2(ddx(input.atlas.y), ddy(input.atlas.y)); float pixelSize = abs(ddx(input.atlas.y)) + abs(ddy(input.atlas.y));
pixelSize *= _TextureWidth * .75; pixelSize *= _TextureHeight * 0.75;
float scale = rsqrt(dot(pixelSize, pixelSize)) * _GradientScale * (_Sharpness + 1); float scale = 1 / pixelSize * _GradientScale * (_Sharpness + 1);
float weight = input.weight; float weight = input.weight;
float bias = (.5 - weight) + (.5 / scale); float bias = (.5 - weight) + (.5 / scale);
@@ -289,7 +295,8 @@ SubShader {
// Alternative implementation to UnityGet2DClipping with support for softness. // Alternative implementation to UnityGet2DClipping with support for softness.
#if UNITY_UI_CLIP_RECT #if UNITY_UI_CLIP_RECT
float2 maskZW = 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + (1 / scale)); half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
float2 maskZW = 0.25 / (0.25 * maskSoftness + 1 / scale);
half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW); half2 m = saturate((_ClipRect.zw - _ClipRect.xy - abs(input.mask.xy)) * maskZW);
faceColor *= m.x * m.y; faceColor *= m.x * m.y;
#endif #endif
@@ -300,7 +307,6 @@ SubShader {
return faceColor * input.color.a; return faceColor * input.color.a;
} }
ENDCG ENDCG
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ca2ed216f98028c4dae6c5224a952b3c
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: f63d574838ccfb44f84acc05fed0af48
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

View File

@@ -6,14 +6,14 @@
Shader "TextMeshPro/Mobile/Distance Field - Masking" { Shader "TextMeshPro/Mobile/Distance Field - Masking" {
Properties { Properties {
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1) _FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0 _FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1) _OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0 _OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0 _OutlineSoftness ("Outline Softness", Range(0,1)) = 0
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0,.5) _UnderlayColor ("Border Color", Color) = (0,0,0,.5)
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0 _UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0 _UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0 _UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
@@ -99,21 +99,24 @@ SubShader {
#include "UnityUI.cginc" #include "UnityUI.cginc"
#include "TMPro_Properties.cginc" #include "TMPro_Properties.cginc"
struct vertex_t { struct vertex_t
{
float4 vertex : POSITION; float4 vertex : POSITION;
float3 normal : NORMAL; float3 normal : NORMAL;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float4 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1; float2 texcoord1 : TEXCOORD1;
}; };
struct pixel_t { struct pixel_t
{
float4 vertex : SV_POSITION; float4 vertex : SV_POSITION;
fixed4 faceColor : COLOR; fixed4 faceColor : COLOR;
fixed4 outlineColor : COLOR1; fixed4 outlineColor : COLOR1;
float4 texcoord0 : TEXCOORD0; // Texture UV, Mask UV float4 texcoord0 : TEXCOORD0; // Texture UV, Mask UV
half4 param : TEXCOORD1; // Scale(x), BiasIn(y), BiasOut(z), Bias(w) half4 param : TEXCOORD1; // Scale(x), BiasIn(y), BiasOut(z), Bias(w)
half4 mask : TEXCOORD2; // Position in clip space(xy), Softness(zw) half4 mask : TEXCOORD2; // Position in clip space(xy), Softness(zw)
#if (UNDERLAY_ON | UNDERLAY_INNER) #if (UNDERLAY_ON | UNDERLAY_INNER)
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y) half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
@@ -124,10 +127,12 @@ SubShader {
float _MaskEdgeSoftness; float _MaskEdgeSoftness;
fixed4 _MaskEdgeColor; fixed4 _MaskEdgeColor;
bool _MaskInverse; bool _MaskInverse;
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
pixel_t VertShader(vertex_t input) pixel_t VertShader(vertex_t input)
{ {
float bold = step(input.texcoord1.y, 0); float bold = step(input.texcoord0.w, 0);
float4 vert = input.vertex; float4 vert = input.vertex;
vert.x += _VertexOffsetX; vert.x += _VertexOffsetX;
@@ -138,7 +143,7 @@ SubShader {
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy)); pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float scale = rsqrt(dot(pixelSize, pixelSize)); float scale = rsqrt(dot(pixelSize, pixelSize));
scale *= abs(input.texcoord1.y) * _GradientScale * (_Sharpness + 1); scale *= abs(input.texcoord0.w) * _GradientScale * (_Sharpness + 1);
if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert))))); if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0; float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
@@ -176,6 +181,7 @@ SubShader {
// Generate UV for the Masking Texture // Generate UV for the Masking Texture
float4 clampedRect = clamp(_ClipRect, -2e10, 2e10); float4 clampedRect = clamp(_ClipRect, -2e10, 2e10);
float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy); float2 maskUV = (vert.xy - clampedRect.xy) / (clampedRect.zw - clampedRect.xy);
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
// Structure for pixel shader // Structure for pixel shader
pixel_t output = { pixel_t output = {
@@ -184,7 +190,7 @@ SubShader {
outlineColor, outlineColor,
float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y), float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y),
half4(scale, bias - outline, bias + outline, bias), half4(scale, bias - outline, bias + outline, bias),
half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)), half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy)),
#if (UNDERLAY_ON | UNDERLAY_INNER) #if (UNDERLAY_ON | UNDERLAY_INNER)
float4(input.texcoord0 + layerOffset, input.color.a, 0), float4(input.texcoord0 + layerOffset, input.color.a, 0),
half2(layerScale, layerBias), half2(layerScale, layerBias),

View File

@@ -6,14 +6,14 @@
Shader "TextMeshPro/Mobile/Distance Field Overlay" { Shader "TextMeshPro/Mobile/Distance Field Overlay" {
Properties { Properties {
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1) _FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0 _FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1) _OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0 _OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0 _OutlineSoftness ("Outline Softness", Range(0,1)) = 0
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0,.5) _UnderlayColor ("Border Color", Color) = (0,0,0,.5)
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0 _UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0 _UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0 _UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
@@ -93,16 +93,18 @@ SubShader {
#include "UnityUI.cginc" #include "UnityUI.cginc"
#include "TMPro_Properties.cginc" #include "TMPro_Properties.cginc"
struct vertex_t { struct vertex_t
{
UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_INPUT_INSTANCE_ID
float4 vertex : POSITION; float4 vertex : POSITION;
float3 normal : NORMAL; float3 normal : NORMAL;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float4 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1; float2 texcoord1 : TEXCOORD1;
}; };
struct pixel_t { struct pixel_t
{
UNITY_VERTEX_INPUT_INSTANCE_ID UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO UNITY_VERTEX_OUTPUT_STEREO
float4 vertex : SV_POSITION; float4 vertex : SV_POSITION;
@@ -111,12 +113,16 @@ SubShader {
float4 texcoord0 : TEXCOORD0; // Texture UV, Mask UV float4 texcoord0 : TEXCOORD0; // Texture UV, Mask UV
half4 param : TEXCOORD1; // Scale(x), BiasIn(y), BiasOut(z), Bias(w) half4 param : TEXCOORD1; // Scale(x), BiasIn(y), BiasOut(z), Bias(w)
half4 mask : TEXCOORD2; // Position in clip space(xy), Softness(zw) half4 mask : TEXCOORD2; // Position in clip space(xy), Softness(zw)
#if (UNDERLAY_ON | UNDERLAY_INNER) #if (UNDERLAY_ON | UNDERLAY_INNER)
float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved float4 texcoord1 : TEXCOORD3; // Texture UV, alpha, reserved
half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y) half2 underlayParam : TEXCOORD4; // Scale(x), Bias(y)
#endif #endif
}; };
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
pixel_t VertShader(vertex_t input) pixel_t VertShader(vertex_t input)
{ {
@@ -127,7 +133,7 @@ SubShader {
UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord1.y, 0); float bold = step(input.texcoord0.w, 0);
float4 vert = input.vertex; float4 vert = input.vertex;
vert.x += _VertexOffsetX; vert.x += _VertexOffsetX;
@@ -138,7 +144,7 @@ SubShader {
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy)); pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float scale = rsqrt(dot(pixelSize, pixelSize)); float scale = rsqrt(dot(pixelSize, pixelSize));
scale *= abs(input.texcoord1.y) * _GradientScale * (_Sharpness + 1); scale *= abs(input.texcoord0.w) * _GradientScale * (_Sharpness + 1);
if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert))))); if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0; float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
@@ -182,7 +188,8 @@ SubShader {
output.outlineColor = outlineColor; output.outlineColor = outlineColor;
output.texcoord0 = float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y); output.texcoord0 = float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y);
output.param = half4(scale, bias - outline, bias + outline, bias); output.param = half4(scale, bias - outline, bias + outline, bias);
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy)); const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
#if (UNDERLAY_ON || UNDERLAY_INNER) #if (UNDERLAY_ON || UNDERLAY_INNER)
output.texcoord1 = float4(input.texcoord0 + layerOffset, input.color.a, 0); output.texcoord1 = float4(input.texcoord0 + layerOffset, input.color.a, 0);
output.underlayParam = half2(layerScale, layerBias); output.underlayParam = half2(layerScale, layerBias);

View File

@@ -6,14 +6,14 @@
Shader "TextMeshPro/Mobile/Distance Field SSD" { Shader "TextMeshPro/Mobile/Distance Field SSD" {
Properties { Properties {
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1) _FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0 _FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1) _OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0 _OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0 _OutlineSoftness ("Outline Softness", Range(0,1)) = 0
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0,.5) _UnderlayColor ("Border Color", Color) = (0,0,0,.5)
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0 _UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0 _UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0 _UnderlayDilate ("Border Dilate", Range(-1,1)) = 0

View File

@@ -6,14 +6,14 @@
Shader "TextMeshPro/Mobile/Distance Field" { Shader "TextMeshPro/Mobile/Distance Field" {
Properties { Properties {
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1) _FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0 _FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1) _OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0 _OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0 _OutlineSoftness ("Outline Softness", Range(0,1)) = 0
[HDR]_UnderlayColor ("Border Color", Color) = (0,0,0,.5) _UnderlayColor ("Border Color", Color) = (0,0,0,.5)
_UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0 _UnderlayOffsetX ("Border OffsetX", Range(-1,1)) = 0
_UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0 _UnderlayOffsetY ("Border OffsetY", Range(-1,1)) = 0
_UnderlayDilate ("Border Dilate", Range(-1,1)) = 0 _UnderlayDilate ("Border Dilate", Range(-1,1)) = 0
@@ -98,7 +98,7 @@ SubShader {
float4 vertex : POSITION; float4 vertex : POSITION;
float3 normal : NORMAL; float3 normal : NORMAL;
fixed4 color : COLOR; fixed4 color : COLOR;
float2 texcoord0 : TEXCOORD0; float4 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1; float2 texcoord1 : TEXCOORD1;
}; };
@@ -117,6 +117,8 @@ SubShader {
#endif #endif
}; };
float _UIMaskSoftnessX;
float _UIMaskSoftnessY;
pixel_t VertShader(vertex_t input) pixel_t VertShader(vertex_t input)
{ {
@@ -127,7 +129,7 @@ SubShader {
UNITY_TRANSFER_INSTANCE_ID(input, output); UNITY_TRANSFER_INSTANCE_ID(input, output);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
float bold = step(input.texcoord1.y, 0); float bold = step(input.texcoord0.w, 0);
float4 vert = input.vertex; float4 vert = input.vertex;
vert.x += _VertexOffsetX; vert.x += _VertexOffsetX;
@@ -138,7 +140,7 @@ SubShader {
pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy)); pixelSize /= float2(_ScaleX, _ScaleY) * abs(mul((float2x2)UNITY_MATRIX_P, _ScreenParams.xy));
float scale = rsqrt(dot(pixelSize, pixelSize)); float scale = rsqrt(dot(pixelSize, pixelSize));
scale *= abs(input.texcoord1.y) * _GradientScale * (_Sharpness + 1); scale *= abs(input.texcoord0.w) * _GradientScale * (_Sharpness + 1);
if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert))))); if(UNITY_MATRIX_P[3][3] == 0) scale = lerp(abs(scale) * (1 - _PerspectiveFilter), scale, abs(dot(UnityObjectToWorldNormal(input.normal.xyz), normalize(WorldSpaceViewDir(vert)))));
float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0; float weight = lerp(_WeightNormal, _WeightBold, bold) / 4.0;
@@ -182,7 +184,9 @@ SubShader {
output.outlineColor = outlineColor; output.outlineColor = outlineColor;
output.texcoord0 = float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y); output.texcoord0 = float4(input.texcoord0.x, input.texcoord0.y, maskUV.x, maskUV.y);
output.param = half4(scale, bias - outline, bias + outline, bias); output.param = half4(scale, bias - outline, bias + outline, bias);
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * half2(_MaskSoftnessX, _MaskSoftnessY) + pixelSize.xy));
const half2 maskSoftness = half2(max(_UIMaskSoftnessX, _MaskSoftnessX), max(_UIMaskSoftnessY, _MaskSoftnessY));
output.mask = half4(vert.xy * 2 - clampedRect.xy - clampedRect.zw, 0.25 / (0.25 * maskSoftness + pixelSize.xy));
#if (UNDERLAY_ON || UNDERLAY_INNER) #if (UNDERLAY_ON || UNDERLAY_INNER)
output.texcoord1 = float4(input.texcoord0 + layerOffset, input.color.a, 0); output.texcoord1 = float4(input.texcoord0 + layerOffset, input.color.a, 0);
output.underlayParam = half2(layerScale, layerBias); output.underlayParam = half2(layerScale, layerBias);

View File

@@ -7,15 +7,15 @@ Shader "TextMeshPro/Mobile/Distance Field (Surface)" {
Properties { Properties {
_FaceTex ("Fill Texture", 2D) = "white" {} _FaceTex ("Fill Texture", 2D) = "white" {}
[HDR]_FaceColor ("Fill Color", Color) = (1,1,1,1) _FaceColor ("Fill Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0 _FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1) _OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineTex ("Outline Texture", 2D) = "white" {} _OutlineTex ("Outline Texture", 2D) = "white" {}
_OutlineWidth ("Outline Thickness", Range(0, 1)) = 0 _OutlineWidth ("Outline Thickness", Range(0, 1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0 _OutlineSoftness ("Outline Softness", Range(0,1)) = 0
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5) _GlowColor ("Color", Color) = (0, 1, 0, 0.5)
_GlowOffset ("Offset", Range(-1,1)) = 0 _GlowOffset ("Offset", Range(-1,1)) = 0
_GlowInner ("Inner", Range(0,1)) = 0.05 _GlowInner ("Inner", Range(0,1)) = 0.05
_GlowOuter ("Outer", Range(0,1)) = 0.05 _GlowOuter ("Outer", Range(0,1)) = 0.05
@@ -99,7 +99,8 @@ SubShader {
#pragma multi_compile_shadowcaster #pragma multi_compile_shadowcaster
#include "UnityCG.cginc" #include "UnityCG.cginc"
struct v2f { struct v2f
{
V2F_SHADOW_CASTER; V2F_SHADOW_CASTER;
float2 uv : TEXCOORD1; float2 uv : TEXCOORD1;
float2 uv2 : TEXCOORD3; float2 uv2 : TEXCOORD3;

View File

@@ -4,10 +4,10 @@ Properties {
_FaceTex ("Fill Texture", 2D) = "white" {} _FaceTex ("Fill Texture", 2D) = "white" {}
_FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0 _FaceUVSpeedX ("Face UV Speed X", Range(-5, 5)) = 0.0
_FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0 _FaceUVSpeedY ("Face UV Speed Y", Range(-5, 5)) = 0.0
[HDR]_FaceColor ("Fill Color", Color) = (1,1,1,1) _FaceColor ("Fill Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0 _FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1) _OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineTex ("Outline Texture", 2D) = "white" {} _OutlineTex ("Outline Texture", 2D) = "white" {}
_OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0 _OutlineUVSpeedX ("Outline UV Speed X", Range(-5, 5)) = 0.0
_OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0 _OutlineUVSpeedY ("Outline UV Speed Y", Range(-5, 5)) = 0.0
@@ -28,12 +28,12 @@ Properties {
_ReflectOutlineColor ("Outline Color", Color) = (0,0,0,1) _ReflectOutlineColor ("Outline Color", Color) = (0,0,0,1)
_Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ } _Cube ("Reflection Cubemap", Cube) = "black" { /* TexGen CubeReflect */ }
_EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0) _EnvMatrixRotation ("Texture Rotation", vector) = (0, 0, 0, 0)
[HDR]_SpecColor ("Specular Color", Color) = (0,0,0,1) _SpecColor ("Specular Color", Color) = (0,0,0,1)
_FaceShininess ("Face Shininess", Range(0,1)) = 0 _FaceShininess ("Face Shininess", Range(0,1)) = 0
_OutlineShininess ("Outline Shininess", Range(0,1)) = 0 _OutlineShininess ("Outline Shininess", Range(0,1)) = 0
[HDR]_GlowColor ("Color", Color) = (0, 1, 0, 0.5) _GlowColor ("Color", Color) = (0, 1, 0, 0.5)
_GlowOffset ("Offset", Range(-1,1)) = 0 _GlowOffset ("Offset", Range(-1,1)) = 0
_GlowInner ("Inner", Range(0,1)) = 0.05 _GlowInner ("Inner", Range(0,1)) = 0.05
_GlowOuter ("Outer", Range(0,1)) = 0.05 _GlowOuter ("Outer", Range(0,1)) = 0.05
@@ -118,7 +118,8 @@ SubShader {
#pragma multi_compile_shadowcaster #pragma multi_compile_shadowcaster
#include "UnityCG.cginc" #include "UnityCG.cginc"
struct v2f { struct v2f
{
V2F_SHADOW_CASTER; V2F_SHADOW_CASTER;
float2 uv : TEXCOORD1; float2 uv : TEXCOORD1;
float2 uv2 : TEXCOORD3; float2 uv2 : TEXCOORD3;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a3d800b099a06e0478fb790c5e79057a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

Some files were not shown because too many files have changed in this diff Show More