Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

(Unity 5.1) Should I use baked or real time lighting on my android phone project?

Discussion in 'Global Illumination' started by JanDawid, Jul 16, 2015.

Thread Status:
Not open for further replies.
  1. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    So I'm working on a little android project; it's a 3D game with a small ball as a character rolling around on a large terrain for a level. There'll be some spinning collectables along the way, enemies and maybe things like torches/fires to add to the atmosphere. I'm making it for android and am currently testing it on my phone (Moto G 2nd Gen). I'm currently using 2 real-time directional lights and one is casting shadows for both the character and the terrain (the other just illuminates only the terrain at an angle so that the shadowed areas aren't too dark).

    The game is currently running at ~40fps. I have disabled 'Precomputed Realtime GI' in Window>Lighting and my quality settings are basically the default 'Fastest' setting for android but with enabled V-Sync. When I enable shadows to 'Hard Shadows Only' and use low settings to render them, the FPS count dips down to ~30fps.

    So I was wondering, is using baked lighting going to boost performance? If so, how should I go about it? If I want my non-static objects to cast (real-time) shadows, how would I get that to work alongside baked lighting? Could I just make the shadows simple black circles underneath?

    I'm finding it hard to get a good answer on what exactly is the best choice for android/phone projects when it comes to lighting options. Some say that real-time lighting isn't supported across many phones, some say baked lighting takes up a LOT of memory space... so what does everyone recommend? Any ideas or tips? Things to consider? Have it out!

    Remember that I'm using Unity 5.1 if that makes a difference.
     
  2. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    When you use baked shadows, you will save GPU time because you don't have to render the objects into shadow map(s). You will also get higher quality soft shadows and ambient lighting. Try and use the skybox for ambient instead of a secondary directional light. Depending on your performance constraints a blob shadow can be a good choice.
    Memory shouldn't be too much of a problem, if you keep the resolution at reasonable levels.
    The Mobile Unlit (Supports Lightmap) is a super cheap shader because it doesn't do any lighting calculations, it just fetches it from the lightmap.
     
    Meltdown and JanDawid like this.
  3. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,908
    Aside from the above, you need to use the classic blob shadow trick for dynamic objects. Even big budget games like Xenoblade use them.



    You should aim for PS2 era graphics to get it running smoothly on tablets from the last 3 years or so.

    Here's a blob shadow script:
    http://pastebin.com/utbjyked
     
    JanDawid likes this.
  4. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,814
    With no lightmapping in my scene, I was getting 28-32FPS, but with the baked scene my framerate dropped down to 17-18 FPS, this is on an Android device. Any reason why?

    Realtime shadow performance is 1-2 FPS on Android with Unity 5, and baked performance results in a massive drop, so what to do?? I'm using Mobile/Diffuse shader.
     
  5. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,908
    You must have dynamic lights/shadows enabled still. Switch to Edit > Player > Rendering Path > to Vertex Lit or Forward.

    Fastest settings will be Vertex Lit, Gamma Color Space, Mobile Diffuse/Unlit shaders, no Image Effects, Quality Settings > Reduce everything, disable Precomputed GI.

    You can't do PC graphics on a Game Boy.
     
    Last edited: Jul 21, 2015
    JanDawid likes this.
  6. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,814
    This gives you 1-2 FPS on Android. So I'm not sure why you would suggest that.
     
  7. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,908
    I meant if you are getting 1-2, then you must have dynamic lights enabled, so you should disable them.
     
  8. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,814
    ??

    I already said I get 1-2 FPS in my original post with realtime shadow performance. Genius you are o_O
     
  9. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,908
    Try reading slower.
     
    MetaDOS and JanDawid like this.
  10. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    He is saying that you should disable them BECAUSE you have them enabled.
     
  11. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,814
    Oh you guys are funny :rolleyes:

    Do you really think I need someone to tell me when I'm getting 1-2 FPS with realtime shadows on, and 28-32FPS with them off, that I need to disable realtime shadows? lol.

    I've been using Unity for over 5 years, but thanks for the noob advice anyway.
     
    Last edited: Jul 21, 2015
    femor likes this.
  12. JanDawid

    JanDawid

    Joined:
    Jul 7, 2014
    Posts:
    283
    It was just miscommunication so let's all just get over it. Haha! Let's get back to talking about lights!
     
    Meltdown likes this.
  13. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,814
    Yeah so what is the verdict? Are you going to use baking in your Android game or not?

    My games visual quality (racing game) looks crap without any shadows on the environment/props etc, so baking is the only viable option. I think I'm slowly getting to the point where its coming right. I literally leave my scene to bake on overnight and see the result each morning. But I'm still seeing tons of bugs, and often the Android device doesn't show what the editor shows.

    One thing I discovered is that you need to make sure you have shadows enabled in your quality settings, and make sure your Android default platform is set to that quality setting with shadows.

    I'm still seeing some wierd black blotches on some of my props etc. Not sure how to fix this.
     
Thread Status:
Not open for further replies.