예제 #1
0
def render_infinity_mirror(image_size=(128, 72), file_name='image.png'):
    scene = Scene()
    scene.max_recursion_level = 7
    scene.objects.append(Sphere((0, 0, 0), 0.25, PURPLE_GLOSSY))
    scene.objects.append(Circle((4, 0, 0), (-1, 0, 0), 2, MIRROR_GLOSSY))
    scene.objects.append(Circle((4.001, 0, 0), (-1, 0, 0), 2.1, GRAY_MATTE))
    scene.objects.append(Circle((-4, 0, 0), (1, -0.05, 0.1), 2, MIRROR_GLOSSY))
    scene.objects.append(Circle((-4.001, 0, 0), (1, -0.05, 0.1), 2.1, GRAY_MATTE))
    scene.objects.append(Plane(position=(0, -1, 0), material=YELLOW_MATTE))
    scene.lights.append(Point(position=(1, 5, 2), max_lighting_distance=128))
    scene.lights.append(Ambient())

    camera = Camera((3, 0.4, 0), (0, 0, 0))
    t_start = time.time()
    print("Start")
    camera.render_image(scene, image_size, file_name)
    print("Finished", time.time() - t_start)
예제 #2
0
def render_infinity_mirror(image_size=(128, 72), file_name='image.png'):
    scene = Scene()
    scene.max_recursion_level = 7
    scene.objects.append(Sphere((0, 0, 0), 0.25, PURPLE_GLOSSY))
    scene.objects.append(Circle((4, 0, 0), (-1, 0, 0), 2, MIRROR_GLOSSY))
    scene.objects.append(Circle((4.001, 0, 0), (-1, 0, 0), 2.1, GRAY_MATTE))
    scene.objects.append(Circle((-4, 0, 0), (1, -0.05, 0.1), 2, MIRROR_GLOSSY))
    scene.objects.append(
        Circle((-4.001, 0, 0), (1, -0.05, 0.1), 2.1, GRAY_MATTE))
    scene.objects.append(Plane(position=(0, -1, 0), material=YELLOW_MATTE))
    scene.lights.append(Point(position=(1, 5, 2), max_lighting_distance=128))
    scene.lights.append(Ambient())

    camera = Camera((3, 0.4, 0), (0, 0, 0))
    t_start = time.time()
    print("Start")
    camera.render_image(scene, image_size, file_name)
    print("Finished", time.time() - t_start)
예제 #3
0
파일: tests.py 프로젝트: pfertyk/ray_tracer
    def test_multiple_reflections(self):
        light1 = Point(position=(-5, 5, 5))
        light2 = Ambient()
        sphere1 = Sphere((-0.7, 0, 0.2), 1, MIRROR_GLOSSY)
        plane1 = Plane(position=(0, -2, 0), material=BLUE_GLOSSY)
        circle1 = Circle(center=(0.8, 0, -0.5), normal=(-1, 0, 1), radius=1.5, front_material=MIRROR_GLOSSY)

        scene = Scene()
        scene.background_color = (0, 0, 0)
        scene.objects.append(circle1)
        scene.objects.append(sphere1)
        scene.objects.append(plane1)
        scene.lights.append(light1)
        scene.lights.append(light2)

        camera = Camera((0, 3, 3), (0, 0, 0))
        rendered_image = camera.render_image(scene, (100, 100), file_name=None)
        self.compare_images(rendered_image, 'multiple_reflections.png')
예제 #4
0
파일: tests.py 프로젝트: pfertyk/ray_tracer
    def test_blue_light(self):
        scene = Scene()
        scene.objects.append(Sphere((0, 0, 0), 0.5, ORANGE_GLOSSY))
        scene.objects.append(Sphere((0.124, 0.484, 0), 0.3, BLUE_GLOSSY))
        scene.objects.append(Sphere((-0.5, 0, 0), 0.3, BLUE_GLOSSY))
        scene.objects.append(Plane(position=(0, -0.7, 0), material=GRAY_MATTE))
        scene.lights.append(Sun(color=(0, 0, 255)))

        camera = Camera((0, 0.4, 4), (0, 0, 0))
        rendered_image = camera.render_image(scene, file_name=None)
        self.compare_images(rendered_image, 'blue_light.png')
예제 #5
0
파일: tests.py 프로젝트: pfertyk/ray_tracer
    def test_multiple_reflections(self):
        light1 = Point(position=(-5, 5, 5))
        light2 = Ambient()
        sphere1 = Sphere((-0.7, 0, 0.2), 1, MIRROR_GLOSSY)
        plane1 = Plane(position=(0, -2, 0), material=BLUE_GLOSSY)
        circle1 = Circle(center=(0.8, 0, -0.5),
                         normal=(-1, 0, 1),
                         radius=1.5,
                         front_material=MIRROR_GLOSSY)

        scene = Scene()
        scene.background_color = (0, 0, 0)
        scene.objects.append(circle1)
        scene.objects.append(sphere1)
        scene.objects.append(plane1)
        scene.lights.append(light1)
        scene.lights.append(light2)

        camera = Camera((0, 3, 3), (0, 0, 0))
        rendered_image = camera.render_image(scene, (100, 100), file_name=None)
        self.compare_images(rendered_image, 'multiple_reflections.png')
예제 #6
0
파일: tests.py 프로젝트: pfertyk/ray_tracer
    def test_camera_angle_90(self):
        scene = Scene()
        scene.objects.append(Sphere((0, 0, 0), 0.5, ORANGE_GLOSSY))
        scene.objects.append(Sphere((0.124, 0.484, 0), 0.3, BLUE_GLOSSY))
        scene.objects.append(Sphere((-0.5, 0, 0), 0.3, BLUE_GLOSSY))
        scene.objects.append(Plane(position=(0, -0.7, 0), material=GRAY_MATTE))
        scene.lights.append(Sun())
        scene.lights.append(Ambient())

        camera = Camera((0, 0.4, 4), (0, 0, 0), horizontal_angle=90)
        rendered_image = camera.render_image(scene, file_name=None)
        self.compare_images(rendered_image, 'camera_angle_90.png')
예제 #7
0
파일: tests.py 프로젝트: pfertyk/ray_tracer
    def test_matte_no_ambient(self):
        light1 = Point(position=(-5, 5, 5))
        sphere1 = Sphere((0, 0, 0), 1, BLUE_MATTE)
        plane1 = Plane(position=(0, -2, 0), material=GRAY_MATTE)

        scene = Scene()
        scene.objects.append(sphere1)
        scene.objects.append(plane1)
        scene.lights.append(light1)

        camera = Camera((0, 3, 3), (0, 0, 0))
        rendered_image = camera.render_image(scene, (100, 100), file_name=None)
        self.compare_images(rendered_image, 'matte_no_ambient.png')
예제 #8
0
def render_reflecting_sphere(image_size=(128, 72), file_name='image.png'):
    scene = Scene()
    scene.objects.append(Sphere((0, 0, 0), 0.5, MIRROR_GLOSSY))
    scene.objects.append(Sphere((1, 0, 0), 0.3, GREEN_GLOSSY))
    scene.objects.append(Sphere((-1, 0, -0), 0.3, RED_GLOSSY))
    scene.objects.append(Plane(position=(0, -0.7, 0), material=GRAY_GLOSSY))
    scene.lights.append(Point(position=(2, 5, 2), max_lighting_distance=128))
    scene.lights.append(Ambient())

    camera = Camera((0, 0.6, 4), (0, 0, 0))
    t_start = time.time()
    print("Start")
    camera.render_image(scene, image_size, file_name)
    print("Finished", time.time() - t_start)
예제 #9
0
def render_water_molecule(image_size=(128, 72), file_name='image.png'):
    scene = Scene()
    scene.objects.append(Sphere((0, 0, 0), 0.5, ORANGE_GLOSSY))
    scene.objects.append(Sphere((0.124, 0.484, 0), 0.3, BLUE_GLOSSY))
    scene.objects.append(Sphere((-0.5, 0, 0), 0.3, BLUE_GLOSSY))
    scene.objects.append(Plane(position=(0, -0.7, 0), material=GRAY_MATTE))
    scene.lights.append(Sun())
    scene.lights.append(Ambient())

    camera = Camera((0, 0.4, 4), (0, 0, 0))
    t_start = time.time()
    print("Start")
    camera.render_image(scene, image_size, file_name)
    print("Finished", time.time() - t_start)
예제 #10
0
파일: tests.py 프로젝트: pfertyk/ray_tracer
    def test_lamp_specular(self):
        light1 = Point(position=(5, 5, 5))
        light2 = Ambient()
        sphere1 = Sphere((0, 0, 0), 1, BLUE_GLOSSY)
        plane1 = Plane(position=(0, -2, 0), material=GRAY_MATTE)

        scene = Scene()
        scene.objects.append(sphere1)
        scene.objects.append(plane1)
        scene.lights.append(light1)
        scene.lights.append(light2)

        camera = Camera((0, 3, 3), (0, 0, 0))
        rendered_image = camera.render_image(scene, (100, 100), file_name=None)
        self.compare_images(rendered_image, 'lamp_specular.png')
예제 #11
0
파일: tests.py 프로젝트: pfertyk/ray_tracer
    def test_sun_specular(self):
        light1 = Sun(direction=(0, -2, 0))
        light2 = Ambient()
        sphere1 = Sphere((0, 0, 0), 1, ORANGE_GLOSSY)
        plane1 = Plane(position=(0, -2, 0), material=BLUE_GLOSSY)

        scene = Scene()
        scene.objects.append(sphere1)
        scene.objects.append(plane1)
        scene.lights.append(light1)
        scene.lights.append(light2)

        camera = Camera((0, 3, 3), (0, 0, 0))
        rendered_image = camera.render_image(scene, (100, 100), file_name=None)
        self.compare_images(rendered_image, 'sun_specular.png')
예제 #12
0
파일: tests.py 프로젝트: pfertyk/ray_tracer
    def test_circle_front_back(self):
        light1 = Point(position=(5, 5, 5))
        light2 = Ambient()
        circle1 = Circle(center=(0, 0, 0.5),
                         front_material=GRAY_GLOSSY,
                         back_material=BLUE_GLOSSY)
        circle2 = Circle(center=(0, 1, -0.5),
                         normal=(0, -1, 0),
                         front_material=GRAY_GLOSSY,
                         back_material=BLUE_GLOSSY)
        plane1 = Plane(position=(0, -0.2, 0), material=ORANGE_MATTE)

        scene = Scene()
        scene.objects.append(circle1)
        scene.objects.append(circle2)
        scene.objects.append(plane1)
        scene.lights.append(light1)
        scene.lights.append(light2)

        camera = Camera((0, 3, 3), (0, 0, 0))
        rendered_image = camera.render_image(scene, (100, 100), file_name=None)
        self.compare_images(rendered_image, 'circle_front_back.png')