- Home /
Why does shader show chars as rectangles?
I am using the shader I found by Eric Haines in http://wiki.unity3d.com/index.php/3DText
I have the following problem using this shader in Unity4---text transforms 3d testMesh to a "string" of disjoint filled bounding rectangles, one for each letter. "Good news" is these rectangles now seem correctly occluded by other meshes.
I am new to Unity but not to computer graphics. I do not yet know enough about shader syntax to see exactly how this "should" work, but am browsing some tutorials.
Attached are test images--before and after I added shader.
What I was missing was not just a shader, but also understanding
how font textures are (and can be) used in Unity. Once I found
out (recall I am new to Unity) that I could "open up" my font to
expose the font texture, I was able to drag-drop this into my new
material and then drag-drop that material onto my text and all is
good. Dennis
Answer by CHPedersen · Dec 29, 2012 at 03:54 PM
This is related to the texture you're using with Eric's 3D text shader. It usually happens because we can't select the default 3d text material the built-in shader for 3D text uses, so you have to recreate a font texture. Thankfully, I think Eric also provides some editor script for that.
First, read the entire tutorial Eric wrote for use with his custom 3D Text shader:
http://wiki.unity3d.com/index.php?title=3DText
Then, realizing that you need a new font texture, use his SaveFontTexture script to create it:
Answer by Dennis Roseman · Dec 29, 2012 at 08:05 PM
Thanks for the reply. I did not realize I needed a new font texture. In fact I am not clear on what the issue is, but then again I have not puzzled out the code involved.
I have tried to follow this solution but so far without success. I believe I correctly used the script of SaveFontTexture and used it to make a new Material and applied it, but this has not changed how things look.
I am confused on a couple of things---maybe it will become clear as I continue to work on this. But the SaveFontTexture in code and comments refers to GUIText objects and but I am using (and need to use) 3d Text.
Also, in SaveFontTexture instructions, it further instructs to use some other shader from http://wiki.unity3d.com/index.php/TexturedFont. I am assuming that I am to use the 3D TexturedFont of ttp://wiki.unity3d.com/index.php?title=3DText. (None of these seems to resolve my basic problem of showing the text).
Attached are two files---one of my game in blender so you can see what I am really trying to do. Note how the frame appears in front of the green M and S. In this game I need to quickly change the letters on the cube. The second is from my Unity version showing the problem if one uses the standard shader---see how the F and D appear to be outside the frame.
That's transparency fighting, happens a lot. Try adding 'zwrite on' to your shader passes.
Also don't forget, post a comment with the comment button, leave the answer area for actual answers to the question :)
Specifically my shader has this directly below 'category':
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
Blend SrcAlpha One$$anonymous$$inusSrcAlpha
AlphaTest Greater .01
Color$$anonymous$$ask RGB
Cull Off Lighting Off ZWrite On