I was working this weekend on this prototype
and got two warnings from the engine:
First one, max number of sprites was reached, which ok, makes sense because I’m creating a matrix of 40x40 sprites, so I need at least 1600.
That matrix is all the same sprite, tinted to represent some kind of pheromone trail. And that raises the second warning: “RENDER: Max number of draw calls reached (1024), some objects will not be rendered. Increase the capacity with graphics.max_draw_calls”
Digging up a bit, I found that tinting does indeed break batching, although it seems that “Tintin breaks batching but components have the exact same tinting will batch.” as stated here: Draw calls and Defold
So if that is true, instead of using floating numbers I could do some value quantization and reduce grayscale values to, say, 32, 64 or 128. That would reduce draw calls by a few thousands already. Indeed, my values range from 0 to 1, so if I do something like tint being math.floor(cell_value * 128) / 10 I get 128 values, which looks like this and doesn’t go beyond 128 drawcalls (tested and works)
But I am curious: Is there another way of reducing drawcalls when tinting? Because a) this trick won’t always work and b) it doesn’t look as good as the original version, which has many more gray values! (although I could improve the way I quantize, spreading values a bit better)
(Also, what is a good value for draw calls? I’ve always understood that the lower the better)