1

I am making a game that needs a lot of text rendered at different distances.

Distance-field-fonts look perfect for this;

https://github.com/libgdx/libgdx/wiki/Distance-field-fonts

I made the font itself no problem - the software and tutorial was great there. However, the tutorials only go into how to use this font with a SpriteBatch. As my game is 3D, this isn't very useful to me.

My game is currently set up to use Scene2d.ui in the 3d world to arrange labels in a virtual interface, but If I have to I'll switch to just making my own layout objects out of lots of meshs.

I am basically looking for any way to use lots of Distance field fonts in 3d space- lets just say on a rectangle with "hello world" on it. If it helps I think the game will likely have about a hundred "text planes" created at run time, but not changing once created.

Please bare in mind I have no real experience with shaders. Some explanations I have found when googleing skip over things that (I assume) are basic to others (like how to make a Shader from a ShaderProgram). I did try to research this myself, but needing to have a custom Shader, a custom Shader Program, a custom Shader Provider and manually reimplementing my own Labels to take the custom shader seemed like I was going into a black hole of blindly poking about when there might be an easier/more obvious way to use Distance-field-fonts.

Any help or pointers will be appreciated, Thanks.

darkflame
  • 998
  • 1
  • 9
  • 23
  • See my answer here: http://stackoverflow.com/a/24389207/506796 You can draw into 3D space using SpriteBatch. – Tenfour04 Nov 05 '14 at 13:22
  • " separate draw call for each mesh " urg. I guess if nothing else comes up. Separate draw calls seems a bad idea here though considering I might end up with a hundred of these text-planes (most offscreen at any specific moment). If it helps the text doesn't need to change once its created. – darkflame Nov 07 '14 at 19:23
  • You could use frustum culling to avoid drawing the off-screen ones. Or you could instead draw a bunch of strings of text onto a FrameBuffer using a SpriteBatch (without the custom distance field shader) and then break up the FrameBuffer's texture into texture regions to use with DecalBatch to draw them in 3D with the distance field shader. But that's not a trivial solution. Maybe someone needs to write a BitmapFont3D class. :) – Tenfour04 Nov 07 '14 at 19:48

0 Answers0