Texture sizes
Monkey Forums/Monkey Programming/Texture sizes
| ||
For my fontmachine module and editor "packed" version, I'm going to pack the font characters into textures. I was thinking on creating 512x512 textures but, is there any recommended texture sizes? Maybe 1024x1024 is a better texture size? |
| ||
Maybe let users decide. For some sizes 512x512 is too much, for some is not enough. Most of my fonts are packed onto 256x256 texture (though they are not as art rich as those created by fontmachine). |
| ||
Is it possible to let the user decide? I'd feel bad if I had a 512x512 image where I only used a quarter of it! |
| ||
Yes, there's no problem on letting the user decide, but I would love to give a proper "default" value for users that just don't want to worry about it, and just use the font. |
| ||
Most newer mobile GPUs can handle up to 4096x4096 texture sizes. I would recommend 1024x1024 if the font actually fills it up. Higher than that might break compatibility with really old GPUs, lower than than might mean less proper batching. Again, this is if the font fills that 1024x1024 texture. If only a few chars are included in the font, pick the smallest texture that can encompass all the characters. If however you're talking about the actual resolution of the characters (aka make them sharper with higher texture size) then I'd say let the user pick if he wants pixel-perfect or slightly blurred (half resolution), or really low resolution (retro?), and default to pixel-perfect. |
| ||
I think you would have to look at some sort of average requested font size for something like that. If it turns our that usually 512x512 is too small then you would opt for 1024x1024. Either way, if there's an option to change afterwards, it shouldn't be a problem for anyone. |
| ||
Ok, I'll leave it this way by now: the tecture packer for fonts can be configured manually for 128x128, 256x256, 512x512 or 1024x1024. If the font is too big to be stored in a single image, the renderer adds a secondary image, so you can always balance if it's better to have two 256x256 instead of a 512x512 (wich is four times bigger). This way, the user will be able to decide wich size fullfills better his/her needs. I've done a simple font that just fits into a 256x256 texture (no borders or shadows). I'll provide an update tomorrow for both the editor and the module. |
| ||
Another possible performance tweak, would it perhaps somehow be able to specify which characters get packed into which texture. That way most commonly used characters can be put in texture 1 and then less common characters in further textures. That way when drawing operations for general use you shouldn't have to switch between multiple textures. |
| ||
A big font with borders and shadows fits in a single texture 1024x1024 (and shadows take lots of space), so I really don't think the suggested selection of chars would make a big diference here. I'll leave it by now. |
| ||
the tecture packer for fonts can be configured manually for 128x128, 256x256, 512x512 or 1024x1024. If the font is too big to be stored in a single image, the renderer adds a secondary image, so you can always balance if it's better to have two 256x256 instead of a 512x512 (wich is four times bigger). This way, the user will be able to decide wich size fullfills better his/her needs What makes you think textures need to be square? One ^2 texture will be best for performance and memory... Just make them taller rather than wider. |
| ||
What makes you think textures need to be square? One ^2 texture will be best for performance and memory. I don't understand your post. AFAIK ^2 are square textures... |
| ||
Nope... It just mean each dimension needs to be evenly divisible by 2 all the way down. A 256x128 texture is perfectly fine. Fyi, I mentioned keeping them taller vs wider because some gpus had issues with blocks larger than their widest resolution. |
| ||
yes why use 2 256^2 textures. why not use 1 256X512. It is still power of 2 and perfectly valid functional in video memory. |
| ||
Something to consider is post processing the font. Quite often you use a font program to generate your image and you then go and add drop shadows etc. In that case you'll want to add some padding around the edges but it should be user controlled. So you can choose to pad nothing on the top and left edges, but pad 8 pixels on the right and botto so there's room for the drop shadow. Also, being able to add seperate images into your font later would be useful. A useful thing is to replace certain characters with small images. Like if you want "Press X To Continue" but show a small picture of the X button on the 360 pad it's easier to add the X button graphic to the font as something like character #. The string you print is "Press # To Continue" but it draws the button graphic instead. |
| ||
Another reason to make them taller than wider may be that PNG can compress them better. As far as I can see, empty horizontal lines cost almost nothing in PNG, whereas empty space on the right can be expensive. Of course this may not matter in many situations, but it is worth considering I think. |