Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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".