Search Unity

skybox but only top half

Discussion in 'General Graphics' started by KovaPx, Jun 10, 2019.

  1. KovaPx

    KovaPx

    Joined:
    Jan 27, 2018
    Posts:
    15
    Hey guys, I'm using LWRP (but shouldn't matter) and Unity 2018.3.6f1

    Does anybody know if it's possible to render skybox for only top half, from horizon up? I have a case where to most demanding view in the scene is when you look down, no skybox visible, but if I turn it off fps goes up. So in conclusion turning off skybox, even if you don't see it, gets us a big performance boost. I'd like to eliminate that fragment depth test overhead.

    This is for #mobilevr (HTC Focus) so every tiny bit matters. We're using regular cubemap skybox. Texture size doesn't matter though, same overhead with 32x32 cubemap as with 1024x1024.

    Any help or hints are appreciated.
     
  2. KovaPx

    KovaPx

    Joined:
    Jan 27, 2018
    Posts:
    15
    Well it seems like using just your own skybox cubemap in the scene solves the entire thing. We have no idea why skybox is so slow when using unity's predefined skybox material slot. We found and used the first shader from
    https://en.wikibooks.org/wiki/Cg_Programming/Unity/Skyboxes
    and set the queue to Geometry+1, works without any overhead like before.
     
  3. Zdravko_FRG

    Zdravko_FRG

    Joined:
    Jun 10, 2019
    Posts:
    3
    To piggy-back off of Kova's comment: We are working on a mobile VR project using HTC Focus hardware.

    Through our optimization efforts, we discovered that disabling the Unity's Skybox (either by setting it's field to None in the Lighting settings, or setting it to null via code) yields unusually high performance gains.

    So much so, that with Skybox disabled, HTC Vive Focus has no problems pushing above 400.000 vertices with one real-time shadowing light at 75FPS target (which is way above commonly cited limits for Mobile VR development). With Skybox left on, device has trouble hitting the performance target, even with realtime lighting turned off and vertex counts decreased (oddly, within the commonly cited limits for Mobile VR development).

    As it's not possible to run Frame Debugger on a remote android device, and in fact device behaves differently with profiler attached, we have no idea what's actually going on, and why Unity's skybox costs so much performance, BUT I am willing to bet it's not expected behavior and could be a bug on Unity's side.

    Googling around for this issue doesn't yield much results, and aside from few sparse mentions, nobody seems to be aware that unity's skybox costs so much performance.

    Following is purely guess work based off of how far VS2019's decompiler will take me, but it seems that, since LWRP's Skybox pass requires a depth texture, the "Render Skybox" step in frame debugger actually does entire depth pass of the geometry, just to render out the skybox - but I could be wrong here.