# Draw calls and Defold

**URL:** <https://forum.defold.com/t/draw-calls-and-defold/4674>\
**Category:** The Defoldmine\
**Created:** [January 31, 2017, 11:19pm UTC](https://forum.defold.com/t/draw-calls-and-defold/4674 "2017-01-31T23:19:50Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![Mattias\_Hedberg](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mattias_hedberg/32/433_2.png) [@Mattias\_Hedberg](https://forum.defold.com/u/Mattias_Hedberg)\
**Post date:** [September 4, 2017, 8:51am UTC](https://forum.defold.com/t/draw-calls-and-defold/4674/10 "2017-09-04T08:51:39Z")

</div>

@britzl wrote a nice summery here [How to "merge" sprites in defold - #35 by britzl](https://forum.defold.com/t/how-to-merge-sprites-in-defold/8778/35) here is a blatant copy of it!

* * *

To clarify:

**Rendering of sprites, spine models, particle fx etc**

- Rendering is based on z-order, back to front.
- Components on different depths will be batched unless one of the following is different from the previous component:
  - Component type (sprite, spine, particle, label, model)
  - Texture
  - Material
  - Blend mode, tint etc
  - Collection proxies
  - Note: Each particle emitter will result in a draw call

**Rendering of gui scenes**

- Rendering is based on the order of the nodes in the outline, depth first
  - Nodes will be batched unless one of the following is different from the previous node:
  - Node type (box, text, pie)
  - Texture
  - Blend mode
  - Font
  - Stencil settings

Layers are used to group different nodes to reduce the number of draw calls. Some images:

 ![07](https://forum-defold-uploads.b-cdn.net/original/2X/2/2bc93b7c6b6acf4ce594750756f9b1a773910f87.png)  
 ![10](https://forum-defold-uploads.b-cdn.net/original/2X/a/a320f7d919ef3c75357a8075f6601aae9432bd68.png)  
 ![14](https://forum-defold-uploads.b-cdn.net/original/2X/f/f58a7492f413e98c52321da2535846f8a204ba50.png)

* * *

Example of the complexity stencil add

A basic scene

 ![stencil_example_without](https://forum-defold-uploads.b-cdn.net/original/2X/f/fe91dd1361ca90e1262bd5fb04ad7a76ddbb0797.jpg)

Same scene with a stencil

 ![stencil_example_with](https://forum-defold-uploads.b-cdn.net/original/2X/4/46be31d2fb0a7599db96f55f890a08a863d82215.jpg)

---

_[View the full topic](https://forum.defold.com/t/draw-calls-and-defold/4674)._
