Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Reducing filtrate: how to render gameplay with lower resolution?

Discussion in 'General Graphics' started by pachash, Oct 11, 2018.

  1. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    Hi!

    I was inspired by Nordeus guys talk about their journey to 60 fps on mobile platforms. I decided to apply some of the tricks they mentioned in the presentation. One of them is rendering gameplay with lower resolution and upscaling the resulting image.

    Here's the relevant slide from their presentation:


    Furthermore it's obvious that my game could benefit from this since when running the project in Xcode on the device I override GPU to "minimise the amount of rendered pixels" I clearly see lower power consumption and decreased GPU frame time.

    I need software upscaling since I need to render in lower resolution just the gameplay while UI should be crisp. It means I can't just use Screen.SetResolution.

    I basically achieved that using the following script attached to the gameplay camera:

    Code (csharp):
    1.  
    2.   RenderTexture render_tex;
    3.  
    4.   void OnPreRender()
    5.   {
    6.     int height = (int)(Screen.height * 0.5f);
    7.     int width = (int)(camera.aspect * height);
    8.     render_tex = RenderTexture.GetTemporary(width, height, 24);
    9.     cam.targetTexture = render_tex;
    10.   }
    11.  
    12.   void OnPostRender()
    13.   {
    14.     camera.targetTexture = null;
    15.     Graphics.Blit(render_tex, null as RenderTexture);
    16.     RenderTexture.ReleaseTemporary(render_tex);
    17.   }
    18.  
    However I see absolutely no gains :( While the image is definitely upscaled. Running on the device in the Xcode I see no changes at all both in terms of power consumption and GPU times. Maybe I'd doing something wrong?

    I'm using Unity LTS 2017.
     
    Last edited: Oct 11, 2018
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Unity does it built in with more recent versions. It's on consoles and mobiles (may need a beta version). Alternatively you can just set a lower resolution directly, and that will just work with everything.

    Did you profile to see if it was a bottleneck?
     
  3. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    Could you please elaborate a bit more on this? A link would be super useful. Unfortunately, it won't be possible to upgrade project to the latest version of the Unity.

    Well, as I said above I can't do that: UI must not be upscaled.

    Not yet, I'm going to give it a try anyway just for testing purposes.
     
  4. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    Oh, I believe @jbooth did something similar for Walking Dead, right? :)
     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    https://docs.unity3d.com/ScriptReference/Camera.html

    It is there (look for allowDynamicResolution + friends).

    But, did you profile it?
     
  6. pachash

    pachash

    Joined:
    Apr 2, 2014
    Posts:
    55
    I did some better profiling and actually I was wrong! Here are the actual measurements:



    It looks like using 1080p with MSAA 2 makes sense on big tablets with crazy resolutions. While using 720p with MSAA2 makes sense on smaller tablets and phones.
     
    hippocoder likes this.