Search Unity

Material.SetVectorArray array size limit?

Discussion in 'General Graphics' started by laurentlavigne, Jan 10, 2018.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    is there a limit to the array size that can be passed to a material or a shader in 2017.3?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    I believe D3D11 has a limit of 4096 float4s (or 16384 floats, technically it's a limit of 64KB). The size of the array is also limited to the size of the array when initially set, so if when you first set the array it's 4 elements long, it can only ever be 4 elements long for the remaining time the game is running.
     
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    and unity follows that limit? i read that back in 5.4 it was limited to 1024 because of internal architecture not handling more
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Actually, Set_Array is likely still limited to 1023 (not 1024), but you can use compute buffers to pass larger sets.
     
  5. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,363
    "Compute Buffer" is the name of that vampire that doesn't want to die in my nightmares.
    What do you think of using Custom Render Textures to do influence map AI?
    I'm thinking SetPixel on the input texture for the grid position of each agent (instead of using SetColorArray on a material because there will be more than 1023 agents)
    Have the magic of CRT do a gaussian pass on the same output texture, frame after frame.
     
    Rs likes this.
  6. Mithrandir01

    Mithrandir01

    Joined:
    Jan 22, 2020
    Posts:
    3
    Hello Bgolus

    I'm having trouble figuring out how to use the computer buffer to change is size limit to pass larger sets of array. Could you show an example of how you would do that?
     
  7. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285