- Home /
is it possible to display text as texture on 3d mesh or plane ?
I was thinking to make a 3d web page with unity, and first thing that come to my mind is how to display text information on 3d objects without using text converted beforehand in to texture.
If i do that, it will be problem with dynamic text, and i guess the text information will cost a lot more in form of texture when considering the bandwidth .
Answer by skovacs1 · Dec 02, 2010 at 06:34 PM
Generally speaking, Unity is not the best at dealing with text, especially in 3D.
The simplest way to get dynamic text to have perspective in 3D space would imply setting up to create/change an aligned 3D text object as appropriate. Every other solution would entail texture manipulation.
If you wrote something to decode truetype font information, you could use the vector coordinates for the given characters in the font or if you properly index the texture and material that the font asset is using (would take a little effort to reverse-engineer and figure out the coordinates that Unity is using for this) to adjust a texture2D at run-time (with GetPixels and SetPixels).
You could also more simply use the built-in GUI text stuff to create a text field rendered to a second camera that renders to a RenderTexture (Pro only) and then merge that RenderTexture into your Texture2D (with GetPixels and SetPixels). Also, you can turn-off the camera's rendering or at least only merge your RenderTexture on frames where the text field changes.
Thank you for the answer. I guess i need to get the pro to start something like this. And it looks like it's not a simple thing to do.The good thing is that you can turn of the camera until you need to update the text. ill see it in action when I get unity pro.
I'm trying to do just this, but I'm not seeing how I get my GUI text stuff "rendered to a second camera." I think I get the rest of it, but how do I render GUI stuff to a second, invisible camera without it being sent to the screen?
make everything you need render only to second camera to new layer, for example, 'text', then turn second camera's culling mask so it render only this layer, and turn your main camera's culling mask NOT to render this layer
http://docs.unity3d.com/Documentation/Components/Layers.html
Ah! Of course. Excellent. Thank you for the quick response!
hmmm. Except that I can't see how I make everything I need to render to a particular layer. I see how to do it with GUIText and GUILayer but not with the UnityGUI system. I'd like to use UnityGUI, but I suppose GUIText would do what I'm looking for...
Answer by Rennat · Dec 02, 2010 at 06:23 PM
unity pro can render to textures, I haven't tried this but I bet you could have a second hidden camera, draw the text in a gui layer and render that camera to a texture at runtime.
Ah I still don't have the pro version. I plan to get it in the next month. Can you tell me how fast is this method, and do I have control over the generation of textures e.g. can i shot it one time and use the texture later, or the camera need to work in background all the time to display the information ? Thank you for your answer btw :P
I haven't used this technique so I can't say how fast it is, but you can read up on RenderTexture here: http://unity3d.com/support/documentation/Components/class-RenderTexture.html I imagine that you wouldn't need to rerender the texture every frame, you would probably have to rerender it once per use
Answer by drudiverse · Dec 05, 2015 at 10:31 AM
if there isnt another option, i'd suggest you get a fonts picture as a grid, and use get-set texture to apply the letters onto the texture.