Search Unity

Edited standard shader with TEX2DARRAY doesn't work in standalone

Discussion in 'Shaders' started by slingchilders, Jan 22, 2017.

  1. slingchilders

    slingchilders

    Joined:
    Nov 25, 2016
    Posts:
    6
    I've edited the standard shader and replaced all the 2d maps with TEX2DARRAYs and I'm sampling them via UNITY_SAMPLE_TEX2DARRAY. In the editor it works like a charm. However, when I go to the standalone player it just shows geometry that is completely black.

    I managed to pinpoint the point of failure, and I think it is inside the fragForwardBaseInternal method. I know the textures are loaded properly, because if I override this method with just this:
    half4 difCol = UNITY_SAMPLE_TEX2DARRAY(_MyArr, myCoords);
    half4 specCol = UNITY_SAMPLE_TEX2DARRAY(_MetallicGlossMap, myCoords);

    and return color from that, it shows correct texture.

    I haven't touched the functions inside FRAGMENT_SETUP or the lighting code. So it must be failing somewhere among these methods:
    FRAGMENT_SETUP, FragmentGI, UNITY_BRDF_PBS, UNITY_BRDF_GI - none of wich I edited.

    Why does this happen? Why does it happen ONLY in the standalone player? I'm not using any shader emulation inside the editor, the shader version is the same between the editor and the player? What's going on?

    Edit:
    Also, I read that it could be some shader code missing. So I included the shader to be always included in the build, but then the build gets stuck at globalgamemanagers.assets, I let it run overnight, but it never finishes, just freezes. Why?
     
    Last edited: Jan 22, 2017
  2. slingchilders

    slingchilders

    Joined:
    Nov 25, 2016
    Posts:
    6
    Ok, I included the shader to be always in (Graphics settings) and now it works. But it took more than 12h to make a build! Why is that? Could it be because some of the files in my shader go between custom ones and the standard shader includes? Or is it a normal time to build a custom shader that inhertis from the standard one?

    I get this error when I include it to be always present:

    Code (CSharp):
    1. Shader "Custom/MyShader" with 157766 variants is marked as always included (see Graphics Settings). This will result in long build times and runtime memory consumption.  Please use a shader variant collection instead.
    Is the number of variants inside that shader (157766) a large number? I just edited the standard one to use texture arrays in albedo, metallic, etc. methods.
    Are "long build times" expected to be over 12h? How would I go about creating a shader variant collection?