Author Topic: Tiled Background  (Read 4747 times)

neken

  • Guest
Tiled Background
« on: October 03, 2012, 08:51:28 AM »
Hello,

I Need to make a background from tiled sprite. I use for that UITiledSprite and rescale to height of the screen. It's look good but i have problem with performance on iPhone4 and 3GS . I Think becouse now i have fullscreen of alpha-shader (Unlite->Transparent Color) form atlas material.. but i can be mistake. There is another option to make fullscreen tiledsprite ?

Thank you

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tiled Background
« Reply #1 on: October 03, 2012, 08:58:41 AM »
Yeah that would be one reason. You can always move that sprite into a separate atlas that doesn't use the alpha blend shader.

neken

  • Guest
Re: Tiled Background
« Reply #2 on: October 03, 2012, 09:22:46 AM »
I created new attlas with Mobile->Unline shader but still have bad framerate.. Did you see any problem with new xcode 4.5 ? On unity forum are topics about problem with alpha-blend in that version.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tiled Background
« Reply #3 on: October 03, 2012, 07:33:48 PM »
When in doubt -- profile it. Make sure you don't have any widgets that change every frame -- for example changing the color, moving them around, etc. Each time that's done, the panel that owns this widget has to rebuild the draw buffer, which affects all other widgets in the panel.

neken

  • Guest
Re: Tiled Background
« Reply #4 on: October 04, 2012, 03:56:58 AM »
Hi Aren,

I do some test.

Atlas size: 1024x1024 4.0MB
Tiled sprite (oryginal: 744x256, tiled to: 744x1280)
Profiler:
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player>    min:  4.3   max: 23.9   avg:  5.9
cpu-ogles-drv> min:  0.3   max:  0.7   avg:  0.3
cpu-waits-gpu> min:  7.2   max: 27.7   avg: 25.3
 msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
frametime>     min: 32.4   max: 34.3   avg: 33.3
draw-call #>   min:   4    max:   4    avg:   4     | batched:     0
tris #>        min:    66  max:    66  avg:    66   | batched:     0
verts #>       min:   132  max:   132  avg:   132   | batched:     0
player-detail> physx:  0.5 animation:  0.0 culling  0.0 skinning:  0.0 batching:  0.0 render: -22.1 fixed-update-count: 1 .. 2
mono-scripts>  update:  1.3   fixedUpdate:  0.0 coroutines:  0.0
mono-memory>   used heap: 954368 allocated heap: 1204224  max number of collections: 0 collection total duration:  0.0
----------------------------------------

And everything is ok but when i turn on panel with another atlas

1. Atlas size: 1024x1024 4.0MB (background)
Tiled sprite (oryginal: 744x256, tiled to: 744x1280)

2. Atlas size: 2048x1024 8.0MB
(Secound atlas have all game sprite)

All sprite don't move, and don't have any my script:
Profiler:
----------------------------------------
iPhone Unity internal profiler stats:
cpu-player>    min: 21.2   max: 38.5   avg: 31.4
cpu-ogles-drv> min:  0.4   max:  0.7   avg:  0.4
cpu-waits-gpu> min:  0.4   max: 13.3   avg:  5.1
 msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
frametime>     min: 33.1   max: 50.0   avg: 38.8
draw-call #>   min:   4    max:   4    avg:   4     | batched:     0
tris #>        min:   302  max:   302  avg:   302   | batched:     0
verts #>       min:   604  max:   604  avg:   604   | batched:     0
player-detail> physx:  0.7 animation:  0.0 culling  0.0 skinning:  0.0 batching:  0.0 render: 20.8 fixed-update-count: 1 .. 3
mono-scripts>  update:  3.9   fixedUpdate:  0.0 coroutines:  0.0
mono-memory>   used heap: 974848 allocated heap: 1261568  max number of collections: 0 collection total duration:  0.0

And now i have -5 fps on iPhone4 and -10 on Phone3GS , -3 - -4 iPad 1


Any idea ? I see that cpu have more usage with 2 atlases (separate panels)

I tested with Mobile->Unlite shaders but no resolve my issue then this is no problem with shaders.
« Last Edit: October 04, 2012, 04:15:34 AM by neken »

neken

  • Guest
Re: Tiled Background
« Reply #5 on: October 04, 2012, 05:35:16 AM »
New test:

On the scene are only 2 atlases from previous post

Profiler:
iPhone Unity internal profiler stats:
cpu-player>    min:  4.9   max:  8.5   avg:  5.7
cpu-ogles-drv> min:  0.4   max:  0.5   avg:  0.4
cpu-waits-gpu> min: 16.5   max: 45.5   avg: 28.4
 msaa-resolve> min:  0.0   max:  0.0   avg:  0.0
frametime>     min: 28.5   max: 53.2   avg: 36.7
draw-call #>   min:   4    max:   4    avg:   4     | batched:     2
tris #>        min:    84  max:    84  avg:    84   | batched:    34
verts #>       min:   168  max:   168  avg:   168   | batched:    68
player-detail> physx:  0.3 animation:  0.0 culling  0.0 skinning:  0.0 batching:  0.1 render: -26.3 fixed-update-count: 1 .. 3
mono-scripts>  update:  1.1   fixedUpdate:  0.0 coroutines:  0.0
mono-memory>   used heap: 417792 allocated heap: 651264  max number of collections: 1 collection total duration:  3.3


And iPhone have -4 fps .
cpu-waits-gpu> min: 16.5   max: 45.5   avg: 28.4 - this line is interesting.
?
I use latest NGUI maybe new xcode change something in new version ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tiled Background
« Reply #6 on: October 04, 2012, 11:15:45 AM »
iPhone has terrible fill rate. If you have a UI that writes to the same pixels more than once (for example one window covering another), you will run into slowdowns. Try enabling the "depth test" option on the panel and/or eliminating other fillrate-heavy cases such as outline / shadow effects on labels.

neken

  • Guest
Re: Tiled Background
« Reply #7 on: October 04, 2012, 12:53:46 PM »
Thank you for answer. Deep Pass dont help me. But i can confirm that i delete my background UITiledSprite and put on render in the same time Shop, Summary Window and Main Menu Window (all on different UIPanels) and have performance issue to..

I wonder have to solve that situation many games have meny "window" on another "window" and fillrate is still good.

My hierarchy look:
UIRoot - Autohight turn off , manualy set to 1024
In attached files i put screen from my hierarchy

Maybe someone has a similar situation
« Last Edit: October 04, 2012, 02:45:44 PM by neken »