Search Unity

Question How to copy data to Texture2DArray as fast as possible

Discussion in 'General Graphics' started by joshuacwilde, Sep 23, 2021.

  1. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    727
    Right now, I have a use case where I stream in textures using Unity's texture streaming API, then use Graphics.CopyTexture() to copy those into a Texture2DArray. What I would rather do is just store the textures as raw data so then at runtime, I can pull only the mip I need (rather than the whole texture as Unity does) from disk, then copy that into a Texture2DArray, ideally without having to create an intermediate texture to do the copying (to avoid double copying data). Any thoughts?
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Store them as bytes, one file per mip, already compressed in the format you need. Then use the Texture2D API to load them, and copy them in via Graphics.CopyTexture (which has an option for mip source/target) mip by mip.