Search Unity

Question Texture2D Arrays, kind of confused.

Discussion in 'Shader Graph' started by N1warhead, Sep 25, 2019.

  1. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Howdy everyone, well I got me some Texture2DArrays setup and ready for Shader Graph. But I realized - it's not making the slightest bit of difference than I was having using regular Texture2D Samplers in Shader Graph.

    The reason? I still have 16 samplers (which breaks the Shader).
    So despite only having 4 Texture2D Arrays, that results to 4 Albedo Samplers, 4 Normal Samplers, 4 Roughness Samplers = 16 Samplers.

    The part that is really confusing me is how I handle the Index value in the Sample Texture 2D Array.
    I can't seem to find a way to loop through all the indexes.

    The way my Arrays are set up (0 = Albedo, 1 = Normal, 2 = Roughness, 3 = Height, 4 = AO).

    I haven't set up Height or AO yet, but if you look at the images below. It shows how I'm handling the Texture2DArray samplers. Which I know is clearly wrong, but this is the part I can't quite figure out..

    Something tells me in reality I should only have '4' samplers and somehow 'loop' through all the indexes and connect them to where they need to go, but I haven't a clue how to go about that, I can't seem to find any looping nodes, so seems like a lost cause honestly.
    upload_2019-9-25_10-41-46.png upload_2019-9-25_10-42-3.png upload_2019-9-25_10-42-15.png

    So as you can tell, I have 4 Texture2DArray samplers for each type of Texture (4 Albedo, 4 Normal, 4 Roughness), and clearly I see this is all wrong, but if this is truly the way to handle it, it really seems like this node is pointless as it would just be easier to have a simple Texture2D Sampler node rather than going through all the headache of making an editor script to make texture2D arrays.