# Raymarching SDF artefacts

hi guys,

I’m quite new to the glsl world (actually in programing general :).
I try to figure out why there are artefacts in my glsl programming, and i am pretty sure it’s because of my cells are incorrect?! the rotation in it or maybe cause of the sine on y coordinate?

heres is part of the code i use:

``````float sdBox(vec3 p, vec3 b){
vec3 q = abs(p) - b;
return max(q.x, max(q.y, q.z));
}

void pR(inout vec2 p, float a) {
p = cos(a) * p + sin(a) * vec2(p.y, -p.x);
}

float opSmoothUnion( float d1, float d2, float k ) {
float h = clamp( 0.5 + 0.5*(d2-d1)/k, 0.0, 1.0 );
return mix( d2, d1, h ) - k*h*(1.0-h); }

float sceneSDF(vec3 p)
{
vec3 p1 = p;
p1.z += 0.5;
float sizeB1 = 1.0;
vec3 c = floor((p1 + sizeB1*0.5)/sizeB1);
vec3 l = vec3(5.);
p1.y += cos(c.x + uTime)*0.5+0.5;
p1.xz = p1.xz-sizeB1*clamp(round(p1.xz/sizeB1),-l.x,l.x);
pR(p1.xy, c.x + uTime - c.z);
pR(p1.yz, c.z + uTime);
float box = sdBox(p1, vec3(0.15));

vec3 p2 = p;
float sizeB2 = 1.0;
vec3 cB2 = floor((p2 + sizeB2*0.5)/sizeB2);
vec3 lB2 = vec3(4.0);
p2.y += sin(cB2.x + uTime*0.7931)*0.7+1.0;   // noise(c.xyx)  + sin(c.x * .5) + sin(c.y * .5 + uTime) *2.0 -1.0;
p2.xz = p2.xz-sizeB2*clamp(round(p2.xz/sizeB2),-lB2.x,lB2.x);

pR(p2.xy, cB2.x + uTime - cB2.z);
pR(p2.yz, cB2.z + uTime);

float box1 = sdBox(p2, vec3(0.2));

float boxes = opSmoothUnion (box, box1, 0.3);

return boxes*0.8;
}
``````

Can anyone guide me to the problem?