I have a Unity GameObject with a TextMeshPro component (let's call this object "White Letter"). The Font Material is using the "TextMeshPro/Distance Field" shader. This works perfectly.

I'd like to make the White Letter "wiggle" a bit using a shader (see below). I'd like the effect to look something like this (made using After Effects):


Here's how I combined my Font Material together with this WiggleTextDF Shader:

  • I created a WiggleTextDF shader.
  • I created a WiggleTextDF Material and set the shader to WiggleTextDF shader.
  • I added a Displacement Map and Texture to the WiggleTextDF Material (here they are):

enter image description hereenter image description here

  • Finally, I applied this Material (as Element 0) to the Mesh Renderer for the White Letter GameObject.

Every time I do that last step... the font stops rendering and the TextMeshPro renders as a pink box.

Any advice on how to move forward?

Shader "WiggleTextDF" {
Properties {
    _MainTex ("Texture", 2D) = "white" {}
    _DisplacementMap ("Displacement Map", 2D) = "white" {}
    _WiggleAmount ("Wiggle Amount", Range(0, 1)) = 0.1
    _WiggleSpeed ("Wiggle Speed", Range(0, 10)) = 5
SubShader {
    Tags {"Queue"="Transparent" "RenderType"="Transparent"}
    Pass {
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"
        #include "UnityTextMeshPro.cginc"

        struct appdata {
            float4 vertex : POSITION;
            float2 uv : TEXCOORD0;

        struct v2f {
            float2 uv : TEXCOORD0;
            float4 vertex : SV_POSITION;

        sampler2D _MainTex;
        sampler2D _DisplacementMap;
        float _WiggleAmount;
        float _WiggleSpeed;

        v2f vert (appdata v) {
            v2f o;
            o.vertex = UnityObjectToClipPos(v.vertex);
            o.uv = v.uv;
            return o;

        fixed4 frag (v2f i) : SV_Target {
            // Sample the displacement map texture to get the displacement value
            float4 displacement = tex2D(_DisplacementMap, i.uv);

            // Calculate the wiggle offset based on the displacement value and time
            float2 wiggleOffset = sin(_Time.y * _WiggleSpeed + i.uv * 10) * displacement.rg * _WiggleAmount;

            // Apply the offset to the texture coordinates
            float2 uv = i.uv + wiggleOffset;

            // Sample the main texture using the offset texture coordinates
            fixed4 col = tex2D(_MainTex, uv);

            UNITY_APPLY_FOG_COLOR(i.fogCoord, col);
            return UNITY_PREPARE_FINAL_COLOR(col);
FallBack "TextMeshPro/Distance Field"


  • \$\begingroup\$ How did you try combining these shaders? \$\endgroup\$
    – DMGregory
    May 10 at 13:45
  • \$\begingroup\$ This is my first project involving shaders, and I don't know what I'm doing. I created a Wiggle Material using the new Shader, and then dragged the Font Material onto the Wiggle Material. Then I dragged the Wiggle Material onto the GameObject with the TextMeshPro component. \$\endgroup\$
    – kanamekun
    May 10 at 13:57
  • \$\begingroup\$ Dragging a material onto a material isn't really a thing in Unity. You can drag a shader into a material, or a material onto an object with a renderer, but materials don't compose by dragging, so I'm a bit confused by what you're describing. \$\endgroup\$
    – DMGregory
    May 10 at 14:10
  • \$\begingroup\$ I am also confused, any advice or help would be appreciated! :D \$\endgroup\$
    – kanamekun
    May 10 at 14:10
  • \$\begingroup\$ @DMGregory I added some more details on the exact steps I took try and apply the new shader to a new material. \$\endgroup\$
    – kanamekun
    May 12 at 8:53


You must log in to answer this question.

Browse other questions tagged .