sorry for hijacking the thread but just now I’m with a perfect hands-on example question.
I’m trying to implement MSDF for my fonts. I also want to add borders and shadows to the fonts, but not to all of them. I’d like to reduce the number of drawcalls
So my idea is using a shader which has two branches, the “plain text branch” (shader of https://github.com/Chlumsky/msdfgen , scroll to the bottom) and the “text with borders and shadows branch” ( https://gist.github.com/Chlumsky/263c960ae0a7df59afc2da4051eb0553 , renderMsdf function)
All the characters will be put into a kind of spritebatch, each character will have its TexCoord, border, thickness, shadow opacity. If border is -1, in example, it will select the plain text shader. Full blown text shader otherwise.
Characters will probably all have about the same size, let’s say around 32x32 (will vary per character, of course)
So, in theory, what would be a better solution?
- Go with the single shader for multiple text types
- Just do two drawcalls
I know the best solution is “just try it” ( actually what I’ll do ^^ ) but with so many hardware and only being able to test in 1 GPU, the test only provides feedback in your current HW.
My bet of an uneducated GPU programmer is that as the characters are ‘quite big’ (a lot bigger than a warp/wavefront) and the text characteristics will be laid out linearly (I mean, I’ll write i.e. 10 characters ‘plain’, then 25 decorated characters, then 12 character plain again, …) the impact of the jump should be low, but I’d love for somebody much more versed in GPU programming to confirm or refute it @AcidFaucent