Search Unity

Question Getting camera feed texture

Discussion in 'Unity MARS' started by Katerpilet, Nov 16, 2021.

  1. Katerpilet

    Katerpilet

    Joined:
    Aug 2, 2015
    Posts:
    87
    Trying to get camera feed texture using IUsesCameraTexture and this.GetCameraTexture(), but rendering it to screen seems to always show as white. I'm using URP and 2020.3 w/ latest MARS. Is there any other special configuration I need
     
  2. jmunozar

    jmunozar

    Joined:
    Jun 23, 2008
    Posts:
    1,091
    Hey there!

    Interesting; Do you get the same problems if you are not using URP ?
     
  3. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    Which platform is this on?
     
  4. Katerpilet

    Katerpilet

    Joined:
    Aug 2, 2015
    Posts:
    87
    I got the IUsesCameraTexture working on Android (both URP and Standard), but it wasn't working on iOS for me. The ARCameraManager method works in conjunction with MARS on both platforms, so I ended up using that.
     
  5. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    Ok - interesting to know that it isn't working on iOS, we'll look into that.

    And as you found, MARS can coexist with AR Foundation managers in your project so you can also use those.
     
  6. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    Confirmed that this is a bug in MARS with AR Foundation 4. A fix is coming, but the workarounds are to either use AR Foundation 3 or to use the ARCameraManager directly.
     
  7. Realift

    Realift

    Joined:
    Oct 12, 2021
    Posts:
    9
    Can you explain how to get the ARCameraManager directly?
     
  8. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    You can just have one in your scene (and other AR Foundation components) and MARS will use them instead of creating it's own.
     
  9. azevedco

    azevedco

    Joined:
    Mar 2, 2014
    Posts:
    34
    Hi CiaranWills,
    It seems this is still an issue that i'm experiencing with my project for iOS, yet running as intended for Android.
    Unity 2020.3.12
    URP
    MARS 1.3.1

    Is there a status update on this fix?

    I've tried switching out some systems to utilize the AR Foundation components but was given an error from the MARS Session component, should that just be removed?

    Cheers!
     
  10. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    What is the error you see?
     
  11. azevedco

    azevedco

    Joined:
    Mar 2, 2014
    Posts:
    34
    Thanks for your response!
    Haven't really looked out for an error, is it something that would be shown in XCode since this only occurs on iOS builds?
     
  12. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    Yeah, when you build and run from xcode you should see messages in the xcode console.
     
  13. azevedco

    azevedco

    Joined:
    Mar 2, 2014
    Posts:
    34
    We're currently getting the following error message from xCode:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object.
    2. at Unity.MARS.Providers.IUsesCameraTextureMethods.GetCameraTexture (Unity.MARS.Providers.IUsesCameraTexture obj) [0x00000] in <00000000000000000000000000000000>:0
    3. at Unit9.UserMarsMirror.LateUpdate () [0x00000] in <00000000000000000000000000000000>:0
     
  14. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    Interesting - you don't see this error?
    Code (CSharp):
    1. Metal: Error creating pipeline state (Unlit/ARKitBackground): depthAttachmentPixelFormat is not valid and shader writes to depth