Search Unity

Question google carboard vr

Discussion in 'VR' started by DaudHTMs, Dec 12, 2020.

  1. DaudHTMs

    DaudHTMs

    Joined:
    Aug 17, 2020
    Posts:
    18
  2. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    I think that's slightly old info.

    Cardboard sdk is handled outside of unity. They will probably lock this thread unfortunately. If so, PM me if u run it to trouble I just went through the setup a few days ago (only on android) or go to github

    Here is the quickstart guide
    https://developers.google.com/cardboard/develop/unity/quickstart

    It says only OpenGLES2 is supported but that is old info.
    OpenGLES3 is now supported


    https://github.com/googlevr/cardboard

    https://github.com/googlevr/cardboard-xr-plugin

    I was able to get everything working but it's a little laggy feeling or motion blur, something not great about it compared to cardboard apps on the store, or compared to YouTube. Still trying to figure that out but until then I'm not feeling like its usable for me

    I'm interested to know if the "hello cardboard" test scene using xr plugin with unity performs different than the native compiled apk. I have not tried that yet
     
    Last edited: Dec 12, 2020
  3. DaudHTMs

    DaudHTMs

    Joined:
    Aug 17, 2020
    Posts:
    18
    thanks for the time i was trying to follow the developers.google carboard thing and i am having trouble installing git and setting it up. Is git optional and if its not how do i set it up. I searched up tutorials and they are all so confusing
     
  4. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    You don't have to install git, but you might want to try. I was also not using Git and got it to install after a bit of frustration
    I will give options for both:

    Instructions for windows 10 install git:

    Install git w default options from the website

    windows 10 start search area...start typing "environment"
    select : "edit system environmental variables"

    click:
    ...Environment Variables
    ...System Variables
    ...Path
    Edit

    add these new: (assuming this is where these are installed)
    C:\Program Files\Git\bin\git.exe
    C:\Program Files\Git\cmd

    restart unity, maybe computer too i'm not sure.
    command prompt, type git, enter. it should recognize it is there.

    try unity importing the cardboard SDK again
    https://developers.google.com/cardboard/develop/unity/quickstart


    ________________
    ________________

    if NOT using git:

    go here
    https://github.com/googlevr/cardboard

    The green "code" button zip does not have the full files ( or didn't before)
    on the right side of this page, click releases, v1.4.1 latest...
    it brings you here, for now:

    https://github.com/googlevr/cardboard/releases/tag/v1.4.1
    download source code.zip

    unzip it somewhere.

    Create new 3d project
    Package manager: click the +
    "add package from disk"

    find package.json from the newly unzipped folder)
    cardboard-xr-plugin-1.4.1 > package.json

    package manager should show the package, then samples inside it, hellocardboard
    import that. Follow the rest of the instructions on the quickstart guide

    note:
    use OpenGLES3 when you get to the instructions that current say OpenGLES2
    (take out vulkan i believe)

    if the android manifest is not in your project files when it wants you to edit that part:

    check off:
    edit: project settings> player>publish settings >
    custom main manifest

    it will show up now in your project and you can edit it as the quickstart guide wants

    make sure to uncheck optimize frame pacing when the instructions say so.

    This should work.
    I just now did a test on my PC importing the SDK this way instead of git and it works, the git way works too
     
    Last edited: Dec 15, 2020
  5. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    I think the new CardboardVR plugin works really nice. The new Unity XR system also feels like an improvement.
    Would say the new Cardboard test scene is comparable with the old one. It´s the one to one tracking that make it feel a bit laggy, and I guess it´s a side effect from the limited field of view. To make it more fit for gaming you has to crank it up a bit yourself by letting the camera rotate more to make a full turn in less than 360 degrees.

    Still missing a proper method for recenter the tracking though.
     
  6. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    Can you explain further? I'm not sure what you mean by one to one tracking or how I might crank it up myself
     
  7. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Turn your head 360 degrees, and the camera will also make a full turn. So if you are looking stright forward and wants to see something at 90 degree angle in some direction, the limited fov forces you to turn the head a lot more compared to real life. That makes if feels soggy, or laggy. One way to compensate for it is to let the camera turn more than your head so you dont have to turn your head so unaturally much when playing the game, and make it feel more snappy.

    It´t easy to test by holding your hand at the side of your head, and note how much (little) you have to turn the head to see it. Compare that to the much more movement needed in the game.
     
  8. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    Would you mind pointing me in the direction of how to change that?
    I adjusted the Field of View on the camera in the inspector, but that must not be what your talking about as it keeps the same head turning amount/speed
     
  9. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    The framerate on my pixel xl4 android is reading out as 200+ fps w cardboard app. with FPS bogs down as the motion blur happens.

    I cannot seem to lock it to a lesser framerate. searching around seems to indicate its set by the SDK for most or all VR sdks. Anything I do to set the FPS or vsync seems to get ignored. The phone itself indicates its refresh rate is 90. This is also what non-VR unity apps read out as (90fps).

    So, kind of seems like the 200fps is an issue.

    I have a motorola g-S*** android or something and it reads 30fps w cardboard. Its hard to compare them...

    but reading out 220 fps and then bogging to 170fps seems match timing w the motion blur im describing
     
  10. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Don't think the frame rate has so much to do with it. One way is to just check how much the XR subsystem has turned the camera since the last frame, and then add some fraction of it in y, to the player, or the camera parent.
     
  11. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    Well I seemed to have failed to figure that out.

    I cant figure out how to access any info related to xrsubsystem
    I tried to edit the tracked pose driver but it over writes whatever i save in that file.
    I did increase the camera rotation based on old/new frame difference in another class, but that doesn't interact well with the pose driver, or whatever is setting the camera.

    That being said though. When I run "cardboard" demo app from google play, everything is smooth, and its also 1 to 1, I spin my chair 360 degrees and land in the same position on screen.

    What I'm seeing is w the unity hellocardboard build is almost a jitter, turning head fast or slow. I don't think increasing the rotation speed will change it.. I feel like there has to be a stupid setting I am missing.

    Even If I figure out how to change the rotation speed as you say. If your turning your head slowly looking at something it still will see jitter I believe.

    I think this person might be referring to the same problem as me
    https://github.com/googlevr/cardboard/issues/163

    The response was:
    the sensor fusion is performed by a Kalman filter in the SensorFusionEkf class. You can find details about its implementation here.

    but I don't find the equivalent to that file in the unity sdk version

    If its not obvious I'm still fairly new at this

    What phone are you using that you feel its working well on?
     
  12. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Yeah it would be nice if there was a setting for it, to change the game camera rotation ratio from the real world head rotation. For now I guess you have to keep track of it yourself by storing the eulerAngles, or localEulerAngles in each frame to see how much it has changed to the next frame.

    I haven't noticed any jitter from the new XR subsystem. The only degradation was when using the old built in VR in Unity 2019.4, where the tracking made the camera vibrate, like never before, kind of moving the camera one step forward, and a half step back every second frame.
     
    Last edited: Dec 15, 2020
  13. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    It almost seems that way on my device now. intermittently, its not really a lag thing as much as something seems off w the frame timing.

    looks like someone else just filed a similar issue:
    https://github.com/googlevr/cardboard/issues/180
     
  14. DaudHTMs

    DaudHTMs

    Joined:
    Aug 17, 2020
    Posts:
    18
    does someone have a tutorial or a video i can watch, i suck at following direction. I am 13 so i have a lot of school work and i totally forgot about my project i was working on.
     
  15. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Think there aren't any youtube tutorial for it yet, only for the previous VR SDK which is fine for Unity 2018.
    Maybe you could make one for the new XR System? :)

    All the the few steps for the new XR System are in the quickstart guide as Treecrotch pointed out. Just add the demo scene. The stuff for downloading Unity, and building the app, and running it on a device are the same as for any non VR game for Android, or iOS.


     
    Last edited: Dec 23, 2020
  16. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    not yet that I know of

    You do not have to use git if you don't want to. You can do this instead:
    That should get you past the git part you first reported being hung up on.
    There are some other details in post#4 if you run in to a snag with the quickstart guide.

    I agree videos are nice, but if you keep at it line by line its not to difficult to get the sample project going.
     
  17. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    I was complaining of poor tracking in cardboard SDK on my android pixel 4 xl.
    similar threads over at github were pointed towards this bug
    https://github.com/googlevr/cardboard/issues/164

    I'm going to assume i am experiencing this same issue, I think my original description siting "motion blur" was not really the best choice of words.

    I still remain at a point where I cant build anything with this for my pixel without it performing worse than any other cardboard app on google play
     
  18. DaudHTMs

    DaudHTMs

    Joined:
    Aug 17, 2020
    Posts:
    18
    I couldn't get it to work probably because im dumb but i followed all the directions. Im using it with unity remote 5 which is working but the tracking is not working, when i rotate the phone the game doesn't do anything.
    here what i did for the directions
    I tried doing it without git but there were no json files to choose from so i chose the git way
    I added the package from git url with this url https://github.com/googlevr/cardboard-xr-plugin.git
    I skipped steps 5 and 6 because they are just for the scene
    then i switched platfroms to android
    then i switched the defaul orientation to landscpq left and unchecked fram rate pacing.
    Then removed vulcan and kept opengles2
    then i selected IL2CCP
    I choose both ARMv7, ARM64
    then i slected require internet acess.
    then i went to build settings and selected custom main graddle templete and also checked custom main manifest and checked custom launcher manifest
    then i went to Assets/Plugins/Android/mainTemplate.gradle
    i clicked on maintmeplate which opened a notepad and I pasted this
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation 'com.google.android.gms:play-services-vision:15.0.2'
    implementation 'com.google.protobuf:protobuf-lite:3.0.0'

    in the notepad,

    edit: sorry for the bad spelling i was in a hurry

    then i went to Assets/Plugins/Android/main manifest
    and clicked on androidmanifest which opened visual studios and I pasted
    <application android:requestLegacyExternalStorage="true" ... >
    ...
    </application>
    in the visual studio

    then i went to project settings and Selected Cardboard XR Plugin under Plug-in Provider
    then i changed the devices to all android devices
    it is appearing on unity remote 5 but its not in vr form

    plzz help
     
  19. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    So you do see the hello cardboard scene but nothing happens?
    can you do a debug build sent to the phone and check for errors? Can you just push it to the phone like a regular build with no unity remote?

    I'm not all that experienced around here either, I've tried unity remote before and couldn't get it to work so I'm not familiar with it.

    I do recall running in to a situation at first where the hellocardboard was on the phone but nothing happening. when i published a debug build and linked it up there was an error i had to fix.

    ...i would assume unity remote does something similar

    EDIT:
    oh i see you said you skipped the steps with the sample scene. I would go back and get that sample scene working. It has the camera setup with the tracked pose driver and stuff.

    get the sample scene working. and then all you have to do is turn off the "cuberoom" game object and you basically have a blank working with camera and tracking and stuff.

    Without that sample scene, even if you did import the SDK properly you didnt setup a camera w the components it needs.

    also are you able to import from git without error now? if not then nothing is in there
     
    Last edited: Dec 24, 2020
  20. DaudHTMs

    DaudHTMs

    Joined:
    Aug 17, 2020
    Posts:
    18
    I got the hello cardboard scene but nothing really happens, there are no errors either. I tried building the game but it kept saying build failed so i just used unity remote 5. the scene shows up but the camera doesnt move at all
     
  21. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    You need to "Add Open Scenes" in the Build Settings dialog to include it in the build. (Also set the demo scene as the Active Scene in the game, and remove the default scene from it.)

    Check the error message in the Conslole log if It it dosn't help.
     
  22. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    Why though, what does it say
     
  23. DaudHTMs

    DaudHTMs

    Joined:
    Aug 17, 2020
    Posts:
    18
    when i use unity remote 5 i get this error
    NullReferenceException: Object reference not set to an instance of an object
    VrModeController.Update () (at Assets/Samples/Google Cardboard XR Plugin for Unity/1.4.1/Hello Cardboard/Scripts/VrModeController.cs:78)


    when building the game i get like 80 errors for some reason.
    and i get a popup saying something was wrong with gradle



    EndLayoutGroup: BeginLayoutGroup must be called first.
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)


    UnityEditor.BuildPlayerWindow+BuildMethodException: 78 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x0027c] in <d1bec46880064709a5e713ad543e6d96>:0
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <d1bec46880064709a5e713ad543e6d96>:0
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
     
    Last edited: Dec 24, 2020
  24. tree_arb

    tree_arb

    Joined:
    Dec 30, 2019
    Posts:
    324
    Well, taking a guess:
    Unity remote isn't playing well with the sdk, prob because it's running on the computer as well and not just the phone.

    Building it right to the phone normally should work, but if getting gradle errors and such. You will have to go through quickstart steps again 100%, from the begining make sure u follow build settings exactly.

    If you know it's right, try just making a new blank project and exporting android app to the phone.

    Do you have the latest Android sdk and ndk setup in unity and all that fun stuff? That part isn't covered in the cardboard quickstart guide.

    So to recap I would say this:
    Press play just in the editor on hello cardboard demo scene. No errors there? Good.

    Get any basic project exported to an android phone. No unity remote. No errors, Good.

    After that it's just a matter of setting from the quickstart guide
     
  25. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Which platform are you building it for? Think the Cardboard VR plugin only runs on Android, or iOS. You have to choose that too in the Build Settings dialog, and then Switch Platform.
     
  26. DaudHTMs

    DaudHTMs

    Joined:
    Aug 17, 2020
    Posts:
    18
    i already did that for android
     
  27. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Which one of the platforms are highlighted in the Build Settings box?
     
  28. DaudHTMs

    DaudHTMs

    Joined:
    Aug 17, 2020
    Posts:
    18
    android
     
  29. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    There are a lots of tutorials for the building part of the app. This one for example:


    (From 1:07:10 in the film)
     
    Last edited: Dec 24, 2020
  30. DaudHTMs

    DaudHTMs

    Joined:
    Aug 17, 2020
    Posts:
    18
    I made a new project and got it building just fine hold up im going to try to do everything from scratch again wish me luck

    edit: I got it working yay, thank you so much for all of your time
    the thing i was doing wrong was

    "If Target API Level is set to API Level 29 or Automatic (highest installed) (resulting in API Level 29), the following steps are also required:

    1. Select 'Custom Main Manifest' in the Build section.
    2. Add the following attribute to the application tag of Assets/Plugins/Android/AndroidManifest.xml:

      <application android:requestLegacyExternalStorage="true" ... >
      ...
      </application>"
    I actually didn't need to this step
    for some reason when i didn't do it, i got no errors and it worked good, the tracking is working too
     
    Last edited: Dec 25, 2020
    arfish likes this.