def scan_frame(world: HittableList, cam: Camera, image_width: int, image_height: int, max_depth: int) -> Vec3List: length = image_width * image_height i_list = cp.tile(cp.arange(image_width), image_height) j_list = cp.concatenate( cp.transpose(cp.tile(cp.arange(image_height), (image_width, 1)))) u: cp.ndarray = (random_float_list(length) + i_list) / (image_width - 1) v: cp.ndarray = (random_float_list(length) + j_list) / (image_height - 1) r: RayList = cam.get_ray(u, v) return ray_color_loop(r, world, max_depth)
def scan_line(j: int, background: Color, world: BVHNode, cam: Camera, image_width: int, image_height: int, samples_per_pixel: int, max_depth: int) -> Img: img = Img(image_width, 1) for i in range(image_width): pixel_color = Color(0, 0, 0) for s in range(samples_per_pixel): u: float = (i + random_float()) / (image_width - 1) v: float = (j + random_float()) / (image_height - 1) r: Ray = cam.get_ray(u, v) pixel_color += ray_color(r, background, world, max_depth) img.write_pixel(i, 0, pixel_color, samples_per_pixel) print(f"Scanlines remaining: {j} ", end="\r") return img
def scan_line(j: int, world: HittableList, cam: Camera, image_width: int, image_height: int, samples_per_pixel: int, max_depth: int) -> Img: img = Img(image_width, 1) row_pixel_color = Vec3List.from_vec3(Color(), image_width) for s in range(samples_per_pixel): u: np.ndarray = (random_float_list(image_width) + np.arange(image_width)) / (image_width - 1) v: np.ndarray = (random_float_list(image_width) + j) / (image_height - 1) r: RayList = cam.get_ray(u, v) row_pixel_color += ray_color(r, world, max_depth) img.write_pixel_list(0, row_pixel_color, samples_per_pixel) return img