Search Unity

I modified TMP_SDF-Surface and just want to make sure I did nothing dumb.

Discussion in 'UGUI & TextMesh Pro' started by awardell, Dec 15, 2021.

  1. awardell

    awardell

    Joined:
    Feb 5, 2014
    Posts:
    71
    I want shadows ON my 3D text, and I'm willing to give up blended transparency. I copied and modified TMP_SDF-Surface.shader and changed the following lines:

    70.
    Tags { "Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout" }

    76.
    #pragma surface PixShader BlinnPhong alphatest:_AlphaCutoff fullforwardshadows vertex:VertShader nolightmap nodirlightmap

    and added
    _AlphaCutoff       ("Alpha Cutoff", Range (0,1)) = 0.9
    to the end of Properties.


    My questions are: will this have unforeseen consequences on text rendering using this shader? Is there anything else I need to do or should be careful of?
     
  2. awardell

    awardell

    Joined:
    Feb 5, 2014
    Posts:
    71
    Update: There was indeed a consequence! It causes very bad aliasing which worsens further from the camera. I see now that partial transparency actually is quite important for properly rendering the edges of the text.

    Has anyone found a good way for TMP Text to receive shadows?

    One potentially helpful detail is that I intend to position the text against a flat backdrop (like a street sign). If there were a way instead of rendering text to unique quads per character that I could render it onto one mesh, then I wouldn't need alpha and could entirely use it for color blending.

    Another potential option seems like I could write two shaders, one to write the color with lighting to a buffer and the other to render with transparency.

    Another potential option seems to be creating a custom render pipeline or a custom pass in HDRP to let me have blended alpha with transparency.


    All of these options seem very difficult :p so I would appreciate any advice!