Search Unity

Post processing stack performance and alternatives

Discussion in 'Image Effects' started by Autoface, Jun 7, 2017.

  1. Autoface

    Autoface

    Joined:
    Sep 23, 2013
    Posts:
    112
    Hi, I've just installed the post processing stack content from the store and it brings the fps down on mobile devices by about 20 fps give or take. Regardless of whether or not I have post processing effects enabled it still has a huge impact on the performance of my game.
    Is there anyway I can increase the performance of this? or any other ways I could add some post pressing affects to my game without using the stack content from the store?

    I'm only really interested in using vignette and and colour grading. It doesn't matter whether or not I have them enabled the impact on performance is terrible.

    I'm aware I could use a sprite in front of the camera for vignette so that's not a problem but I really don't want to use this method for the colour grading or adjusting the overall colour of the scene.
    I would like to use the colour grading in my 2D game which uses a top down view. The colour grading would be used to "suggest" the colour of the sky, time of day and a nice addition for weather affects. for example blistering heat would make the screen slightly red or yellow tinted. Cold weather would create a blue kind of tint.

    I'd like to mention that I already have all settings set to low in unity.

    Does anyone have any ideas or suggestions?

    Many thanks



    **Edit** arrr man I just realised this should have been posted in Image effects. Could it be moved possibly?
     
    AsemBahra likes this.
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Time difference can't be measured in fps. The difference in fps is always relative to the fps that you started with. So, from what to what did you go in terms of fps? Then we can calculate the difference in ms, which is the actual thing to look at.

    Example 1: From 40 to 20 fps. Time taken is 1000/20 - 1000/40 = 25 ms

    Example 2: From 100 to 80 fps. Time taken is 1000/80 - 1000/100 = 2,5 ms
     
    Last edited: Jun 8, 2017
    marserMD and hippocoder like this.
  3. Autoface

    Autoface

    Joined:
    Sep 23, 2013
    Posts:
    112
    Thanks for getting back to me. So my game is averaging at 40fps. When i have post processing stack attached to my camera without having any effects enabled it drops by around 20fps.

    A jump from 40fps to 20fps while only having it in my scene with no effects enabled is pretty bad. I've tested on high end devices and low end devices and all with a similar outcome which is a massive drop in frame rate.

    Any ideas?

    Thanks again
     
    Last edited: Jun 8, 2017
  4. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    So that's 25 ms per frame. That is quite a bit, so I would look at alternatives. (Or write your own.) Mobile devices are not great at overdraw, so you will always take a bit of a hit with postprocessing. What is the impact if you just put in a dummy postprocess?

    1. Create a new Image Effect Shader shader (It inverts the colors by default, which is great for seeing it's applied)
    2. Write a script that uses this shader in OnRenderImage
    3. Apply the script to the gameObject with the camera

    The next step is the actual implementation, but this will show you the minimal impact of any postprocessing.
     
  5. Oliver-Bogdan

    Oliver-Bogdan

    Joined:
    Dec 30, 2014
    Posts:
    4
    Hey, have you found a solution for this? I have the same issue with the post processing stack. Only having it attached to the camera (no actual effect enabled) will drop my game to 30 fps from 60 which is unplayable.
     
  6. Kumo-Kairo

    Kumo-Kairo

    Joined:
    Sep 2, 2013
    Posts:
    343
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I had DOF, bloom, grading, volume particles, shadows, noise, light shafts, 4xMSAA, lighting and 250,000 polys at <16ms on ipad2 so with some fudging and approximation (and some cheating), you can get the appearence of a lot of high end effects, depending on your needs.

    Tips:
    • start with https://forum.unity.com/threads/dof-on-ios-how-we-did-it-mini-post-mortem.143887/
    • modify for bloom
    • mask for shafts
    • render entire screen to a buffer - reuse this all the time, don't grabpass
    • keep ALU cost in fragment low as possible
    • do all your work in vertex shader
    • roll your own lighting in vertex shader
    • raise polygon count (it makes sense if shifting responsiblity from frag to vert)
    • consider faking transparency by reading render texture and drawing opaque
    Note: this approach is only good for tile deferred hardware with low bandwidth needs and as always, to lower res targets, as doing a lot of work in vertex is fine on mobiles. This may even end up slower on desktops.

    That's how I did it and it looks close to what unity puts out these days on desktops. If you squint. Our project changed from mobile to console so we no longer use it. I may package it up one day for people to tear apart. I don't think that would be of real use though, so I haven't. I no longer do invasive lighting replacement work or anything like that these days as everything is moving too fast to bother. It's a full time job to do optimised post and lighting, there's no time left for the game. in a few years, mobiles will handle Unity's post without blinking and all be iPhone X performance.

    Unity's post stack is not yet optimised for mobile or XR properly, so you will only want to use Unity's post for console and desktop at the moment. They do plan a lot of optimisations but I think the smart money is on waiting for scriptable render pipeline to drop properly.
     
  8. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,906
    It also depends on what kind of effects you want - Color Grading and SSAO or SSR are quite different in terms of performance - orders of magnitude indeed.

    Effects that do not require depth/normals information are quite fast. Color Grading/, sharpening, ... require very low texture fetches.

    Beautify includes 3 levels of optimizations including a simplified feature-set that works without depth info so you can tailor the quality of the post-fx according to the device capability/user settings with a single toggle, from OFF, Basic, Best Performance, Best Quality.
     
    Last edited: Jan 5, 2018
    Onevisiongames likes this.
  9. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    I would stay away from Unity's built-in postprocessing stack on mobile. It's simply not designed for it, anyone who has dug into their shaders will know what I mean. Tons of high cost instructions for differences that basically can't be seen on mobile.

    If you're serious about mobile and want a Post-Processing stack that has actually been used to release multiple games on iOS and Android, and has had a stable version since last year, I encourage you to check out PRISM. If PRISM can't perform better than any other post-processing stack at equivalent quality settings on mobile, I will give you a full refund.
     
  10. luisfelipeart

    luisfelipeart

    Joined:
    May 8, 2015
    Posts:
    1
    I would add a step between (2) and (3). You'll want to right-click on the shader and select Create > Material. Then reference that material on your script in the camera.

    This video covers it nicely for those interested:
     
    Deleted User likes this.