                              (windowSize.y / 2));
 
     // Initialize view
-    vec3 eye = vec3(0, 0, 49.9);
+    vec3 eye = vec3(0.0, 0.0, 49.9);
 	//    vec3 target = vec3(position.x, position.y + 1, 0);
     Ray initialRay = Ray(eye, normalize(vec3(position.xy, -1)));
 

		PendingRay r = pendingRays[--numPendingRays];
		
        Intersection s = sphereIntersect(r.ray);
        if(s.object == -1) break;

		float reflect_weight, refract_weight;
        vec3 point = r.ray.origin + r.ray.direction * s.distance;
        vec3 shadedColor =
            shade(spheres[s.object].shader, spheres[s.object].color, point,
                  s.normal, reflect_weight, refract_weight);

		if(reflect_weight > 0 && r.depth < 4){
			vec3 rr = reflect(r.ray.direction, s.normal);
            pendingRays[numPendingRays++] = PendingRay(
                Ray(point, rr), reflect_weight * r.weight, r.depth + 1);
        }
		if(refract_weight > 0 && r.depth < 4){
			vec3 rr = refract(r.ray.direction, s.normal, 1.0 / 1.5);
            pendingRays[numPendingRays++] = PendingRay(
                Ray(point, rr), refract_weight * r.weight, r.depth + 1);
        }
		
        color.rgb += r.weight * shadedColor;
    }

    // Average color with past samples from the same pixel

    }
    return ret;
}
// vec3 shade(int shader, vec3 color, vec3 point, vec3 normal,
//            out float reflect_weight, out float refract_weight) {
//     if(shader == DIFFUSE_SHADER) {
//         vec3 diffuseColor = vec3(0);
//         for(int i = 0; i < numLights; i++) {
// 			vec3 d = randomDirection();
//             d *= -sign(dot(d, lights[i].position - point));

//             vec3 target = lights[i].position + lights[i].radius * d;
//             vec3 lightOffset = target - point;
//             vec3 lightDirection = normalize(lightOffset);
//             Ray shadowRay = Ray(point + 0.01 * lightDirection, lightDirection);
//             Intersection shadow = sphereIntersect(shadowRay);

//             if(shadow.object == -1 ||
//                shadow.distance * shadow.distance >
//                    dot(lightOffset, lightOffset)) {
//                 diffuseColor += color * dot(normal, lightDirection);
//             }
//         }

// 		reflect_weight = 0;
// 		refract_weight = 0;
//         return mix(diffuseColor, color, 0.4);
//     } else if(shader == MIRROR_SHADER) {
// 		reflect_weight = 1;
// 		refract_weight = 0;
// 		return vec3(0);
// 	}
// }

void main() {
	// Left
    spheres[0] = Sphere(1e3, vec3(-1e3 - 50, 0,0), vec3(0),
                        vec3(.75, .25, .25), DIFFUSE_SHADER);

	//Rght
    spheres[1] = Sphere(1e3, vec3(1e3 + 50, 0, 0), vec3(0),
                        vec3(.25, .25, .75), DIFFUSE_SHADER);

	// Back
	spheres[2] = Sphere(1e3, vec3(0, 0, -1e3 - 75), vec3(0), vec3(.75, .75, .75),
                        DIFFUSE_SHADER);

	// Front
    spheres[3] = Sphere(1e3, vec3(0, 0, 1e3 + 50), vec3(0), vec3(0),
                       DIFFUSE_SHADER);

	// Bottom
    spheres[4] = Sphere(1e3, vec3(0, -1e3 - 50, 0), vec3(0),
                        vec3(.75, .75, .75), DIFFUSE_SHADER);

    // Top
    spheres[5] = Sphere(1e3, vec3(0, 1e3 + 50, 0), vec3(0),
                        vec3(.75, .75, .75), DIFFUSE_SHADER);

    // Diffuse
    spheres[6] = Sphere(10.5, vec3(0, -12, -25), vec3(0), vec3(1, 0, 1) * .999,
                        DIFFUSE_SHADER);

    // Mirror
    spheres[7] = Sphere(16.5, vec3(33, 16.5, -38), vec3(0), vec3(0.999),
                        MIRROR_SHADER);

	// Light
	spheres[8] = Sphere(50, vec3(0, 95, -30), vec3(10), vec3(0),
                        MIRROR_SHADER);

	// lights[0].radius = 5;
    // lights[0].position = vec3(0, 44.9, -30);
    // lights[0].color = vec3(10);

    vec2 position = vec2((gl_FragCoord.x - windowSize.x / 2 + random() - 0.5) /
                             (windowSize.y / 2),
