Masked progress bar and shaders

It’s always easier when a user shares a ready-to-test minimal project that’s easy to open and check what’s wrong, because there’s not enough context about your setup to help you.

Since I don’t have enough info, I can only guess. The most frequent issue related to this is the use of atlases and the assumption that every sprite has normalized UVs from 0 to 1. But:

  • var_texcoord0 that Defold passes to sprites is global within the whole texture atlas, not inside the current flip-book region. When your bar occupies, say, the range 0.40–0.70 of the atlas width, the smallest var_texcoord0.x you’ll ever see is ~0.40, never 0.0 — Shader - UVs based on whole atlas?

  • Your uniform progress.x = 0.5 was compared against those 0.4–0.7 UVs, so the test never matched the local width you expected, and the entire quad (or none of it) survived the discard.

(Also check this forum topic: Shader - UVs based on whole atlas?)

P.S. since you already use ChatGPT, try to use o3 for such questions, it will be able to use search in internet (for example, on forum)

3 Likes