Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
10
Question by DaveA · Jan 26, 2011 at 12:49 AM · shaderrenderingtextz-depth

Text mesh (font material) renders on top of everything, any way to change that?

I have these objects with some text on them floating in my space (labeling things as it were). My problem is that apparently, text is drawn last, so it is visible always, even if it should be occluded by intervening solid objects. Is there a way to fix that? Do I have to muck with the shader on it?

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 MFKJ · Jun 11, 2020 at 08:48 AM 0
Share

Its 2020, For new Text $$anonymous$$esh Pro you can use distance field shader here is the demo https://youtu.be/7HnixlwlQ5Q

7 Replies

· Add your reply
  • Sort: 
avatar image
11
Best Answer

Answer by Jessy · Jan 26, 2011 at 01:13 AM

Yes, you have to use a different shader. Here's one to start with:

http://www.unifycommunity.com/wiki/index.php?title=3DText

Comment
Add comment · Show 4 · 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 DaveA · Jan 29, 2011 at 07:36 PM 0
Share

Perfect. And works on mobile too!

avatar image logic.cpp · Apr 16, 2013 at 11:34 AM 0
Share

Doesn't colorize with <color=red>rich tags</color> ...

avatar image VolureDarkAngel · Nov 20, 2013 at 06:15 PM 0
Share

Wow. I didnt even know the regular one did that. Nice to learn something new.

avatar image Andrei.Farkas · Aug 12, 2014 at 01:34 PM 4
Share

The link is now broken. Can someone post here the shader? Thank you very much.

avatar image
7

Answer by Ngoc Ngo · Aug 22, 2014 at 12:30 AM

The shader has been moved here: http://wiki.unity3d.com/index.php?title=3DText

     Shader "GUI/3D Text Shader" { 
     Properties { 
        _MainTex ("Font Texture", 2D) = "white" {} 
        _Color ("Text Color", Color) = (1,1,1,1) 
     } 
     
     SubShader { 
        Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" } 
        Lighting Off Cull Off ZWrite Off Fog { Mode Off } 
        Blend SrcAlpha OneMinusSrcAlpha 
        Pass { 
           Color [_Color] 
           SetTexture [_MainTex] { 
              combine primary, texture * primary 
           } 
        } 
     } 
 }

This one won't use the color set with TextMesh though.

Comment
Add comment · Show 4 · 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 Eldoir · Oct 10, 2017 at 09:08 AM 1
Share

Worked perfectly for me. As you said, the shader "disables" the color of Text$$anonymous$$esh, but you can set the color with the Shader ins$$anonymous$$d of the Text$$anonymous$$esh, so it's pretty much the same result. I attached a pic for future readers.alt text

pic.png (29.3 kB)
avatar image jvhgamer Eldoir · Dec 07, 2017 at 09:10 PM 0
Share

@Eldoir Is it possible to do this for GUI elements such as Buttons as well? Fleshed out detailed question post link here. Unsure how this solution translates to Buttons as they allow for a variety of color options based on how they are interacted with (i.e.: Normal, Highlighted, Pressed, Disabled)

avatar image AtifatGamy · Oct 05, 2018 at 11:19 AM 0
Share

Thanks allot This works on $$anonymous$$e...

avatar image sabint · Oct 05, 2021 at 08:28 AM 0
Share

But where is the font texture?

avatar image
4

Answer by tinytiger2424 · Jul 05, 2016 at 06:11 AM

I just got this working in my most recent project. That link someone else posted has instructions how to use it and you can set the colour too! (Link: http://wiki.unity3d.com/index.php?title=3DText)

Code

 Shader "GUI/3D Text Shader" { 
     Properties {
         _MainTex ("Font Texture", 2D) = "white" {}
         _Color ("Text Color", Color) = (1,1,1,1)
     }
  
     SubShader {
         Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
         Lighting Off Cull Off ZWrite Off Fog { Mode Off }
         Blend SrcAlpha OneMinusSrcAlpha
         Pass {
             Color [_Color]
             SetTexture [_MainTex] {
                 combine primary, texture * primary
             }
         }
     }
 }

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
3

Answer by Gan_HOPE326 · Jul 19, 2016 at 04:03 PM

This is very old and may not be relevant any more, but in case someone still has this issue I just found out a super-easy solution to this problem: just set everything else's material's Rendering Mode to "transparent". In that way the right order of drawing is preserved.

Comment
Add comment · Show 3 · 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 jmerrin · Aug 09, 2016 at 03:18 PM 0
Share

You are a godsend. That worked perfectly.

avatar image ModLunar · Jun 06, 2018 at 02:24 AM 0
Share

Wouldn't that remove all those materials' support for deferred rendering though?

avatar image gavriktonio · Dec 21, 2018 at 10:09 AM 0
Share

Uhm, this is a very bad idea. Rendering trasparent things is much more performance intensive, among other things that it will mess up

avatar image
1

Answer by Cascho01 · Nov 23, 2015 at 11:52 AM

@Ngoc Ngo Any way to get the color set with TextMesh working?

Comment
Add comment · Show 1 · 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 Ngoc Ngo · Nov 23, 2015 at 12:00 PM 0
Share

I don't know, but I haven't checked in a year, so maybe somebody has done it somewhere. $$anonymous$$eep looking. Good luck! And don't forget to post it here once you found a way, it may help someone.

  • 1
  • 2
  • ›

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

16 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

Related Questions

2.5D perspective rendering order challenges 2 Answers

Standard Shader Still Visible through Stencil Shader 0 Answers

What is "sampler_ScreenTextures_linear_clamp" and what other options do I have in shaders? 1 Answer

Any way to get a render that shows profile edges? 1 Answer

How do I enable DOTS Instancing on a material/shadergraph 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