Log in or register to post comments

Narrow viewport for AR camera not clipping Terrain

September 30, 2015 - 12:11pm #1

When using the ARCamera with the Cardboard the camera view is narrower than the usual Cardboard barrel distortion viewport rendering. This is likely due to the aspect ratio of the Galaxy S6 camera I'm using. The issue is that the Unity Terrain is not clipped by the narrower Vuforia camera masks. You can see that in the attached photo. The water is clipped just fine but the Terrain is not. The Terrain is filling out the whole Cardboard viewport.

How can I achieve that the Unity Terrain is masked/clipped by the narrower video overlay?

AttachmentSize
Image icon WP_20150930_21_06_51_Pro_LI.jpg282.49 KB

Narrow viewport for AR camera not clipping Terrain

December 30, 2015 - 11:20am #9

Did you find any solution to this? i can change the field of view but it zooms in to much. so you get headeachs and dizzy.

 

Narrow viewport for AR camera not clipping Terrain

November 24, 2015 - 5:13am #8

Thank you so much man! I'm kinda overwhelmed right now with other project but I'll definitely try this and get back to you.

 

Thanks!

Narrow viewport for AR camera not clipping Terrain

November 17, 2015 - 4:57pm #7

Suffered through this process again recently, myself.

The Cardboard/Unity documentation ( https://developer.vuforia.com/library/articles/Solution/Integrating-Cardboard-SDK-050 ) has been slightly out of date (as are many things here since the project is surging forward so rapidly these days). You have to feel your way through it until they update. It does look like they've fixed a couple names recently though.

I don't have a clean scene with just the bits that you need since what I have is now hopelessly conflated with other IP, but I can give you a few tips. Do yourself a favor and build the setup in a nice, clean, fresh project - don't try to build this on top of another scene. It's tricky enough without dealing with other variables. Assemble it and once you have it working make it a unitypackage that you can load into your other projects.

This is my checklist modified from the instructions at the link above).

  1. Make sure you have the latest Vuforia Unity Extension (5.0.6 right now) from https://developer.vuforia.com/downloads/sdk
  2. Get the latest Cardboard for Unity goodies here (0.5.2 currently) https://developers.google.com/cardboard/unity/download
  3. Update Unity (5.2.2f1 right now)
  4. If developing for iOS make sure you have the latest XCode. For Android, update the Android SDK and do whatever other configuration may be necessary.

    In my experience, the above are hugely important checks to make. Small variations in what Cardboard expects from Unity and what Unity expects from the Vuforia extension can cause all sorts of problems that you just can't fix by checking a box or editing a single script somewhere. Some combinations are simply toxic.
     

  5. Create a new Unity project and create a new scene in that project - don't do this in an existing project until you have it working. You can always write this out as a UnityPackage when it's ready.
  6. Delete whatever camera is present in the scene
  7. Load both the Vuforia Unity Extension and the Cardboard for Unity SDK
  8. Steps 3 and 4 here are mostly ok: https://developer.vuforia.com/library/articles/Solution/Integrating-Cardboard-SDK-050 but I do a couple things differently:
    • I leave the stereo multiplier property set to 1
    • I leave "Check Stereo Comfort" turned on because I intend to use raycasting to determine center of interest. It's safe to turn off though.
  9. In step 5 when it instructs you to add this line: Vuforia.VuforiaBehaviour.Instance.ApplyCorrectedProjectionMatrix(proj, eye == Cardboard.Eye.Left);
    I ignore it, though you might choose to do differently. It duplicates the projection matrix between the eyes which gave me flat renders (no stereo rendering) and the projection matrix doesn't feel right for the duplicated eye, even in mono. I'm not sure why the instructions mention setting up the Stereo Multiplier if the next step is going to disable stereo rendering.
  10. Also in step 5 - AndroidVRDevice.cs doesn't exist any more. It's now called CardboardAndroidDevice - but the line they mention isn't in that script any more either. It's in BaseCardboardDevice.cs now (and is inherited by CardboardAndroidDevice). There's no longer a conditional about Unity5 - it's just set to false. You'll want to set debugDisableNativeDistortion to true.
  11. Likewise, iOSVRDevice.cs doesn't exist now. It is now called CardboardiOSDevice.cs - the recommended change can be made there.
  12. Step 6 of the docs suggest configuring for legacy distortion rendering and link to a page that mentions nothing about legacy distortion rendering (it probably did at one time, but the destination page has been updated). I suspect this was meant to be referring to "Native Distortion Correction" but I have ignored it without ill effect. I feel like this has probably been overtaken by events and is no longer necessary but someone else may want to weigh in.
  13. For Step 7, as far as iOS is concerned I make the changes to the code under Assets/Plugins/iOS instead of in the XCode project - the tutorial just seems jumbled here - I don't know why you'd patch these in XCode when you can change them in your Unity project - it would simplify updating to later versions of the Vuforia SDK but I do builds far more often than there are updates to Vuforia. I can't speak to their suggestions for Android.

Finally, you can top off the project with the cardboard settings tweaks they mention though that's not necessary to get a project working.

Narrow viewport for AR camera not clipping Terrain

November 17, 2015 - 12:32pm #6

Yeah but your answer is based on a Vuforia project already adapted to Cardboard, and my problem is exactly at this point.

 

I just can't make Vuforia and Cardboard work together, even following the instructions on the Library. In the interface part is everything ok, but in the code changes, some of the files don't even exist on my project (and I'm using Vuforia 0.5.0 and Cardboard 0.5).

 

Any chance for you to have a "clean" project just with the functional parts of Vuforia and Cardboard so I can see what was done?

 

Thakns.

Narrow viewport for AR camera not clipping Terrain

November 17, 2015 - 11:12am #5

See my earlier response. You just have to disable the mattes on the Cardboard Left and Right camera instances and disable Skew Frustum for the ARCamera. This will increase the rendering area. The actual video preview will still be narrower depending on your camera resolution and screen size.

Narrow viewport for AR camera not clipping Terrain

November 16, 2015 - 4:28am #4

Hi, can you share some info on how did you achieved the field of view on your attached image? I already tried a hundred times integrate Cardboard SDK with Vuforia (following the instructions on a page from Vuforia itself) with no joy. And when I use the stereo camera from Vuforia, the lens area is too small...

 

I already tried this many and many times, can you please tell me how you did this?

 

Thanks.

Narrow viewport for AR camera not clipping Terrain

October 6, 2015 - 11:11pm #3

Thanks for the info. Remobing textures is not going to be a solution for sure.

In the meantime I found a workaround: I checked "Disable Mattes" for the HideExcessAreaBehaviour script attached to the Cardboard Left and Right camera and also disabled Skew Frustum for the ARCamera. This lets the rendering cover the full cardboard field of view.

 

Narrow viewport for AR camera not clipping Terrain

October 6, 2015 - 9:17pm #2

It seems familiar that there was something different in how Unity Terrain objects were rendered or maybe the order they are rendered. Here's an old thread that discusses occlusion with a Unity Terrain and one developer mentioned removing the textures from the terrain to get occlusion working:

https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/depth-mask-and-unity-terrain-not-occluding-my-terrain-p#comment-2031754

 

Log in or register to post comments