Create a BitmapFontParameter object, and set the atlasName property to the internal filepath of your texture atlas definition file (normally a. If you're using an AssetManager to load your resources, it only takes a couple lines of code to update your fonts to use the Texture Atlas. We won't be including those PNG files in our assets anymore, so we need to tell the BitmapFont classes where to find the atlas. fnt file references the PNG that was generated with it. When you create Bitmap fonts with tools like Hiero, the. Tell your Bitmap Font to use the new atlas Configure the other options to your needs.Turn on the option "Strip whitespace Y" to get rid of all the empty vertical space in your fonts.Add your bitmap font PNG files to the list!.Otherwise, add all of your UI graphics to the list of files to pack. If you have a UI textures project already, open it.Open your favorite texture packer tool.Why not 1 draw call? My UI uses multiple Group actors, which can trigger SpriteBatch flush() calls that force a texture binding. Only 5 texture bindings/draw calls in the UI layer per frame! In hindsight, that tip made perfect sense and I'm a little annoyed that I didn't think of it!įollowing that advice, I packed up all of my UI layer graphics, fonts, and particles into a single texture atlas. This post by 'davedes' on was especially useful. While searching online for tips on optimizing Scene2D performance, I found some forum posts that mentioned packing your fonts with the rest of the UI graphics. The progress bar and the lower power-up icons (which render one at a time) are clear examples of this. Some of those actors need to draw both an image and text, which required multiple texture files in my project. The reason this happens is that the Scene2D Stage draws each Actor in the order they were added to the stage. Measure before optimizingĪfter setting up the GLProfiler, I was surprised to see 13+ texture bindings in the UI layer per frame! Why so many texture bindings? I had already gone through efforts to minimize draw calls/texture bindings on the game world, but I hadn't put much thought into the UI layer. There is a mixture of game world sprites and Scene2D UI elements. In the screenshot below, there is a typical scene from Santa Skate. I generated four fonts, each of which had a 512x512 texture with mostly empty space. While making Santa Skate, I used the Hiero tool to generate the. The LibGDX Wiki and many tutorials do a great job at recommending and explaining the use of atlases for your game world, but it was not obvious to me that you should also pack your Bitmap Fonts with your UI textures. Using Texture Atlases is one of the easiest and most effective ways of optimizing your game rendering. In my previous post, we learned about the importance of minimizing texture bindings in OpenGL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |