   Rendering text with a shader?
  In my current text rendering system, I render all the letters to a texture, which will hold the entire text renderarea. I do this in system mem.Since I only have to do this every time text changes, it is very fast to render, since it is a simple texture on the shader.However, when I want to change something, it is quite slow.Is there a way to easily and quickly render text with the shader?I imagine uploading the font texture to the shader, and then render the letters one by one, with a list of areas on the font texture.Is this efficient? Or what is your preferred method?How would I do this? Make a vertexbuffer, that I open, adjust and close for each letter (=overhead I imagine)?Thanks in advance.   
  i wrote sometime ago a little font engine for directx11.the fonts where stored in a bitmap.i used anglecodes bitmap font generator to generate the font and the informationsabout the chars inside the font texture.for displaying text on the screen iam using a dynamic vertex buffer that is locked when text changed.while loading the font bitmap and the configuration file for the font i create somekind of a lookup table for each charset.so when i need to fillup the vertex buffer with text i can lookup the rectangle of the char from the lookup table and copy that information to the vertex buffer.in the lookup table i have informations about every char that is supported by the bitmap font.for each charset 4 vertices with precalculated uv and position are stored in the lookup table.so in a loop when i want to fillup the vertex buffer with a text that need to be display, i just need to lookup the settings for the char.internal an offset is calculated in the loop to have the correct position for the next char in the text.this is just a short description but it works very well. and text rendering can be batched really good together.;  Some caution advised when dealing with text. Unicode text is far more complicated than used to be in the 90's. If you are on windows, you may want to take a look at Uniscribe and the Blinn/Loop curve rendering method.Uniscribe will automatically take hinting (which doesn't truly matter in FP) and kerning (which is more important for some specific pairs, according to your font of choice).To me, doing Blinn/Loop with a dynamic vertex buffer feels fairly efficient, it gets you proper-ish vector rasterization regardless of the zoom level, resulting in a "fire and forget" text buffer geometry.If you're not going to embed text in a 3D world, Blinn/Loop is probably overkill. Even if not using Blinn/Loop, recall that in Unicode, multiple chars are allowed to map to a single glyph (such as the 'fi' ligature in some languages), so you'll want to lookup on glyphs instead of characters, also do not confuse the character (you probably mean the code point here) with the value encoded in wchar_t (which is UTF-16 on windows).If you plan to stay within a certain charset, the above is essentially a rant: those cases are fairly rare and decent typography services can be built even without taking those things in consideration.;  How about using hardware instancing to render text?  It's something I was thinking about for my engine - something along the lines of:1) Set a texture which contains all the characters.2) Create a quad the size of each character3) Fill a vertex buffer with the index number of the characters you'd like to display4) Fill a vertex buffer with the translation of the digit quads (or where they'd be in screen-space)5) In the shader, use the index number of the character to get the texture coordinates of the character6) Render everything with one callI haven't tried it yet, but I can't foresee any major issues other than having to lock the vertex texture to change the text but you could probably just discard the previous contents and write the whole thing again.   ;Quote:Original post by RobMaddisonHow about using hardware instancing to render text?  It's something I was thinking about for my engine - something along the lines of:That's exactly how I do it in my sample framework, and it works like a champ. In fact it uses my SpriteRenderer class, which uses instancing to render batches of sprites. Wasn't very hard at all to write.;Quote:Original post by Gruntyfor displaying text on the screen iam using a dynamic vertex buffer that is locked when text changed.It was something like this I had in mind. I store my letter information somewhat differently, but it is in principle the same I could do.;Quote:Original post by KrohmTo me, doing Blinn/Loop with a dynamic vertex buffer feels fairly efficient, it gets you proper-ish vector rasterization regardless of the zoom level, resulting in a "fire and forget" text buffer geometry.I will look into this Blinn/Loop thingy. At some point I may need to embed text in the world, and then it will be good to know about it. Thank you.;Quote:Original post by MJPQuote:Original post by RobMaddisonHow about using hardware instancing to render text?  It's something I was thinking about for my engine - something along the lines of:That's exactly how I do it in my sample framework, and it works like a champ. In fact it uses my SpriteRenderer class, which uses instancing to render batches of sprites. Wasn't very hard at all to write.Sounds interesting. I have to look into hardware instancing first, since I don't know about it yet.I don't suppose anyone could throw some example code? MJP?   