I have to use array in the shader (float4) but I can’t get it to work:
float4[] spheres;
spheres[0] = float4(10, 1, 10, 1);
spheres[1] = float4(8, 1, 10, 1);
spheres[2] = float4(6, 1, 10, 1);
spheres[3] = float4(12, 1, 10, 1);
float Sphere1 = sdSphere(p - spheres[0].xyz, spheres[0].w);
float Sphere2 = sdSphere(p - spheres[1].xyz, spheres[1].w);
return opSmoothUnion(Sphere1, Sphere2, 1);
When I use separate variables, everything works perfectly, but there is a problem with array.
How should I define and use them in a shader?