# raymarching slowdown

In my new raymarcher, using meta1 function gives me 600 fps (vsync off) , using meta2 function gives me only 58 fps (vsync off). But they are basically the same, positions[] pretty much containes the same vec3 data as is manually added in meta1, but it’s coming in via uniform arrays. Is a substraction that more expensive than an addition? Or is it the uniform array?

```float meta1(in vec3 P){ vec3 p1=P+vec3(5,0.0,12.0); vec3 p2=P+vec3(4,0.0,12.0); vec3 p3=P+vec3(3,0.0,12.0); vec3 p4=P+vec3(2,0.0,12.0); vec3 p5=P+vec3(1,0.0,12.0); vec3 p6=P+vec3(0,0.0,12.0); vec3 p7=P+vec3(-1,0,12); vec3 p8=P+vec3(-2,0,12); vec3 p9=P+vec3(-3,0,12); vec3 p10=P+vec3(-4,0,12); vec3 p11=P+vec3(-5,0,12); float r0 = Sz/dot(p1,p1)+Sz/dot(p2,p2)+Sz/dot(p3,p3)+Sz/dot(p4,p4)+Sz/dot(p5,p5)+Sz/dot(p6,p6); float r1 = Sz/dot(p7,p7)+Sz/dot(p8,p8)+Sz/dot(p9,p9)+Sz/dot(p10,p10)+Sz/dot(p11,p11); return -(r0+r1)+1.0; }```

```float meta2(vec3 P) { vec3 p1=positions[0]-P; vec3 p2=positions[1]-P; vec3 p3=positions[2]-P; vec3 p4=positions[3]-P; vec3 p5=positions[4]-P; vec3 p6=positions[5]-P; vec3 p7=positions[6]-P; vec3 p8=positions[7]-P; vec3 p9=positions[8]-P; vec3 p10=positions[9]-P; vec3 p11=positions[10]-P; float r0 = Sz/dot(p1,p1)+Sz/dot(p2,p2)+Sz/dot(p3,p3)+Sz/dot(p4,p4)+Sz/dot(p5,p5)+Sz/dot(p6,p6); float r1 = Sz/dot(p7,p7)+Sz/dot(p8,p8)+Sz/dot(p9,p9)+Sz/dot(p10,p10)+Sz/dot(p11,p11); return -(r0+r1)+1.0; }```

It likely uniforms that’s the slowdown. With the first code the compiler can insert those numbers directly into the assembly code, while the 2nd one requires memory lookups. Just the way GPUs work.