Hello,
I’m having trouble with passing in some floats to my shader. Here’s a snippet of what and where my float declarations are:
...
Pass{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
//we include "UnityCG.cginc" to use the appdata_img struct
float sampleStrength;
float sampleDist;
float samples[10];
...
My understanding is that I can use the
mat.SetFloat("sampleDist", 1.0f);
mat.SetFloat("sampleStrength", 2.2f);
It’s also my understanding that the array unrolls into samples0-9. For example:
mat.SetFloat("samples0", -0.08f);
mat.SetFloat("samples1", -0.05f);
...
It appears that I’m not getting the values I’m setting and what’s even more strange is that if I re-order my declaration, like:
float samples[10]; // moved from bottom to top
float sampleStrength;
float sampleDist;
I get different outcomes.
I’m now wondering if there’s alignment issues I don’t understand, like 16 byte boundaries or something. Anyone see this issue? If I do not pass in the values, but declare and set them in my fragment shader, everything works. So, I know the values are correct. I’m just trying to figure out what I could be doing wrong trying to pass them in.
Thanks
Jeff.