Hello Guest

Author Topic: Scrolling Backgrounds Impacting Performance  (Read 4455 times)

Ceraph

  • Newbie
  • *
  • Posts: 8
    • View Profile
Scrolling Backgrounds Impacting Performance
« on: July 30, 2013, 09:22:59 pm »
Hello, I am working on a runner for mobile with parallax scrolling backgrounds and I had some questions about the best way to display scrolling backgrounds with the lowest impact on performance. I have tried two different setups with very different impacts on performance.

My original setup was to have the entire background cut up into as large images as possible and put together in the scene. The camera would follow the player and pan across the background without ever having to actually move it.

The second setup is largely the same and still has the moving camera and stationary background. The background is fairly simple and is mostly just a solid color that changes every few hundred pixels, so to save memory I cut up the background into several 16x16 images that served as color swatches. I made a sprite for each color section and resized the sprite X and Y (using the TK2D Sprite component in the inspector) to stretch across the length of that background segment. The end result was a change from 2 large, unscaled sprites to around 25 smaller images scaled up 45x and 50y (only 2 of which are visible on the screen at any given time). The second method resulted in a significant reduction in performance (tested on the iPhone 4). I didn't scale the sprites with Unity's transform panel so I'm really not sure why the second method performed so much worse than the first. If anything I would think that using less RAM would increase performance. Any thoughts?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Scrolling Backgrounds Impacting Performance
« Reply #1 on: July 30, 2013, 10:29:06 pm »
You'll have to run this through the profiler to work out why there is a diference in performance. I wouldn't have expected 25 images vs 1 to make any appreciable difference in performance.

One thing though - since its mostly a solid color, you should almost certainly switch the shader to solid. That should net you some nice GPU gains.

Ceraph

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Scrolling Backgrounds Impacting Performance
« Reply #2 on: July 31, 2013, 09:14:16 pm »
Thanks for the heads up about the shader, I will have to look into that!