Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Graphics Texture2DArray Surface Sampling problems

Discussion in '5.4 Beta' started by NerdyOrc, May 10, 2016.

  1. NerdyOrc

    NerdyOrc

    Joined:
    Aug 6, 2013
    Posts:
    17
    Hi, I am testing the Texture2DArray and for the life of me I couldn't make the sampling work in the Surface shader, it compiles with no problem using #ifndef SHADER_TARGET_SURFACE_ANALYSIS, but the uv seems to be always turn to float(1,1), even as the uv works with regular tex2D sampling.


    To make it visual the following sampling returns the next image.
    Code (CSharp):
    1. o.Albedo =tex2D (_myTexture, IN.uv_MyArray);  
    upload_2016-5-10_14-41-16.png


    And the same applies to this:
    Code (CSharp):
    1. #ifndef SHADER_TARGET_SURFACE_ANALYSIS
    2.               o.Albedo = UNITY_SAMPLE_TEX2DARRAY(_MyArray,float3(IN.uv_MyArray,0));
    3.           #endif

    upload_2016-5-10_14-42-49.png
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    You can remove the whole SHADER_TARGET_SURFACE_ANALYSIS check, if you're using 5.4 beta15 or later. That should work without problems.

    The reason for your thing is that the "what is actually needed by the surface shader" analysis step now thinks that "hey, UV of _MyArray is not used, so let's not generate code for it".