Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Access cubemap of ARKit environment texture??

Discussion in 'AR' started by Tuitive, Feb 20, 2019.

  1. Tuitive

    Tuitive

    Joined:
    Mar 25, 2013
    Posts:
    36
    I need to access the textures that make up the cubemap generated by ARKit's environment/reflection probe. I can do this successfully in non-ARKit scenes by doing this:

    Code (CSharp):
    1. Cubemap cm =  reflectionProbe.customBakedTexture;
    2. Color[] colors = cm.GetPixels(CubemapFace.NegativeX);
    3.  
    4. Texture2D tex = new Texture2D(256, 256);
    5. tex.SetPixels(colors);
    6. tex.Apply();
    7.  
    8. //do something with tex (apply to a Material, RawImage, whatever...)
    This works great on-device for non-ARKit scenes, but it fails in ARKit scenes. Xcode says the texture is empty even though I can see the reflection probe is working and reflecting the room, so it MUST have a cubemap on it. Are ARKit reflection probe cubemaps different in some way?? Any insight or guesses, however trivial, would be greatly appreciated!
     
  2. Tuitive

    Tuitive

    Joined:
    Mar 25, 2013
    Posts:
    36
    So, I've confirmed that calling GetPixels on an ARKit-generated environment texture (cubemap) returns garbage or nothing. @jimmya can you pretty please give me a hint why this is so?