Search Unity

Issues with Texture2DArray

Discussion in 'Shaders' started by bgulanowski, Jul 15, 2019.

  1. bgulanowski

    bgulanowski

    Joined:
    Feb 9, 2018
    Posts:
    36
    I get an error in the editor when I select objects that use a texture array 2d as their main texture. This does not happen during gameplay. It seems to happen when I select any object, 3d or 2d, whose shader is based on texture 2d.

    I'm using a customized version of the standard shader that I found on the Internet. Although it's not that complicated, mostly a find/replace of the use of texture2d with texture2darray and changes to types as needed. I've seen some suggestions that it would be better to not use _MainTex variable, but define another one. Would that be enough to fix it?

    Unity needs better workflow support for Texture2DArray. Or better documentation. And maybe the standard shader needs some love to make it easier to customize it. I'm not that experienced with practical techniques, although I've read a lot of serious documentation and tutorials. My use case seems … fringe.
     
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,549
    Yeah I would recommend trying a different name for it than _MainTex, as _MainTex is referenced by various editor code and CGINC files for default texture, and those things aren't going to expect it to be a Texture2DArray.

    Surface shaders aren't going to be improved, they're part of the legacy pipeline. LWRP and HDRP are what will get improvements going forward, with ShaderGraph being built up as the "replacement" to surface shaders basically.