Search Unity

What's the best way to make "line of sight" effect on mobile?

Discussion in 'General Graphics' started by Vefery, Dec 26, 2019.

  1. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    119
    I want to make a game where you're exploring a completely dark building with only a lamp. So for making that shadow effect I've just given the player lamp with actual point light with enabled shadows and made new shader for all objects (shader from here: https://answers.unity.com/questions/1001969/unity-5-using-mobile-shaders-with-point-light-and.html).
    When there was only the player and the rooms I was able to get 60 fps on my phone, but then I added objects, character model and post process with color grading and grain. After that I can get only ~25 fps with 0.7 dpi scale. Is there a way to somehow fake point light shadows or get the similar effect? I recorded a little gameplay video where you can see what I want to get: https://drive.google.com/file/d/1P6rd6FtKJrlsZtZtnMYgmLeuxOWWoYcE/view?usp=drivesdk
     
  2. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    119
  3. doarp

    doarp

    Joined:
    Sep 24, 2019
    Posts:
    147
    Well regardless of your line of sight question, running post processing on mobile is expensive, and doing so at a constant 60 FPS is probably impractical on most devices.
    Thermal throttling is a serious issue and doing PP at 60 FPS isn’t helping.
     
  4. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    119
    Just tested the game and you're right. Without shadows, one material for all objects but with PP (vignette, color grading and grain) and it runs only 25-30 fps! Is there a way to fake PP?
     
  5. doarp

    doarp

    Joined:
    Sep 24, 2019
    Posts:
    147
    You could probably fake vignette with an overlay image made in photoshop or something. But you need to test performance to see which is faster. The problem with PP on mobile is that simply turning it on, with no specific PP effects, already has a significant penalty.
    So basically:
    - use as few PP effects as possible
    - tune the PP effect parameters for performance where possible
    - if you can avoid activating PP layer on the camera you will save a ton of performance.

    Also try using the builtin PP stack of URP in 2019.3. Unity claim that it is faster, but from my tests, mainly around Bloom, I didn’t see any significant difference on my device. Which is also an issue - your mileage will vary greatly depending on the device, and also the graphics API (Metal / Vulcan / openGLES).
     
  6. doarp

    doarp

    Joined:
    Sep 24, 2019
    Posts:
    147
    Also: unless you have the engineering capacity to invest a lot of time and effort into optimizations, I would give up on running at 60 FPS on mobile. Aim for 30. For short periods it’s not hard, but you’ll have a lot of trouble keeping it at 60 with thermal throttling, and especially with the huge variance in device specs.