Search Unity

Unity 5.1 VR Getting Started

Discussion in 'AR/VR (XR) Discussion' started by thep3000, Jun 10, 2015.

  1. noemis

    noemis

    Joined:
    Jan 27, 2014
    Posts:
    76
    Thank you Ed, this solved my problem... I attach a screenshot for all how think about where to put the oculussig file.
     

    Attached Files:

    WendelinReich likes this.
  2. noemis

    noemis

    Joined:
    Jan 27, 2014
    Posts:
    76
    Here's more Feedback which currently comes into my mind where I have / see problems:

    Mixed Mode / activate vr mode later: When I activate the "virtual reality supported" button the samsung s6 asked to attach the gear before the app starts... but it would be better in some cases, if I could decide, that the app starts with normal content / infos / menues and an additional VR Gear / Cardboard mode which could be activated through loading a scene for example or just activate through script and give a message that now the gear / cardboard should be used.

    Renderlayer for each cam? In my previous stereo setups I had two cameras. Now it's easer, just one cam... but also shared render layer :( - how can make an object render only for left eye / right eye? This is especially interesting when using 360° stereo images in a sphere where every eye should see it's specific texture / sphere object.

    FOV: Why is the FOV of in the samsung gear fixed... in a test, I could not change the FOV at runtime... but what if I want to simulate a spyglass in VR for example?
     
  3. Vainte_

    Vainte_

    Joined:
    Jul 5, 2015
    Posts:
    2
    Is there any possibility for setup VR for 3dTV side by side mode? In docs i found VR split device, but I don't know how to use it. Is there any tutorial for it?

    Thanks for any advice and sorry for my english.
    Regards
     
  4. scottb9239

    scottb9239

    Joined:
    Jan 5, 2013
    Posts:
    107
    I had a typo in my Plugins/Android/assets, sig file works fine now. But...

    Just converted my project over to using the native VR support, all works fine except the frame rate is dramatically lower, one level was around 30-60 fps and is now 8fps. Looking at the profiler now to see what's going on... :(
     
  5. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    Hi there,
    When native VR support is enabled and the device is active, components attached to the camera receive the OnPostRender event twice per frame.

    Is this expected behaviour?
     
  6. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Yes, once for each eye.

    This is controlled by the android manifest entry
    <meta-data android:name="com.samsung.android.vr.application.mode"
    android:value="vr_only"/>

    It can be changed to vr_dual to support both vr mode and phone mode. We don't currently have built-in support for this but maybe in the future.

    We are working on a solution for this.

    We've had a few requests to change FOV, we're discussing allowing FOV override in the future. For now it is not possible.
     
  7. scottb9239

    scottb9239

    Joined:
    Jan 5, 2013
    Posts:
    107
    Okay, I looked into this some more. I got back a lot of the difference in frame rate from Oculus plugin vs native VR support. But I am now at a point where I can't optimize it anymore and it seems that the native VR is around 15-30% slower on both of my VR games I'm working on vs the Oculus plugin VR. :|
     
    DrewMedina likes this.
  8. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    @scottb9239 is it possible to submit a bug report? We haven't actually seen any scenes that perform worse with native VR so we would be very interested in taking a look.
     
  9. scottb9239

    scottb9239

    Joined:
    Jan 5, 2013
    Posts:
    107
    Hi, I will see if I can put together a comparison pair of projects and submit a bug report (after further confirming if it is slower before submitting). Thanks.
     
  10. bleu

    bleu

    Joined:
    Apr 6, 2013
    Posts:
    41
    I've heard that dynamic batching in GearVR doesn't quite work in Unity 5.1.1. Maybe this was addressed in the patches though. Also I'm not sure if the mobile VR rendering pipeline is as good as Unity 4.6*...I'm curious to read other people's opinions about this.

    The other issue is that the standard shader seems to be required for light maps for Unity 5, and I'm not sure if that's performant for VR mobile yet. In a small light mapped environment that I tested in it seemed fine with 4x MSAA, but in more complicated scenes that I have yet to port to Android it seems like an open question.

    If anyone has experiences in these two areas please let me know.
     
    Last edited: Jul 7, 2015
  11. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
  12. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    You must switch platform to PC and version to 0.5.0.1-beta .. see attached screenshot. Screen Shot 2015-07-08 at 10.48.24 AM.png
     
  13. bali33

    bali33

    Joined:
    Aug 14, 2011
    Posts:
    232
    Thank you !
     
  14. MarxentAnthony

    MarxentAnthony

    Joined:
    Feb 20, 2015
    Posts:
    18
    My app crashes when I load the EXE I am using 0.6.1 and unity 5.1.1p3. It runs fine in the editor but crashes when I load the standalone exe. Thoughts?
     
  15. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    What does the crashlog look like? IE: What does the stacktrace look like?
     
  16. MarxentAnthony

    MarxentAnthony

    Joined:
    Feb 20, 2015
    Posts:
    18
    Here is my output_log.txt
     

    Attached Files:

  17. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    Do you get the same crash with an empty project? The VRDevice has been created properly according to the log. But a detailed stack trace isn't present, so it would be easiest for you to submit a bug report.
     
  18. MarxentAnthony

    MarxentAnthony

    Joined:
    Feb 20, 2015
    Posts:
    18
    It works with an empty project. And oddly when I returned to the previous 'bad' project, I built and tested in preparation for a bug report the darn thing worked. So go figure.
     
  19. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    That sounds like it might have been a nasty Project upgrade bug. We had some issues with that on 5.1.1f1. You should try updating to the latest patch since those issues have definitely been fixed since. If you do see the issue again though, report a bug.
     
  20. oddgoo-io

    oddgoo-io

    Joined:
    Aug 22, 2014
    Posts:
    16
    Thank you for this! I am another developer who needs the "vr_dual" functionality.

    However, I'm having trouble modifying the Android Manifest.

    First I tried adding my own in Unity, but I got a "manifest merge conflict" error since it seems that Unity adds its own in the build process.
    Then I tried manually extracting and modifying the manifest inside the apk, but apktool.jar kept giving me errors and overall it's another bunch of pain poins.

    Is there any other option? What would be your recommendation?

    Note: The app is working fine in "vr_only" mode. It's only the "vr_dual" that I need to make work.
     
  21. quitebuttery

    quitebuttery

    Joined:
    Mar 12, 2011
    Posts:
    329
    I think my biggest issue with this is the requirement that the DK2 be plugged in for OSX when developing for Gear VR. In many cases I want to edit and run the project without a HMD.

    Having a DK2 hooked up to my MacBook Pro causes chaos with all my connected displays and resolutions. Previously, I made entire Gear VR projects in editor using a mouse to look around, and making native builds to test on device.

    I'd appreciate the option to run in editor without a HMD connected and using a mouse to move it around.

    Not to mention the fact I can't figure out how to quit out of the game when running in editor in VR--ESC doesn't seem to work?
     
  22. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    I think apktool post processing is your best bet right now, we don't have a smooth workflow for this yet.
     
  23. InfiniteLee

    InfiniteLee

    Joined:
    Dec 11, 2014
    Posts:
    4
  24. oddgoo-io

    oddgoo-io

    Joined:
    Aug 22, 2014
    Posts:
    16
    Thank you! After plenty of struggle, I fixed my errors by making sure I did all possible steps:

    Code (CSharp):
    1. adb pull system/adb pull /system/framework/framework-res.apk
    2. apktool if framework
    3.  
    (Pulling resources from the connected device, and adding them to apktool's framework).

    However, the resulting build crashes on startup with memory errors :( :

    Code (CSharp):
    1. A/libc﹕ Fatal signal 6 (SIGABRT), code -6 in tid 21381 (UnityMain)
    2. subj=u:r:untrusted_app:s0 pid=21381 comm="UnityMain" reason="memory violation" sig=6
     
  25. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    I'd try following this guide for repacking an apk. First simply unpack / repack with no changes, verify it runs on device with no crashes. Then unpack / change manifest / repack. If you are seeing a crash only with the changed manifest, I'd guess that the vr_dual manifest entry isn't doing what we think, and maybe there are some more changes that need to happen in order for it to work. I haven't investigated it much. Note that you can get a decent callstack on the crash with a developer build which can give us a better hint on the issue.
     
  26. ViktorCor

    ViktorCor

    Joined:
    Jul 22, 2012
    Posts:
    13
    Don`t work antialiasing ! ((
    before it was available in Oculusf Rift Rig
     
  27. EdBlais

    EdBlais

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    311
    You can change antialiasing in the Quality Settings. I can confirm this has been available since 5.1.1p3. Please try the latest release and change the MSAA value in the Quality Settings either through script or in the Editor Window.
     
    ViktorCor likes this.
  28. oddgoo-io

    oddgoo-io

    Joined:
    Aug 22, 2014
    Posts:
    16
    Thank you for your time!

    Unpacking and Repacking with no changes runs fine. It is only the vr_dual mode that causes an instant crash. Attached here is the section of the logcat with the debug version.

    At the top of the stack I can see:

    Code (CSharp):
    1. 07-16 01:05:37.788    2960-2960/? I/DEBUG﹕ #12 pc 0074d1ac  /data/app/com.myCompany.myVRDualApp-1/lib/arm/libunity.so (VRDeviceOculus::OculusEventGfxThread(VRDeviceOculus::OculusEvent)+220)
     

    Attached Files:

  29. Marcellus_Wilson

    Marcellus_Wilson

    Joined:
    Jul 19, 2013
    Posts:
    12
    I'm trying to move my mobile game over to gear vr. After turning off all lighting and switching to matcap shaders, I am close but still not hitting 60. I was wondering if there was a timetable for the options to throttle the cpu and to set VRSettings.renderScale on gear vr?
     
  30. Lumen-Digital

    Lumen-Digital

    Joined:
    Aug 3, 2012
    Posts:
    16
    This is a requirement for our projects as well. While the community will appreciate the simplification of implementing VR in Unity I think a lot of developers will require a greater level of control than what is currently exposed.
     
  31. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    L/R rendering masks is coming in 5.1.2p1 this week. Will update with more details when it lands.
     
  32. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    Hi again,
    I'm trying to make some native rendering work with native VR and after solving the double OnPostRender() call, I noticed I often get wrong values when building the view and projection matrices.Nnative rendering flickers from left to right possibly indicating values not updated correctly, or maybe I'm doing something wrong?

    I get the view matrix from
    Code (csharp):
    1. m_Camera.worldToCameraMatrix;
    where m_Camera is the cached Camera component retrieved on Awake().

    I get the projection matrix from
    Code (csharp):
    1. GL.GetGPUProjectionMatrix(m_Camera.projectionMatrix, isRenderingToTexture);

    This is all done from the OnPostRender() callback, so I would assume the Camera component's values are right for each eye's callback by frame?

    Thanks in advance for your help.
     
  33. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    This all sounds fine. You mention your native rendering flickers from left to right -- where are you issuing the plugin events for native rendering?
     
  34. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    From the OnPostRender callback, right after sending the aforementioned matrices to the native side.
    Basically, I have :
    Code (csharp):
    1. void OnPostRender()
    2. {
    3.   UpdateCamSpecificStuff();
    4.   GL.IssuePluginEvent();
    5. }
     
  35. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    Also, it seems the flickering only occurs in the editor's game view and the oculus' left eye, for some reason.
     
  36. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Editor view == left eye, so that makes sense.

    Note that when your code gets called from GL.IssuePluginEvent, it is on a different thread from UpdateCamSpecificStuff (if multi-threaded renderer is enabled). So you'll need to do some synchronization there.

    You can try forcing single threaded renderer (start unity with -force-gfx-direct) .. if the issue goes away it's likely a synchronization problem between main thread / render thread.
     
  37. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    Right, I wasn't thinking of that, must be it.
    Sounds like native VR support is going to be less trivial than I anticipated. Oh, well...

    I'll try forcing single threaded rendering and work from there, thanks.
     
  38. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    Ok, so disabling multi-threaded rendering indeed made the flickering go away.

    Is there a way of knowing in OnPostRender which eye finished rendering?
     
  39. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Left eye first, right eye second is the current way. This will be easier in 5.3 -- we are planning to have the stereo view / projection matrices available as parameters on the camera, but this doesn't help you right now.
     
  40. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    Ok, thanks. I managed to fix the flickering.
     
  41. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    Ok, one last thing, I think.
    For non-VR rendering, I have 2 extra offline cameras, one to get the scene's depth and another one to natively render a distortion pass applied to the main camera with a custom image effect.

    With the Oculus plugin, since we had a camera for each eye, this went smoothly but native vr is a whole other story.

    - So first, how can I get a native handler (glUint or Resource pointer) on each vr eye's depth texture?
    - Secondly, how can I add an offline camera for each vr eye?
    - Last but not least, how can I add an image effect on each eye?

    If any of the above are actually possible, of course. :)

    Thanks for your help!
     
  42. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    camera.targetTexture is filled out when the camera is rendering (OnPostRender, etc). You can get the native ptr during those times... but that's only color buffer. I'll see what colleagues think about exposing depth buffer ptr as well. I don't think it's possible right now... but maybe with offline rendering method described below:

    Any cameras that have a target texture assigned will not render to the backbuffer and they also won't be head tracked. Making them a child of a head tracked camera node may work, but this is the center eye position.

    One thing to try: leave camera with no target texture... this way it is head tracked. OnPreRender, use SetTargetBuffers on the camera to fill out your own color / depth buffer textures.. which you can get native ptrs to and access in your native plugin OnPostRender.

    Any image effects added to the camera will be executed on both eyes separately.

    Note that in 5.1.2p1 there will be the ability to have two separate cameras do two separate rendering passes to render the scene, one for left eye one for right eye which can help ease transition here. It's generally only recommended for cases that need to render different things in each eye (via render layers), because you miss out on optimizations with two cameras.
     
  43. ArtyBoomshaka

    ArtyBoomshaka

    Joined:
    Mar 5, 2013
    Posts:
    226
    Thanks for your help!
    I'll look more into it when I have some time when patch is out, then.

    That'd be great!
    Also, currently we're adding an additional camera to render the depth to a texture using SetTargetBuffers(color, depth).
    We haven't changed this in ages, maybe there's a better way of doing it? Re-rendering the scene just to get the depth texture is really expensive, if we could save the additional draw calls, that would change our lives.
    We used to have an image post-effect rendering the depth in a texture, but the consequence was we were a frame late when our native rendering was done. Also image effects on mobile are really expensive, too.

    So yeah, if your colleagues have any insight on this, I'd love to hear it. ^^
    Thanks so much!
     
  44. dagon

    dagon

    Joined:
    Jan 4, 2013
    Posts:
    20
    Material Chrome : shader Standard(specular setup) is very terrible in gear vr but normal in no virtual reality supported
     
  45. bleu

    bleu

    Joined:
    Apr 6, 2013
    Posts:
    41
    It seems like my Mac builds are plagued by horrid input lag when VR support is checked, even though no HMD is plugged in at all. So even though I would like to make Mac builds that can run in 2D mode, I can't because native VR mode checked off makes those builds unusable because of input lag. The rendering looks fine. This lag does not occur in the editor at all -- only in builds.

    To see what I mean, try this project out:
    https://drive.google.com/file/d/0B9MvONPTD3x6S2x1UVU0bnp3TDQ/view?usp=sharing

    Test the only scene out in the editor and then in the built version (VR support is checked). The movement is very simple here; use W and S. I'm currently on 5.1.2f1 because p1 doesn't work in stereo.
     
  46. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    A similar bug was identified on Windows -- a fix should be coming in 5.1.2p2.
     
  47. LordChilli

    LordChilli

    Joined:
    Jul 30, 2015
    Posts:
    4
    I'm getting some weird behaviour running Unity 5.1.2 on a Mac. I've got an extremely simple project, with just a couple of cubes. When I run it, I get the Oculus Rift health warning displayed, and it takes ages to go away. I also can't seem to find a way to stop running and return to the editor (the escape key doesn't do it., nor does any key I've found) I have to quit Unity altogether with CMD+Q, although that doesn't always work. Anyone else getting that?
     
  48. chriskotopher

    chriskotopher

    Joined:
    Dec 6, 2014
    Posts:
    1
    I have a scene utilizing both a regular camera and the VR and I wish to toggle between the two through a settings menu. However, when I toggle back to regular view from VR the camera is now stretched and screwed for the settings it needed for the Oculus. I tried calling the camera's ResetProjectionMatrix() but it doesn't work after I fixed the FOV back to 60. Doesn't work. Not sure where else to go from there.

    Running 5.1.2 and latest SDK for Oculus (6.0.1)

    UPDATE: Version 5.1.2.p2 fixes this issue.
     
    Last edited: Jul 31, 2015
  49. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Did a search and could seem to find if this question had been asked yet.

    Any plans to increase VR device support for such devices as Google Cardboard / VISR / ALPS for example
    Or open up the VR options to be able to configure the lenses, barrel and so on?
     
    imunity02 likes this.
  50. bleu

    bleu

    Joined:
    Apr 6, 2013
    Posts:
    41
    I've been trying to include an Android plugin with a Native VR app. This Android plugin has always worked with non-VR apps, but now it breaks with this message when building with VR support:

    CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
    /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java -Xmx2048M -Dcom.android.sdkmanager.toolsdir="/Applications/adt-bundle-mac-x86_64-20140702/sdk/tools" -Dfile.encoding=UTF8 -jar "/Applications/Unity/Unity.app/Contents/BuildTargetTools/AndroidPlayer/sdktools.jar" -

    stderr[

    UNEXPECTED TOP-LEVEL EXCEPTION:
    java.lang.IllegalArgumentException: already added: Lcom/****/*****/R$attr;

    I literally made a barebones Java class which does absolutely nothing at all, and this message still appears and prevents compilation. The existence of the .jar file in Plugins causes this bug to occur, but only when VR support is checked.

    I'm going to prepare a project to post here. Any thoughts help. I don't have duplicate jars in the Plugins folder, so that's not the root of the problem (plus it only happens when native VR support is toggled).