Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

GLSL arrays can't be size 1?

Discussion in 'Shaders' started by Big_Friggin_Al, Mar 8, 2016.

  1. Big_Friggin_Al


    Jan 9, 2014
    In my shader, I was playing around with different values and noticed something bizarre (to me).

    I have an array, and if I size it to any number it works fine, but if I size it to 1, I'm unable to access the data at index 0 (either in a loop or not).

    To set the data I do a setFloat from my .cs script and I know it works, because when I getFloat it returns the correct value, but the shader will not reflect that unless I change the array to be size 2 or higher (at which point it totally works to access the data at index 0).

    Is this some kind of built-in limitation of the language that I'm not aware of?
  2. Farfarer


    Aug 17, 2010
    It's possible that setFloat, when given a single value, is just calling the "single value" version of the API's "setFloat", rather than the array one.