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
1
Question by Barrett-Fox · May 25, 2011 at 07:10 PM · shadershaderstransparency3dtextspecularrenderqueue

Why does the 3D Text shader show specular at certain angles?

I'm using the 3D Text shader from the wiki. It solves the z-buffering problems that the standard 3d text shader had. But there are unwanted specular highlights in the transparent areas of the text that appear only when the camera is at certain angles to the 3D text objects.

I'm using two directional lights in the scene. Adjusting their direction or settings or using other light types has no effect.

Here is an example to illustrate:

alt text

...and at a slightly different camera angle:

alt text

Would like to know what's causing this. Could this be solved by a simple change in the shader (including here so its handy)? If not, is there a certain part of the shader to investigate as a starting point?

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 } } } }

Comment
Add comment · Show 2
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 Eric5h5 · May 25, 2011 at 09:52 PM 0
Share

Typo: "operaters" should be "operators".

avatar image Barrett-Fox · May 25, 2011 at 10:04 PM 0
Share

Heh, thx Eagle-Eye-Eric. That would be a typo by a user. $$anonymous$$ust get spellchecking into the comment fields...

2 Replies

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

Answer by Wolfram · May 25, 2011 at 07:23 PM

It's not specular, it's the background color.

I assume the dark rectangle with the small triangle at the bottom also uses a transparent shader? The problem is the transparency sorting between these two objects - at certain viewing angles it will fail, rendering the text first, and the dark shape afterwards. However, since the 3D Text shader uses "ZWrite On", pixels that are actually behind the text are prevented from being rendered, because their z-test fails.

There are some ways to get around this, but a perfect solution working in all cases is difficult, and depend on the geometric situation in your scene.

Things you can try are:

  • change the shader to "ZWrite Off". This might sometimes cause the text to vanish, though.

  • change the shader to "Queue"="Transparent+1". This might cause the text to be overlaid over other transparent objects, even when the text should be behind.

  • experiment with the two parameters of "ZOffset" (check the ShaderLab docs on the Unity site)

  • physically offset the 3D text from the dark object, so that it is closer to the viewer/ floating above its surface, to help the transparency sorting algorithm to fail less often

  • don't use a transparent shader for the dark "background" geometry behind your text

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 Barrett-Fox · May 25, 2011 at 07:38 PM 0
Share

Thanks for the reply, that's helpful as a start. Yes, the material behind the 3Dtext object is also transparent. And, pulling the text away from the backing polygons does mitigate the problem a little. Buy me some time to do this shader experimenting.

avatar image leonardo_try · Nov 29, 2011 at 02:38 PM 0
Share

DUDE THAN$$anonymous$$ YOU!!! i just put "Queue"="Transparent+1" and it worked fine, i know it will appears in front of transparent objects, but for my situation it's not a problem

avatar image Wolfram · Dec 19, 2011 at 12:46 PM 0
Share

Note that since Unity 3.x (I think) you can access+modify the queue level directly from the material, so you no longer have to modify/write your own shader. So you could write a small script that simply increments the current material.renderQueue. http://unity3d.com/support/documentation/ScriptReference/$$anonymous$$aterial-renderQueue.html

avatar image
0

Answer by Barrett-Fox · May 25, 2011 at 10:10 PM

And, indeed, another answer to my own question is to render text to a texture off-camera and combine text and background into one shader. Have done that route before on another project. But I wanted to get a better understanding of these sorting issues.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Simplest Unlit Instanced shader - how to enable switching it on/off (with AlphaTest)? 0 Answers

Rendering transparent objects back to back (HDRP Lit shader) 0 Answers

Tree Creator Shader will not fade 0 Answers

Adding specular to shader 0 Answers

transparent + reflection shader (river water problems) 2 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