GithubHelp home page GithubHelp logo

[v1] Using this soft mask with text mesh pro in unity 2023 makes the text blocky like the shader dosen't work about softmaskforugui HOT 7 OPEN

TheEye2108 avatar TheEye2108 commented on August 25, 2024
[v1] Using this soft mask with text mesh pro in unity 2023 makes the text blocky like the shader dosen't work

from softmaskforugui.

Comments (7)

mob-sakai avatar mob-sakai commented on August 25, 2024 2

Sorry for my late reply.

The TextMeshPro shader does not work correctly in the following environments due to updates:

  • Unity 2023.2 and Unity 6 (TextMeshPro is built into uGUI)
  • TextMeshPro v3.2.0-pre and v4.0.0-pre

As a workaround, please try the following:

  • If you have already imported the TextMeshPro Support sample, delete the folder.
  • Extract the following zip file into the Assets folder:
  • Add the shaders to Project Settings > Shader Settings > Always Included Shaders

from softmaskforugui.

AgainJBC avatar AgainJBC commented on August 25, 2024

Seems to happen for >TextMeshPro/Distance Field< sharder .... the blocky appearance is fixed when I switch to >TextMeshPro/Mobile/Distance Field< but there still is some artifact looking like underline on each letter

Edit: Just found out that changing Vertical Mapping for the TextMeshPro component to "line" or "paragraph" seem to fix the problem.

Edit 2: No ... after further usage I found there are still some issues with the fonts looking differently or completely buggy in most scenarios :(

from softmaskforugui.

karyol avatar karyol commented on August 25, 2024

I managed to fix it by copying the default Distance Field shader from TMP and making minor adjustments.
First changed the shader name to Hidden/TextMeshPro/Distance Field (SoftMaskable).
Second change is in Pass. Edit pragmas and includes like this:

#pragma target 3.0
#pragma vertex VertShader
#pragma fragment PixShader
#pragma shader_feature __ BEVEL_ON
#pragma shader_feature __ UNDERLAY_ON UNDERLAY_INNER
#pragma shader_feature __ GLOW_ON

#pragma multi_compile __ UNITY_UI_CLIP_RECT
#pragma multi_compile __ UNITY_UI_ALPHACLIP

#include "UnityCG.cginc"
#include "UnityUI.cginc"
#if UNITY_VERSION < 201910
  #include "Assets/TextMesh Pro/Resources/Shaders/TMPro_Properties.cginc"
  #include "Assets/TextMesh Pro/Resources/Shaders/TMPro.cginc"
#else
  #include "Assets/TextMesh Pro/Shaders/TMPro_Properties.cginc"
  #include "Assets/TextMesh Pro/Shaders/TMPro.cginc"
#endif

#include "Packages/com.coffee.softmask-for-ugui/Shaders/SoftMask.cginc"
#pragma shader_feature __ SOFTMASK_EDITOR

With softmask editor included you can add softmask to your text but you need to know the world position and there comes the third change.
Add float4 worldPosition : TEXCOORD6; to struct pixel_t.
Then you need to add world position from input to output output.worldPosition = input.position; in VertShader just before returning the output.
And finally you can add the softmask into PixShader just before returning faceColor faceColor *= SoftMask(input.position, input.worldPosition);.
It works for soft masking the TMPro texts for me but i still do not managed to make it work for TMP inline sprites.

from softmaskforugui.

TheEye2108 avatar TheEye2108 commented on August 25, 2024

I managed to make it work with unities built in soft mask but then we had to downgrade to unity 2022 and there we had other problems so we just scraped the soft mask part and just went with the hard mask ore just mask :D.
But ty for posting this i will try and implement it for testing.

from softmaskforugui.

SeanNi1221 avatar SeanNi1221 commented on August 25, 2024

Make sure the TextMeshPro Support package is imported into your Asset folder as stated in
https://github.com/mob-sakai/SoftMaskForUGUI?tab=readme-ov-file#usage-with-textmeshpro
I think the author @mob-sakai maded it a bit misleading putting the resources under a folder called "Samples".

from softmaskforugui.

akpil avatar akpil commented on August 25, 2024

Make sure the TextMeshPro Support package is imported into your Asset folder as stated in https://github.com/mob-sakai/SoftMaskForUGUI?tab=readme-ov-file#usage-with-textmeshpro I think the author @mob-sakai maded it a bit misleading putting the resources under a folder called "Samples".

I am experiencing the same issue as described in this thread, and I have definitely installed the package you mentioned. (If it isn't installed, it appears in magenta.) However, even after installation, the color that was magenta just shows up as a black (or the color of the font) rectangle. In the 2023 version, the same issue occurs no matter how I bake the font asset, whereas in version 2022.3.x, everything works perfectly with the same settings. Therefore, the method you suggested does not solve the problem.

from softmaskforugui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.