-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [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
- Loading branch information
Unity Technologies
committed
Apr 24, 2020
1 parent
6ee2477
commit 9382215
Showing
63 changed files
with
3,009 additions
and
5,392 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
// Simplified SDF shader: | ||
// - No Shading Option (bevel / bump / env map) | ||
// - No Glow Option | ||
// - Softness is applied on both side of the outline | ||
|
||
Shader "Hidden/TextMeshPro/Internal/Distance Field SSD" { | ||
|
||
Properties { | ||
_FaceColor ("Face Color", Color) = (1,1,1,1) | ||
_FaceDilate ("Face Dilate", Range(-1,1)) = 0 | ||
|
||
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0.02 | ||
|
||
_WeightNormal ("Weight Normal", float) = 0 | ||
_WeightBold ("Weight Bold", float) = .5 | ||
|
||
_MainTex ("Font Atlas", 2D) = "white" {} | ||
_TextureWidth ("Texture Width", float) = 512 | ||
_TextureHeight ("Texture Height", float) = 512 | ||
_GradientScale ("Gradient Scale", float) = 5 | ||
_ScaleX ("Scale X", float) = 1 | ||
_ScaleY ("Scale Y", float) = 1 | ||
_Sharpness ("Sharpness", Range(-1,1)) = 0 | ||
|
||
_VertexOffsetX ("Vertex OffsetX", float) = 0 | ||
_VertexOffsetY ("Vertex OffsetY", float) = 0 | ||
|
||
_ColorMask ("Color Mask", Float) = 15 | ||
} | ||
|
||
SubShader { | ||
Tags | ||
{ | ||
"ForceSupported" = "True" | ||
} | ||
|
||
Lighting Off | ||
Blend One OneMinusSrcAlpha | ||
Cull Off | ||
ZWrite Off | ||
ZTest Always | ||
|
||
Pass { | ||
CGPROGRAM | ||
#pragma vertex VertShader | ||
#pragma fragment PixShader | ||
|
||
#include "UnityCG.cginc" | ||
#include "TMP_Properties.cginc" | ||
|
||
sampler2D _GUIClipTexture; | ||
uniform float4x4 unity_GUIClipTextureMatrix; | ||
|
||
struct vertex_t { | ||
float4 vertex : POSITION; | ||
float3 normal : NORMAL; | ||
fixed4 color : COLOR; | ||
float2 texcoord0 : TEXCOORD0; | ||
float2 texcoord1 : TEXCOORD1; | ||
}; | ||
|
||
struct pixel_t { | ||
float4 vertex : SV_POSITION; | ||
fixed4 faceColor : COLOR; | ||
float2 texcoord0 : TEXCOORD0; | ||
float2 clipUV : TEXCOORD1; | ||
}; | ||
|
||
|
||
pixel_t VertShader(vertex_t input) | ||
{ | ||
// Does not handle simulated bold correctly. | ||
|
||
float4 vert = input.vertex; | ||
vert.x += _VertexOffsetX; | ||
vert.y += _VertexOffsetY; | ||
float4 vPosition = UnityObjectToClipPos(vert); | ||
|
||
float opacity = input.color.a; | ||
|
||
fixed4 faceColor = fixed4(input.color.rgb, opacity) * _FaceColor; | ||
faceColor.rgb *= faceColor.a; | ||
|
||
// Generate UV for the Clip Texture | ||
float3 eyePos = UnityObjectToViewPos(input.vertex); | ||
float2 clipUV = mul(unity_GUIClipTextureMatrix, float4(eyePos.xy, 0, 1.0)); | ||
|
||
// Structure for pixel shader | ||
pixel_t output = { | ||
vPosition, | ||
faceColor, | ||
float2(input.texcoord0.x, input.texcoord0.y), | ||
clipUV, | ||
}; | ||
|
||
return output; | ||
} | ||
|
||
half transition(half2 range, half distance) | ||
{ | ||
return smoothstep(range.x, range.y, distance); | ||
} | ||
|
||
// PIXEL SHADER | ||
fixed4 PixShader(pixel_t input) : SV_Target | ||
{ | ||
half distanceSample = tex2D(_MainTex, input.texcoord0).a; | ||
half smoothing = fwidth(distanceSample) * (1 - _Sharpness) + _OutlineSoftness; | ||
half contour = 0.5 - _FaceDilate * 0.5; | ||
half2 edgeRange = half2(contour - smoothing, contour + smoothing); | ||
|
||
half4 c = input.faceColor; | ||
|
||
half edgeTransition = transition(edgeRange, distanceSample); | ||
c *= edgeTransition; | ||
|
||
c *= tex2D(_GUIClipTexture, input.clipUV).a; | ||
|
||
return c; | ||
} | ||
ENDCG | ||
} | ||
} | ||
|
||
CustomEditor "TMPro.EditorUtilities.TMP_SDFShaderGUI" | ||
} |
2 changes: 1 addition & 1 deletion
2
...aders/TMP_SDF Internal Editor.shader.meta → .../Shaders/TMP_SDF Internal SSD.shader.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.