Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SRJ_Amat · Jul 07, 2018 at 05:58 AM · shadertextmeshbillboardbillboards

Give textmesh pro text a billboard effect in shader (Always lookAt camera)

Hey,

I'm working project where I need a floating text effect. But my target hardware is extremely limited and I cant afford to rotate the texts through script to lookAt the camera always. I tried to alter the TextMeshPro/Mobile/Distance Field shader to get that effect and got close. But its not perfect. There is always offset in both axes and rotation pivot seems to be elsewhere. So the text leaves its rect when I look at it from different angles. This is the code I added in the shader right before vertex shader output is added.

vPosition = mul(UNITY_MATRIX_P, mul(UNITY_MATRIX_MV, float4(0.0, 0.0, 0.0, 1.0)) - float4(vert.x, vert.y , vert.z, 0.0) * float4(-unity_ObjectToWorld[0].x , -unity_ObjectToWorld[1].y , unity_ObjectToWorld[1].z, 0.0));

alt text

I need help. Any guidance would be very much appreciated.

capture.png (67.3 kB)
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexagonius · Jul 07, 2018 at 06:29 AM 0
Share

how is rotating a Ui element or the whole canvas straining performance?

4 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by clabe45 · Feb 23, 2019 at 10:37 PM

Match the text's rotation with that of the camera

 public class BillboardText : MonoBehaviour {
     void Update() {
         transform.rotation = Camera.main.transform.rotation;
     }
 }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by outoftunegames · Dec 14, 2020 at 07:11 PM

Almar, has this shader been updated to work with URP?

It would be great to get it working in our current game, we've reverted to aligning the transform, but the your solution worked great before we updated to URP! :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by cspeer504 · Jul 10, 2018 at 11:48 PM

This isn't a shader-based solution, but just in case this might help you:

If you parent the text's transform to the camera's transform, you only have to call lookAt once, in the start function. For example, here is a monoBehavior you can use and attach to your TextMeshPro object:

 using UnityEngine;
 
 public class BillboardText : MonoBehaviour
 {
     void Start ()
     {
         transform.SetParent(Camera.main.transform);
         transform.LookAt(Camera.main.transform);
         transform.localEulerAngles = new Vector3(180f, 180f, 180f);
     }
 }

I have to rotate the text afterwards because it shows completely flip side for me. So I left that in in case it helps you.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Almar · Jul 05, 2019 at 12:16 PM

Sorry for necro'ing this question, but it might help people:

I just put a shader gist online for this. The important part is to disable the dynamic batching!

See: https://gist.github.com/Spongert/b52a24aa110933a918cf47c777fea1c8

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

140 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with unity tree billboarding 0 Answers

Need help with billboard shader 0 Answers

Trying to make the player/npcs be a billboard of a sprite but can't find a way for it to cast and receive shadows 0 Answers

Setting camera to terrain generated billboards 0 Answers

Creating a billboarding surface shader 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges