setPixel ( x, y )
      rayv = [0,0,0]; rayw = normalize([(x-W/2)/W , (H/2-y)/W , -3])
      [sphere,point] = shootRay(ray)
      return computeShade(ray,sphere,point,black)

   shootRay ( ray )
      t = HUGE
      for all spheres s
         ts = raySphereIntersect(v, w, s)
         if ts > 0 and ts < t
            t = ts
            sphere = s
      if sphere then point = rayv + t rayw
      return [sphere,point]

   computeShade ( ray, sphere, point, color )
      if sphere then
         normal = (point - spherecenter) / sphereradius
         color += phongShade(normal)
         rayv = point + ε normal; rayw = rayw - 2 (raywnormal) normal
         [ sphere , point ] = shootRay(ray)
         if sphere then
            color += computeShade(ray, sphere, point)
      return color

   raySphereIntersect ( ray, sphere )
      v = rayv - spherecenter; w = rayw
      double A =   ww
      double B = 2 vw
      double C =   vv - sphereradius2
      return if B2-4AC ≥ 0 then (-B - sqrt(B2-4AC)) / 2A else HUGE