Hello Guest

Author Topic: Perspective camera increases draw calls  (Read 4582 times)

yanivp

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Perspective camera increases draw calls
« on: July 07, 2013, 06:55:28 pm »
Hi,
I'm trying to understand how to save draw calls effectively with tk2d while using a perspective camera, however I'm running into some unexpected behavior.

Here's what I tried:
- I set up a simple scene with 5 objects with 5 separate sprite collections
- The camera is a regular Unity camera and is set to perspective mode
- When the scene starts I get 5 draw calls (which is expected)
- When I duplicate some of the objects they sometimes get batched, sometimes they don't. Usually, they don't. Batching seems to happen at complete random locations  in the scene. It looks as though the closer the objects to the camera's center the more they get batched. The farther they are the less. This is regardless to any overlapping (I'm making sure nothing overlaps while testing this).
- When I switch to orthographic camera batching works as expected (I get 5 draw calls constantly).

This is with Unity 4.1.5f and tk2d 2.0. All sprites are animated using tk2dSpriteAnimator

Can anyone please help to explain what practices I should use to effectively batch my objects in a perspective camera? I'm a bit confused here and not sure where to start.

Thank you!
Yaniv
« Last Edit: July 07, 2013, 07:11:33 pm by yanivp »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Perspective camera increases draw calls
« Reply #1 on: July 07, 2013, 07:07:40 pm »

yanivp

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Perspective camera increases draw calls
« Reply #2 on: July 07, 2013, 07:21:29 pm »
That seems to have fixed it! Thanks!
Would overlapping have any effect on objects that are of the same sprite collection?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Perspective camera increases draw calls
« Reply #3 on: July 08, 2013, 09:38:45 am »
Overlapping objects from the same sprite collection won't cause any issues, apart from the undefined draw order.