md5crypt Posted January 20, 2022 Share Posted January 20, 2022 So I was very hyped up by the sdf text feature in bitmap-text. It solves so much problems in text-heavy projects. But... it breaks batching. I understand that there is a material change, but: a) even sdf text objects on the same level in hierarchy don't get batched b) in unity as long as geometry does not overlap objects with same materials still get batched even when they are in separate trees I have a list that has like 20-40 list items on screen. Each item is composed of multiple text objects and sprites. As it is currently every single text object causes a flush and the end result is... not so great... If I understand correctly the build-in pixi batcher does not work at all with objects with materials different then the default one and if I want anything else to batch I need a custom plugin. So my idea would be: a) make plugin to batch all custom text sdf object's geometry ignoring their hierarchy b) flush the batch on demand (for example in a custom container that would be the list parent) Then I can manually do what unity does and first render all the list items sprites in one draw call and then all the text in a second one? Is this possible? Will it work? If so could someone give me some hints where to start? For example is this https://github.com/pixijs/batch the correct place to start looking? Quote Link to comment Share on other sites More sharing options...
jimmy6dof Posted January 29, 2022 Share Posted January 29, 2022 I am also interested if you find a solution to this please do post. BTW, If you have a text heavy screen maybe see if this is useful https://github.com/Chlumsky/msdfgen Quote Link to comment Share on other sites More sharing options...
md5crypt Posted February 25, 2022 Author Share Posted February 25, 2022 So to answer my question, yes, it is possible and yes, it will work. Unfortunately I can't really give myself any tips where to start as I already did the thing. Anyway for future reference here is a link: https://github.com/md5crypt/layout-pixi/tree/ad15a128a404a653dfe62095564b14e5e5d3b274/src/sdfText I implemented 3 modes of operation: flush=false forceBatch=false batches SdfText display objects but flushes on renderer plugin change (so like a "proper" pixi renderer plugin but not really helpful) flush=false forceBatch=true batches all SdfText objects and flushes when rendering reaches a SdfTextFlushBarrier display object flush=true flushes after each SdfText display object (so like pixi bitmap text in sdf mode) I got lazy and it supports only one base texture atm, will have to change that someday when my fonts stop fitting on a single texture. Hope this helps someone out there. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.