Jump to content

sdf text batching


Recommended Posts

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?

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

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.

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...