Skip to content

Commit 9382215

Browse files
author
Unity Technologies
committed
com.unity.textmeshpro@3.0.0-preview.1
## [3.0.0] - 2019-10-30 ### Changes - Updated TMP Examples & Extras to remove CanvasRenderer from text objects in example scenes. - CanvasRenderer component will now be removed from existing text objects that contains this unnecessary component. - Editing a prefab that contains a normal <TextMeshPro> component will no longer open the prefab in Canvas mode. Case #1103782 and Case #1188483
1 parent 6ee2477 commit 9382215

File tree

63 files changed

+3009
-5392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3009
-5392
lines changed

CHANGELOG.md

Lines changed: 11 additions & 128 deletions
Large diffs are not rendered by default.

Editor Resources/Shaders/TMP_SDF Internal Editor.shader

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// Simplified SDF shader:
2+
// - No Shading Option (bevel / bump / env map)
3+
// - No Glow Option
4+
// - Softness is applied on both side of the outline
5+
6+
Shader "Hidden/TextMeshPro/Internal/Distance Field SSD" {
7+
8+
Properties {
9+
_FaceColor ("Face Color", Color) = (1,1,1,1)
10+
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
11+
12+
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0.02
13+
14+
_WeightNormal ("Weight Normal", float) = 0
15+
_WeightBold ("Weight Bold", float) = .5
16+
17+
_MainTex ("Font Atlas", 2D) = "white" {}
18+
_TextureWidth ("Texture Width", float) = 512
19+
_TextureHeight ("Texture Height", float) = 512
20+
_GradientScale ("Gradient Scale", float) = 5
21+
_ScaleX ("Scale X", float) = 1
22+
_ScaleY ("Scale Y", float) = 1
23+
_Sharpness ("Sharpness", Range(-1,1)) = 0
24+
25+
_VertexOffsetX ("Vertex OffsetX", float) = 0
26+
_VertexOffsetY ("Vertex OffsetY", float) = 0
27+
28+
_ColorMask ("Color Mask", Float) = 15
29+
}
30+
31+
SubShader {
32+
Tags
33+
{
34+
"ForceSupported" = "True"
35+
}
36+
37+
Lighting Off
38+
Blend One OneMinusSrcAlpha
39+
Cull Off
40+
ZWrite Off
41+
ZTest Always
42+
43+
Pass {
44+
CGPROGRAM
45+
#pragma vertex VertShader
46+
#pragma fragment PixShader
47+
48+
#include "UnityCG.cginc"
49+
#include "TMP_Properties.cginc"
50+
51+
sampler2D _GUIClipTexture;
52+
uniform float4x4 unity_GUIClipTextureMatrix;
53+
54+
struct vertex_t {
55+
float4 vertex : POSITION;
56+
float3 normal : NORMAL;
57+
fixed4 color : COLOR;
58+
float2 texcoord0 : TEXCOORD0;
59+
float2 texcoord1 : TEXCOORD1;
60+
};
61+
62+
struct pixel_t {
63+
float4 vertex : SV_POSITION;
64+
fixed4 faceColor : COLOR;
65+
float2 texcoord0 : TEXCOORD0;
66+
float2 clipUV : TEXCOORD1;
67+
};
68+
69+
70+
pixel_t VertShader(vertex_t input)
71+
{
72+
// Does not handle simulated bold correctly.
73+
74+
float4 vert = input.vertex;
75+
vert.x += _VertexOffsetX;
76+
vert.y += _VertexOffsetY;
77+
float4 vPosition = UnityObjectToClipPos(vert);
78+
79+
float opacity = input.color.a;
80+
81+
fixed4 faceColor = fixed4(input.color.rgb, opacity) * _FaceColor;
82+
faceColor.rgb *= faceColor.a;
83+
84+
// Generate UV for the Clip Texture
85+
float3 eyePos = UnityObjectToViewPos(input.vertex);
86+
float2 clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0));
87+
88+
// Structure for pixel shader
89+
pixel_t output = {
90+
vPosition,
91+
faceColor,
92+
float2(input.texcoord0.x, input.texcoord0.y),
93+
clipUV,
94+
};
95+
96+
return output;
97+
}
98+
99+
half transition(half2 range, half distance)
100+
{
101+
return smoothstep(range.x, range.y, distance);
102+
}
103+
104+
// PIXEL SHADER
105+
fixed4 PixShader(pixel_t input) : SV_Target
106+
{
107+
half distanceSample = tex2D(_MainTex, input.texcoord0).a;
108+
half smoothing = fwidth(distanceSample) * (1 - _Sharpness) + _OutlineSoftness;
109+
half contour = 0.5 - _FaceDilate * 0.5;
110+
half2 edgeRange = half2(contour - smoothing, contour + smoothing);
111+
112+
half4 c = input.faceColor;
113+
114+
half edgeTransition = transition(edgeRange, distanceSample);
115+
c *= edgeTransition;
116+
117+
c *= tex2D(_GUIClipTexture, input.clipUV).a;
118+
119+
return c;
120+
}
121+
ENDCG
122+
}
123+
}
124+
125+
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI"
126+
}

Editor Resources/Shaders/TMP_SDF Internal Editor.shader.meta renamed to Editor Resources/Shaders/TMP_SDF Internal SSD.shader.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor Resources/Shaders/TMP_SDF_SSD.cginc

Lines changed: 0 additions & 132 deletions
This file was deleted.

Editor Resources/Shaders/TMP_SDF_SSD.cginc.meta

Lines changed: 0 additions & 9 deletions
This file was deleted.
Binary file not shown.
Binary file not shown.

Scripts/Editor/GlyphMetricsPropertyDrawer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2121
// We get Rect since a valid position may not be provided by the caller.
2222
Rect rect = new Rect(position.x, position.y, position.width, 49);
2323

24-
EditorGUI.LabelField(new Rect(rect.x, rect.y - 2.5f, rect.width, 18), new GUIContent("Glyph Metrics"));
24+
EditorGUI.LabelField(rect, new GUIContent("Glyph Metrics"));
2525

26-
EditorGUIUtility.labelWidth = 50f;
27-
EditorGUIUtility.fieldWidth = 15f;
26+
EditorGUIUtility.labelWidth = 30f;
27+
EditorGUIUtility.fieldWidth = 10f;
2828

2929
//GUI.enabled = false;
3030
float width = (rect.width - 75f) / 2;

Scripts/Editor/GlyphRectPropertyDrawer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2121

2222
// We get Rect since a valid position may not be provided by the caller.
2323
Rect rect = new Rect(position.x, position.y, position.width, 49);
24-
EditorGUI.LabelField(new Rect(rect.x, rect.y - 2.5f, rect.width, 18), new GUIContent("Glyph Rect"));
24+
EditorGUI.LabelField(rect, new GUIContent("Glyph Rect"));
2525

26-
EditorGUIUtility.labelWidth = 50f;
27-
EditorGUIUtility.fieldWidth = 20f;
26+
EditorGUIUtility.labelWidth = 30f;
27+
EditorGUIUtility.fieldWidth = 10f;
2828

2929
//GUI.enabled = false;
3030
float width = (rect.width - 75f) / 4;

0 commit comments

Comments
 (0)