I think I found a way to massively optimise some of my procedurally generated meshes, but to do so I need to access what is effectively a nested array in my shaders.
So first approach, flatten the thing but I will need more than 1024 values which is likely Unitys limit for array sizes (Reference: Material.SetVectorArray array size limit? )
Instead what I am trying to do is something like this in a CG Includes file:
float4 BendAxis1 [14];
float4 BendAxis2 [14];
float4[] GetAxis(int index)
{
if(index == 0)
return BendAxis1;
else
return BendAxis2;
//then many more checks for other axis
}
Problem is, the shader wont compile and doesn’t like: float4[ ] GetAxis(int index) because of “Unexpected token ‘[’”
Any idea if its possible to return an array in shaders and if so what the syntax would be?
I could probably get around this with a baked texture lookup but would be a far messier solution so would rather avoid that!