Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to reduce overdraw for mobile when making a 2d side scroller?

Discussion in '2D' started by topherbwell, Jan 23, 2016.

  1. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    Hello,
    I am currently making a 2d, side scrolling, endless runner game. The game is very near completion, and runs great on iPhone5 and Samsung S5, but once the game is put on a larger mobile device, such as iPad3 or Galaxy Tab4, the framerate is horrible.

    After several days of spelunking into the depths of the internet, and after countless hours of changing where my code to move my player, camera, scrolling backgrounds, etc is updated(update,fixed, late,etc), I have come to understand the painful lesson of overdraw on mobile devices.

    When using sprites and textures with alpha, the same pixel is drawn for every layer, every frame. This is a pretty hard limit on mobile gpus that are pushing 7 and 10 inch screens.

    So I guess now that I know the problem, I can't seem to find any straightforward information on how to fix this.

    How are some of you handling things like infinite scrolling backgrounds and sprites on mobile for 2d games? I have read to use meshes, but have also found information on how to do this pretty scarce.


    Any help would be very appreciated. Thanks!
     
  2. tomicz

    tomicz

    Joined:
    Mar 16, 2015
    Posts:
    152
    Okay dude, after 20 hours I did something that helped me, I hope it will do the same for your project.

    I went to main camera and changed from Skybox to Don't Clear and changed Rendering Path to forward. It increased FPS to 60.

    If it helps, let me know.

    Best luck.
     
  3. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    thank you for the reply but unfortunately this did not work.
     
  4. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    Bump. Anyone?
     
  5. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    I need to know how to reduce overdraw... How do I convert my sprites to meshes and use them instead? How do I tackle an infinite scrolling background without overdraw? Did i pick the wrong game engine to make a 2d game? I started learning unity about 8 months ago and love it, but now that i'm putting my 2d projects on mobile devices the usually very helpful community has been silent. I have made several posts in multiple categories and have gotten few answers at all.
     
  6. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
  7. DalerHakimov

    DalerHakimov

    Joined:
    Mar 14, 2014
    Posts:
    302
    What do u mean by "background". Is your background just one sprite? or multiple sprites? Can you show some code on how you scroll them? or at least how you do it.. You shouldn't have any kind of overdraw for background..
     
  8. tomicz

    tomicz

    Joined:
    Mar 16, 2015
    Posts:
    152
    I don't make backgrounds as sprites, they are textures. I create an empty quad, and then paste a background (as texture) to it. Is that what you are looking for ?

    And indeed, these forums seems dead. I usually go to reddit.
     
  9. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    My background is three quads, using a script to offset the texture. Yes, I am using textures on my backgrounds, on quads. The problem is that these textures still have lots of alpha. According to the overdraw tool in the scene view, they are causing overdraw.
     
  10. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    If the textures on the quads use transparency you get overdraw, at least that is how it appears in unity.
     
  11. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    All relevant code is here: http://forum.unity3d.com/threads/is...-2d-scrolling-background.381353/#post-2477038
     
  12. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    Screen Shot 2016-01-25 at 11.32.42 AM.png

    What my overdraw is looking like^^

    Screen Shot 2016-01-25 at 11.32.51 AM.png

    What the same scene is looking like.

    As you can see below, transparent geometry is killing my performance. Camera.Render (specifically render.transparentGeometry), and Graphics.PresentAndSync go back and forth fighting for the top spot.

    Unfortunately, the GPU part of the profiler is giving me an error and I cannot seem to use it, but I think the below data from the CPU readings is enough to say that transparency is killing my game performance on tablets.

    Screen Shot 2016-01-25 at 1.19.48 PM.png
     
    Last edited: Jan 25, 2016
  13. topherbwell

    topherbwell

    Joined:
    Jun 8, 2015
    Posts:
    180
    Bump. With no clear way to move forward this has basically halted the production of this game. We cannot release with this sort of performance on tablets and we do not want to release only on phones.

    So sad. We thought we were ready to release, minus tidying up some menu screens and adding admobs.

    At this point we are considering posting a job on upwork to see if anyone will share some knowledge.
     
  14. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    try one scene in older unity version, I have read new versions have perfomance problems. Your screen is not looking realy hard for old gpu.

    I have noticed, my samsung s1 dont like big size sprites, so i am trying keep them at 1024.
     
    theANMATOR2b likes this.