Search Unity

Any way to set up two cameras with different culling masks with GoogleVR?

Discussion in 'Daydream' started by wojwen, Feb 24, 2017.

  1. wojwen

    wojwen

    Guest

    I'm trying to set up tow cameras with different culling masks and ClippingPlanes because otherwise I have to set nearClippingPlane to very low value so the cockpit of my ship is vivsible, but at the same time it causes mesh clipping on objects that are far away(I don't know why, it just works like this). The perfect solution would be to set up two cameras - one for cockpit with low nearClippingPlane and one for everything elese with high nearClippingPlane so there is no mesh clipping. The problem is that when I try to set up two cameras with different clipping planes values and depths the final image is completely wrong - the image from "cockpit camera" appears only on the bottom of the screen and in some middle part, also seems to be shifted. Does anyone know how to deal with this or maybe you have a better idea for solving this? I'm using Unity Daydream Preview 5.4.2f2-GVR13 and GoogleVR SDK 1.0
     
  2. Dirly

    Dirly

    Joined:
    Mar 24, 2013
    Posts:
    19
    Were you able to figure this out? I think I might have it partway there but it gets pretty messed up.
     
  3. reedny

    reedny

    Joined:
    Mar 4, 2017
    Posts:
    57
    Also curious on this, I have tried 2 cameras to have some meshes in front always. Using Unity 5.6.0f3, GVR Unity SDK 1.30, Android 7.0, Moto Z Force Droid.

    It works in the Unity Editor (showing Daydream dual-rendered windows) but on my phone with headset the 2nd camera does not render correctly
     
  4. reedny

    reedny

    Joined:
    Mar 4, 2017
    Posts:
    57
    More info:

    It works fine on my Windows 10 PC in the Unity Editor.

    But when played on my phone with the headset the meshes assigned (via layers)
    to the 2nd-camera move/rotate in the opposite direction as the headset moves,
    even though their transform is not changing.

    But 2nd-camera meshes do render in front of main-camera meshes.
     
  5. joejo

    joejo

    Unity Technologies

    Joined:
    May 26, 2016
    Posts:
    958
    A note about in-editor rendering for Google VR: If you are using the Google VR SDK for Unity, the rendering you get in editor is manually created by Google using their SDK. It is only a representation of what you would see and should not be relied upon to show a 100% fidelity view of what you get on the device. Just because it works in the Editor does not in any way guarantee that it will work on the device.

    If you are not using the Google VR SDK for Unity, then anything that you see in editor is not representational of what you get on the device since Google VR can only run on the device. There is no way for us to show what you would see on the device natively.
     
  6. reedny

    reedny

    Joined:
    Mar 4, 2017
    Posts:
    57
    Thanks joejo, understood that the PC Editor render is not the same as Android Daydream render. I am using Google VR SDK for Unity v 1.30.

    I put a sample project to show this here - http://www.imeditate.com/unity/two_cameras.zip.

    When run under Android Daydream the red cube reverse-follows the 2nd-camera, which is odd since the red cube is not a child of the 2nd-camera, or having its transform modified. But in the PC Editor, the red cube correctly renders in front of the other two cubes and stays put, as set by the layer assignment.
     
  7. reedny

    reedny

    Joined:
    Mar 4, 2017
    Posts:
    57
    Found a workaround -- have 2 cameras, don't parent 2nd-camera to the main-camera, but instead in update() sync their position and rotation. Then assign meshes that you want to be in front into a layer that the 2nd camera renders, and the rest of the meshes to the default layer, which the main-camera renders.

    Make sure to add a GvrPointerPhysicsRaycaster to 2nd-camera if you want to interact with meshes in the front layer also.
     
    lucasdglass likes this.