Author Topic: Drawcall problem!  (Read 4727 times)

bagomints

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Drawcall problem!
« on: January 19, 2014, 10:40:04 PM »
Here's the process:

-I'm instantiating a child to add to an invisible widget acting as a container for the child objects I instantiate using NGUITools.AddChild(..);

-Child object :depth 3
--Container1  :depth 3

 ---Slider A : depth 3
 ---- Slider A background : depth 3
 ---- Slider A foreground : depth 4
 ---- Slider A Label : depth 3

 ---Slider B: depth 3
 ---- Slider B background : depth 3
 ---- Slider B foreground : depth 4
 ---- Slider B Label1 : depth 3
 ---- Slider B Label2 : depth 3

 ---Slider C : depth 3
 ---- Slider C background : depth 3
 ---- Slider C foreground : depth 4
 ---- Slider C Labe1l : depth 3
 ---- Slider C Label2 : depth 3

-- Container2 : depth 3
  --- Label1 : depth 3
  --- Label2 : depth 3

-- Sprite : depth 3

So the child object has 2 containers, 1 for sliders, 1 for some labels, and a separate Sprite.

Everything is depth 3, since they don't overlap each other, except the UISlider foreground sprites because they sit ontop the slider's background sprites are depth 4.

When I open the DrawCalls from the UIPanel, everything is being rendered almost separately, one at a time or sometimes 2 at once.. doesn't make sense to me seeing as they ALL share the same atlas, and all the Labels share the same material.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drawcall problem!
« Reply #1 on: January 19, 2014, 11:14:42 PM »
You shouldn't use the same depth values on both parents and children. That's confusing, and makes it uncertain what will get the events. When things overlap, they should have different depth values.

bagomints

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Drawcall problem!
« Reply #2 on: January 19, 2014, 11:23:37 PM »
The parents are just invisible widgets though, just containers, and nothing overlaps visually. But I'm going to try to change the parents depth values and see and post results.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Drawcall problem!
« Reply #3 on: January 19, 2014, 11:28:40 PM »
Note what I said there:

http://www.tasharen.com/forum/index.php?topic=7643.msg36195#msg36195

Depth is not cumulative.

bagomints

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Drawcall problem!
« Reply #4 on: January 19, 2014, 11:37:35 PM »
Do I understand properly that even if, for example, 2 UISliders do not overlap, but are under different parents, giving them the same depth value is still confusing?

Should I literally just change to unique depth values for every single widget I'm using?

bagomints

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Drawcall problem!
« Reply #5 on: January 19, 2014, 11:46:39 PM »
Okay I managed to go from 20 drawcalls to 2 drawcalls separating depths of all widgets.

Each parent has a different depth value, but the child sprites share the same depths like so:

Slider 1 - depth 4

Slider 2 - depth 5

Slider 3 - depth 6

Label container - depth 7

but all 6 background and foreground sprites that the Sliders share are same depth values (8 and 9)

and all Labels share the same depth (3)

So as you can see every parent has a different depth value, and each shared sprite or label have the same depth value.

Now they all render in 2 drawcalls (sprites from same atlas + font from same material separately)

Thank you :)