Search Unity

Fog Mobile

Discussion in 'Image Effects' started by Ankaman, Jul 25, 2016.

  1. Ankaman

    Ankaman

    Joined:
    Feb 14, 2014
    Posts:
    37
    Hello,

    I read about the rendersettings.fog etc does not work on mobile? I tried to used the gobalfog shader, but it looks terrible on the mobile device compared to the rendersettings.fog. Is there any good tutorial for the gobal fog shader? or is there a way to get the rendersettings.fog get working on a mobile device?

    thx
     
  2. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    Ideally on mobile, you use custom shaders for everything, and implement fast per-vertex fogging within those. Calculate the fog strength per vertex, and you just need one extra fragment shader instruction to lerp towards the fog colour.

    Rendersettings fog, AFAIK, is calculated per-pixel (and patched into fragment shaders?). I thought it worked on mobile, but haven't tried it in Unity 5. If it still works in the same way, then it's not particularly fast on mobile, or at least it was certainly a bad idea back when targetting the iPhone 4S and similar devices - might be less of an issue now with many devices being a lot faster.

    Global fog is a postprocessing effect, requiring a depth texture, and also calculating the fog per pixel. It looks great, but I don't know if depth textures work on mobile. And if they do, it's not goint to be cheap..
     
  3. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
    in unity5, Window->Lighting->Scene->Fog is working on mobile(tested on both gles2/3), and quite fast because this fog is calculated in vertex shader, and only lerp result in fragment shader.

    only shaders provide by unity / your custom shader(you need to support unity's fog, it is default included if you create a new unlit shader in project window) can render this fog.

    You can imagine each object is rendering part of the fog, but the final result will become a complete fullscreen calculated fog.
     
  4. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    I test it on unity 5.1~5.2 and its work fine.
    but when i turn on Fog in unity 5.3 and newer versions ,my frame rate drop down very much than unity 5.2
    I m come back to unity 5.1.5 and its work prefect
    what is problem? I test on real android game project;
     
  5. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
    how much slower(CPU/GPU)? what device?
    I have a scene that use fog & built using Unity5.3.4, it runs quite fast on Mali400MP even with post process
     
    UnityLighting likes this.
  6. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    I've used Lenovo A3300-A3500
    I compare 2 version of unity. not two version of device
    Same device,same effect,same game,two version of unity
    also test it on other Mali400MP mobile device

    I tested two months ago. you can test a game with 30FPS average on 5.1.5 and 5.3.4 and compare result
     
  7. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,080
    Hello,
    im testing a custom script to generate fog for mobile devices. To perform the fog It uses a temp buffer the size of the screen, and at 1280x720 it weights 7MB. Isn't too much for a mobile device?