Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Oliver 2 · Jun 10, 2010 at 01:58 PM · shadertexturefontoutline3dtext

3DText Outline Shader

Hallo, Im using the Shader of http://www.unifycommunity.com/wiki/index.php?title=3DText

The Shader: 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 On Fog { Mode Off } Blend SrcAlpha OneMinusSrcAlpha Pass { Color [_Color] SetTexture [_MainTex] { combine primary, texture * primary } } } }

Now I was wondering if there is a way to modify this Shader to make a outline around the 3Dtext.

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 adam718 · Mar 22, 2012 at 08:42 AM 0
Share

That is my problems too. If anyone knows how to implement it, please help. I am dark in shader.

Help.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by x4000 · Sep 23, 2010 at 07:06 PM

If performance isn't a concern (heh), the way that I've solved this in the past is to draw the text five times. Basically, given a BorderColor and a InnerColor, if you want to draw at X, Y, Z the pseudocode is:

Draw Font with BorderColor at X-1, Y, Z-1
Draw Font with BorderColor at X+1, Y, Z-1
Draw Font with BorderColor at X, Y-1, Z-1
Draw Font with BorderColor at X, Y+1, Z-1
Draw Font with InnerColor at X, Y, Z

That obviously increases the load of drawing the text 5X, but sometimes in menus or for a small amount of text that is not really a worry. We do that in our Unity 3D game Tidalis, for example. It works with 3DText or render text, either way.

One caveat is that sometimes with certain fonts this may not look very good because of the borders being offset poorly. In those cases, you can do an (even more expensive) 9-stage draw process, as follows:

Draw Font with BorderColor at X-1, Y, Z-1
Draw Font with BorderColor at X+1, Y, Z-1
Draw Font with BorderColor at X, Y-1, Z-1
Draw Font with BorderColor at X, Y+1, Z-1
Draw Font with BorderColor at X-1, Y-1, Z-1
Draw Font with BorderColor at X+1, Y+1, Z-1
Draw Font with BorderColor at X+1, Y-1, Z-1
Draw Font with BorderColor at X-1, Y+1, Z-1
Draw Font with InnerColor at X, Y, Z

Talk about inefficient, but it looks really awesome in most cases. With a thick font, you can even do extra large borders (more than 1px) by simply using a variable in place of all those 1 consts for X and Y.

You can of course combine this with something like a RenderTexture, and then save the result for later use as a single texture, when performance is a concern (as it usually is). That way, if you're spending either 5x or 9x the normal render time for a single frame, that's no concern for any game -- then after that it's got a simple prerendered texture of the text, which would be more efficient than using the 3D text to draw the same string, anyway, to my knowledge.

So, despite the poor performance of this at first glance, there are tricky ways you can go about making it perform well. Granted, I'd love to have something simpler and without the need for these sorts of secondary steps, but this is the best I've been able to find to meet my own similar needs.

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 oliver-jones · Sep 24, 2013 at 03:30 PM 0
Share

Where would this 'Draw Font with BorderColor' be placed?

avatar image
0

Answer by Kiloblargh · Feb 19, 2013 at 07:41 PM

You don't need to modify the shader, just modify the generated font material. Check this out on the script wiki... You should edit a bold version of the font and shrink selection in Photoshop or "stroke inside" rather than adding the outline around the edges, as the font texture letters are already packed as closely as they can be without running onto the next character's space.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Temperature map shader 0 Answers

Shader Edit Help: 2D Outline Coloring 2 Answers

3d text mesh hides plane object 1 Answer

Strange Error: Shader wants normals, but the mesh doesn't have them 3 Answers

Combine Shaders 0 Answers


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