Shaderlab, how to pass a array of float

Hi,

This is probably a stupid question, but since there is a poor documentation about shader, I hope some will be able to answer me :x

So, as I understood it, for passing a float from c# to shader, we need to do it in 3 step:

  1. something.material.SetFloat("_MyFloat", 5f) C# side
  2. _MyFloat("A description", Float) = 0.0 Shader side. (ShaderLab properties)
  3. float _MyFloat; Shader side (Inside the CGPROGRAM)

at the step one I can use SetArrayFloat()

But, at the step two unity doesn’t allow Float[].

and the step 3 allow float _MyValue[]

So how can I achieve it ?

2.) You can’t set arrays via the material inspector, only via code (as noted here). So you don’t/can’t expose them in the properties block.

3.) Arrays need to be declared in Cg with a fixed size, e.g. : float _MyFloat[100];