Search Unity

External Texture API Bug -- Unity Devs

Discussion in 'Scripting' started by Lanre, Nov 28, 2015.

  1. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    Hello Guys.

    I noticed that the external texture API (CreateExternalTexture, UpdateExternalTexture) do not support reading or writing. You can check this out by downloading Unity's iOS External Texture Example Asset on the Asset Store. Calls to GetPixel(s), ReadPixels, SetPixels, and EncodeToJPG or PNG fail. This is also the case on Android.

    I'd like to know Unity's take on this. Please fix it. Thank you very much!
     
  2. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    ReadPixels etc work by keeping an uncompressed copy of the texture data in CPU memory (for normal textures, this requires that you mark the texture readable, see https://docs.unity3d.com/ScriptReference/TextureImporter-isReadable.html ).

    When using ExternalTextures, there is no CPU cache of this data so it's up to you to manage that. You owned the CPU data that you wrote to the external texture, so you can make your own accessors / mutators of the data and upload / read from the GPU API when you want to.

    (Sorry for resurrecting an old thread, someone asked for an answer to this)
     
    forestrf and TaleOf4Gamers like this.
  3. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,971
    No worries. I ended up learning this and a lot more as I developed NatCam, especially for its preview data pipeline.