Search Unity

Depth based LOD optimization in VR mode [SOLVED]

Discussion in 'AR/VR (XR) Discussion' started by arnebp, Oct 9, 2015.

  1. arnebp

    arnebp

    Joined:
    Oct 15, 2013
    Posts:
    22
    Hi All

    I have created a proof of concept scene that show the effects of depth based rendering optimization. I am having trouble getting this to work in 'VR mode' in Unity 5.2.1.

    I have two cameras with each their frustum rendering 'near' and 'far' objects in the scene. The 'near' camera render close vicinity high polygon objects and the 'far' camera renders low polygon objects far away. Simple stuff.

    I have a third camera that combines the RenderTextures of the 'near' and 'far' camera using a custom 'depth combine' shader.

    This all works well when running in non-VR mode, but when I turn on my HMD (Oculus DK2) and start the scene, the main camera running the custom shader freezes and does not render anything to screen. I can see in the editor output that the Camera is active and running, but no output. This happens using 'normal' Unity Camera class and also using the Unity Utilities from Oculus (OVRCameraRig).

    Can anybody point me in the right direction?
     
  2. arnebp

    arnebp

    Joined:
    Oct 15, 2013
    Posts:
    22


    I have set up and shared the base project. Please download and inspect in interested in this problem.

    Press 'Alpha0' aka zero key to switch between depth LOD camera and normal camera.

    The script CombineDepth combines the RenderTexture of the 'near' and 'far' camera.

    When I turn on VR support in 'Player Settings -> Other Settings -> Virtual Reality Supported' and put on my Oculus DK2, all I get is black screen output. Hence the CombineDepth script seems to be overridden somehow.

    Any ideas?
     
  3. DrBlort

    DrBlort

    Joined:
    Nov 14, 2012
    Posts:
    72
    Looks like it's something in the settings.

    I first checked your scene, shader, etc. and everything seemed ok. Then I realized that should be the blit, but that would be really unlikely, so I tried other image effects, like "Blur (optimized)" and "Tilt Shift" and they didn't work either.

    Suspecting a bug in 5.1.2p3 I loaded a test of mine with those same effects, and it worked ok.
    So then I tried reimporting your files without the "ProjectSettings" folder and that was it. Works like a charm :D
     
  4. DrBlort

    DrBlort

    Joined:
    Nov 14, 2012
    Posts:
    72
    I looked into the settings, to see if I was able to found what was different, and this jumped out. I don't know what this means exactly, it's new to me.



    I chose save to asset, and got these files.



    Maybe it's useful enough to send a bug report to Unity, if you want.

    EDIT: Added the files, to save you the trouble.
     

    Attached Files:

    Last edited: Oct 12, 2015
  5. arnebp

    arnebp

    Joined:
    Oct 15, 2013
    Posts:
    22
    Thank you for looking into this @DrBlort !

    After you pointed me in the right direction, I was quickly able to conclude that the problem lies with the choice of Rendering Path. It was set to 'defeered'. Switching to 'forward' makes everything work.

    I'll do my best to communicate this to Unity.

    Thanks again.
     
  6. DrBlort

    DrBlort

    Joined:
    Nov 14, 2012
    Posts:
    72
    No problem!

    I can't believe I missed that setting! :)
    If it helps, I've tried my project with image effects in deferred mode, and they worked. I don't know enough about writing shaders to know if they should be written differently for forward vs. deferred.

    Cheers!