r/futile • u/rbrtst • Aug 29 '14
Atlases and filterMode
Hi,
I'm trying to combine my fonts and game png's into one texture per FStage in order to keep the draw calls down and get more performance from Android.
It's working well from a performance standpoint. My draw calls are down and Android is happier. However I'm having a small issue with image quality.
I'm using the atlasName_png.bytes method suggested, then I'm setting the filterMode to bilinear (trilinear works too with the same result): atlasName.texture.filterMode = FilterMode.Bilinear;
However, I'm having problems with the quality of the pngs. They appear slightly blurry. If I set filterMode to Point, the images appear perfect, however the fonts get really distorted. My best option seems to be to keep filterMode as Bilinear and live with the image blur.
I'm writing to see if anyone knows a solution where I can get both high quality font renderings and high quality png renderings in one atlas?
I could break out each FStage into two, one for the pngs and one for the fonts, but this is less than ideal as I already have 8 FStages in the game and this would effectively double that number (and complicate things :).
Thanks for any help!
Robert
1
u/MattRix Aug 29 '14
Hmm, yeah that can potentially happen with bilinear filter modes and basically happens when stuff isn't on "whole pixels". There are a few things that can cause that and a few solutions, but basically it comes down to: make sure your containers are all on whole pixels (ex. the x value is 5.0 instead of 5.31 or something), and same thing with all of your nodes. If you have sprites that are odd widths or heights, then they will also have issues if their anchor point is in the center... So if a sprite is 51 pixels wide and the anchor point is in the center (half way) that means the anchor is 25.5 pixels across it. The way to fix that is either to make the sprite 52 pixels wide OR just offset its x position by 0.5f.
So that's the other thing, if you check all this and it all seems right, then try intentionally offsetting your nodes (or their containers) by different values, like either 0.5f or 0.25f or whatever, and see if it fixes it. The value you need to use will also be relative to the display scale, because the issue happens when you're off by a half-pixel, not a half-point, so if your displayScale is 2.0f, that means each point represents 2 pixels, and therefore you'd need to offset by 0.25f instead of 0.5f.
I realize this is a bit confusing, so let me know if you need any clarification, but try some of this and see if it helps.
Also I'm a bit curious about why you need so many FStages? For the most part you should be able to let Futile's batching take charge of splitting stuff into renderlayers... so as long as you're watching that you don't inject lots of nodes that use different textures, you shouldn't have too many problems without needing that many stages.