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.
  2. Dismiss Notice

Dynamic Shader Or Array of Shaders Question

Discussion in 'Shaders' started by namoricoo, Oct 27, 2011.

  1. namoricoo

    namoricoo

    Joined:
    Apr 14, 2011
    Posts:
    534
    Does anybody know a way to have an Array of Texture Shaders or to Dynamically create shader properties.

    I'm looking for something like.

    Properties
    {

    _MainTex( "Particle Texture", 2D[] ) = "white" {}

    }

    where 2D[] would be the An Array of Textures.... I know that 2D[] is an invalid syntax. I'm looking for the correct way to do it. Any insight would be appreciated.
     
  2. Chickenlord

    Chickenlord

    Joined:
    May 13, 2011
    Posts:
    381
    Texture arrays are only supported in DX10/11 as far as i know.
     
    petersvp likes this.
  3. namoricoo

    namoricoo

    Joined:
    Apr 14, 2011
    Posts:
    534
    So is it not supported? I don't know what DX10/11 is.
     
  4. Chickenlord

    Chickenlord

    Joined:
    May 13, 2011
    Posts:
    381
    It's supported with DirectX 10 upwards (or DirectX 11, not completely sure). As Unity uses DirectX 9, no it isn't.
     
  5. namoricoo

    namoricoo

    Joined:
    Apr 14, 2011
    Posts:
    534
    Thank you for your quick response. Have a nice day.
     
  6. R-Type

    R-Type

    Joined:
    Oct 31, 2012
    Posts:
    44
    Just to avoid wasting time in seeking a solution for my problem:

    I have the same requirement, but now in Unity 4. I need to pass an array of textures to the shader. Is there a solution now?
     
  7. Chickenlord

    Chickenlord

    Joined:
    May 13, 2011
    Posts:
    381
    I don't think Texture arrays are supported yet, but i'm not completely sure as i'm having quite a bit trouble finding out how to use the new DX11 features myself. What you could do is use a compute buffer, though it would only work for textures with the same size.

    But as said i might be mistaken. You could just try if it works on the shader side and then try to figure out, how to best set all the textures in the array.
     
    Last edited: Dec 23, 2012
  8. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Texture arrays aren't supported in Unity right now (even if they would, they'd need a very recent GPU and using DX10/11 to actually get them - before that, you just can't do texture arrays).
     
    petersvp likes this.