Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    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?