How to render road name text
I am using a texture atlas and character sprites to render road names on a map.
This text will not be updated whilst the program is running.
All text will be loaded into one vbo, which will consist of vertices and texture coords. It will have an IBO as well.
I am just trying to figure out how to pass in position data and what the shaders can do.
(Sounding out my thoughts)
When the map is zoomed in or out, the text will remain the same size, so the position data for each character must have a central point that it is relative to them all and shader needs to manipulate this as per the scale of the map.
Could use some advice how to proceed.
If you want to continually scale the text, I would store the text strings in unit length from -0.5 to 0.5. This will make the scaling easiest since you can just supply a simple uniform vec4 x,y,z and scale and apply this to each vertex of the string when you render the string
Please bear with me I'm new to this. Can you explain any further?
lets say I want to display the string "road name" and place it centred at 10,0,20 on the map.
If the string needed to be 50 units wide from the camera I could draw it in a box from x = -15 to 35
If I move the camera further away I have to re-scale so it might be -30 to 70 (double)
I suggest you start with the string inside -0.5 to 0.5.
Now for the first view I would scale my vertices by 50 and add the string location (10,0,20)
For the second view I would scale by 100 and add the origin.
So when you render the string you just need to supply the origin and scale.
Note this simple version only works if the map is flat. If its heights change you have to adjust each vertex height from a height map; you may also need to highly tessalate the string mesh so that it fits the terrain well
My text is going to be rendered character by character not as a string of characters. So this changes things a bit, how would you solve this?
My map is flat, z = 0.
Tags for this Thread