# Possible material cache optimization?

**URL:** <https://forum.defold.com/t/possible-material-cache-optimization/71433>\
**Category:** Questions\
**Created:** [August 12, 2022, 6:13pm UTC](https://forum.defold.com/t/possible-material-cache-optimization/71433 "2022-08-12T18:13:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Musenik](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/musenik/32/20573_2.png) [@Musenik](https://forum.defold.com/u/Musenik)\
**Post date:** [August 12, 2022, 6:13pm UTC](https://forum.defold.com/t/possible-material-cache-optimization/71433/1 "2022-08-12T18:13:39Z")

</div>

Here I’m guessing that sprites which share a material are best drawn in a batch.

My example is, I have factories that crank out alphabet glyph sprites. If I were to z-sort them in alphabetical order, would they draw faster?

Say that ‘a’ glyphs are farthest from the camera and ‘z’ glyphs are closest. When a frame is drawn, would all the 'a’s get drawn before the 'b’s? Would that help drawing from the cache?

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [August 12, 2022, 6:50pm UTC](https://forum.defold.com/t/possible-material-cache-optimization/71433/2 "2022-08-12T18:50:08Z")

</div>

You could put all of those sprite glyphs on their own render predicate and they should only be 1 draw call. Is your profiling bad atm?

---

<div class="post-metadata">

**Author:** ![Musenik](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/musenik/32/20573_2.png) [@Musenik](https://forum.defold.com/u/Musenik)\
**Post date:** [August 12, 2022, 11:12pm UTC](https://forum.defold.com/t/possible-material-cache-optimization/71433/3 "2022-08-12T23:12:17Z")

</div>

It was a theoretical question, and I like your answer. Thank you. That’ll help me greatly in the future, but I would still like to know if z-order can be used to group sprite draws.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [August 13, 2022, 5:47am UTC](https://forum.defold.com/t/possible-material-cache-optimization/71433/4 "2022-08-13T05:47:45Z")

</div>

> [@Musenik](#):
>
> I would still like to know if z-order can be used to group sprite draws

Yes indeed it can. Have a look at how we batch draw calls here:

> **[Draw calls and batching - The render pipeline in Defold](https://defold.com/manuals/render/#draw-calls-and-batching)**
>
> Every object that is shown on screen by the engine: sprites, models, tiles, particles or GUI nodes, are drawn by a renderer. At the heart of the renderer is a render script that controls the render pipeline. By default, every 2D object is drawn with...
