Search Unity

Writing to Rendertexture array vs Copying to Texture array

Discussion in 'General Graphics' started by Chickenkeeper, Dec 23, 2018.

  1. Chickenkeeper

    Chickenkeeper

    Joined:
    Jun 23, 2018
    Posts:
    9
    Hi, I'm working on a tiled-terrain system and I need to store texture data for each tile in a texture array. I also need to write to individual array elements as needed (from a compute shader), and generate mipmaps for them. I've already tried Rendertexture arrays but mipmaps don't automatically generate when a texture is written to from a compute shader, with autoGenerateMips set to true. Also GenerateMips doesn't have a variable for the specific texture in the array to generate the mipmaps for, and I don't want to be generating mipmaps for every texture in the array each time one of them is changed.

    So could there be a bug with autoGenerateMips, or would it be more efficient to write to a single rendertexture, generate its mipmaps manually, then copy it to a regular texture array instead? And does GenerateMips always generate mipmaps for every texture in the RenderTexture array or can it just generate mips for the textures that have been changed?
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    3,014
    Texture array is a single texture.If you call GenerateMips on it, it will do that for all layers, always.
    I'm not sure if that's intended behaviour or not. I'd suggest reporting a bug.

    Rendering to a single texture, generating mipmaps and then copying the stuff to the texture array sounds like an efficient way to do this.
     
  3. Chickenkeeper

    Chickenkeeper

    Joined:
    Jun 23, 2018
    Posts:
    9
    Ah that makes sense, thanks for clearing that up! I'll take another look at autoGenerateMips in case the fault is on my end, and report a bug if necessary.