I have a Sprite that contains multiple childs sprites (a grid sprite containing multiple bitmap tile sprites).
If I display it like this, everything is correct. However, as soon as I change the scale of the parent sprite (by setting grid.scaleX = 0.5; grid.scaleY = 0.5; for example), the rendering is (really) ugly. The edges of my tiles (that are hexagons) are rendered as a flickering line instead of a straight smooth one…
I have tried to set grid.cacheAsBitmap = true;
and in my project.xml file I have: <window orientation="portrait" vsync="false" antialiasing="4" if="cpp" /> (also tried with vsync=“true”)
But that doesn’t change anything.
What is the solution to get a smooth rendering when applying scalling to a set of bitmaps?
Also, be aware that OpenGL smoothing looks best when between 50% and 100% scale, smaller than that it starts look worse due to how GL_LINEAR sampling works
Yes my bitmaps have smoothing=true.
I create them like this: _bitmap = new Bitmap(null, PixelSnapping.AUTO, true);
And then I fill their bitmapdata with _bitmap.bitmapData = mybitmapdata where mybitmapdata is a bitmapdata generated on the fly
But just to be sure I set _bitmap.smoothing = true;
But that didn’t change anything
And my real scalling factor is something between 0.95 and 0.8 (it is definitively above 0.5).
wait.
I just tried by setting _bitmap.smoothing = true AFTER _bitmap.bitmapData = mybitmapdata and that looks OK now. So seems like setting _bitmap.bitmapData reset _bitmap.smoothing to false…
Anyway, why isn’t smoothing set to true by default? Usually people prefer to have smooth bitmaps than ugly ones… (and if you don’t transform your bitmap, smoothing=true or smoothing=false shouldn’t change anything anyway)
OK. Is this sampling also performed when there is no transformation applied to the bitmap (like scalling, rotation…)? Just to know if there would be any overhead if I set smoothing=true for a large fix background image or a an UI button for example (that are not rescalled)?
It’s up to the OpenGL driver implementation, GL_LINEAR is very, very common, so it’s probably heavily optimized. I think it’s just the motivation for leaving smoothing off by default, if you don’t need it, there’s probably a modest boost, but there’s no way to know for sure without benchmarking
EDIT: It’s likely less expensive than on software targets, like Flash Player, Cairo and HTML5 canvas