 float generatDistanceFields(vec3 pos){
     float d = 0.;
  	d= smin(
-        sphere(pos+vec3(0.154,0.415,0.371), 0.160),
+        sphere(pos+vec3(-1.,0.415,-0.271), 0.968),
         sphere(pos+vec3(0.405,0.195,0.250), 0.380)  //length(p) - 0.5; // Distance to sphere of radius 0.5
     ,0.1);
-    d = max(d, sdBox(pos+vec3(0.044,0.570,0.001),vec3(0.433,1.000,-.0)));
-    d = min(d, sdCylinder(pos+vec3(0.1), vec3(0.074,0.180,0.235)));
+    d = min(d, sdBox(pos+vec3(0.044,0.570,0.001),vec3(1.033,1.460,0.000)));
+    //d = min(d, sdCylinder(pos+vec3(0.1), vec3(0.074,0.180,0.235)));
+
+    float d0 = sphere( pos, 2.4 );
+
     return d;
 }
 

    return far;
}



//color gradient between blue and red based on iteration

    return vec3(1.);
}


//TODO: try and understand this
vec3 gradient( vec3 pos ) {
    const float grad_step = 0.2;
	const vec3 dx = vec3( grad_step, 0.0, 0.0 );
	const vec3 dy = vec3( 0.0, grad_step, 0.0 );
	const vec3 dz = vec3( 0.0, 0.0, grad_step );
	return normalize (
		vec3(
			generatDistanceFields( pos + dx ) - generatDistanceFields( pos - dx ),
			generatDistanceFields( pos + dy ) - generatDistanceFields( pos - dy ),
			generatDistanceFields( pos + dz ) - generatDistanceFields( pos - dz )
		)
	);
}

void main()
{
    vec3 eye =  vec3(0.,0.,10.0);//vec3(cos(u_time*2.),sin(u_time*2.),-10);
    float near = 0.0;
    float far = 1000.0;
    vec4 background = vec4(0.940,0.714,0.266,1.0); // background color


    vec3 rayDirection = rayDir(25., u_resolution.xy, gl_FragCoord.xy );

	float depth = rayMarch(eye, rayDirection, near, far);

    vec3 pos = eye + rayDirection * depth;//*10.+cos(u_time/2.);//;
    vec3 norm =  gradient(pos);//lightShade(eye, pos);



    //gl_FragColor = vec4(vec3(depth),1.)+background; //only works if we return 0. instead of far from rayMarch
    gl_FragColor = vec4(norm, 1.)+background;

}
