def __init__(self, task):
        assert isinstance(task, RenderTask)

        self.task = task

        self.random = Random()
        self.raytracer = RayTracer(task.getScene())
        self.progress = 0.0
Exemple #2
0
    def __init__(self, task):
        if not isinstance(task, RenderTask):
            raise TypeError(
                "Incorrect task type: {}. Should be RenderTask".format(
                    type(task)))

        self.task = task

        self.random = Random()
        self.raytracer = RayTracer(task.getScene())
        self.progress = 0.0
Exemple #3
0
 def get_frame(self, scene, image):
     raytracer = RayTracer(scene)
     aspect = float(image.height) / float(image.width)
     for y in range(image.height):
         for x in range(image.width):
             x_coefficient = ((x + random()) * 2.0 / image.width) - 1.0
             y_coefficient = ((y + random()) * 2.0 / image.height) - 1.0
             offset = self.right * x_coefficient + self.up * (y_coefficient * aspect)
             sample_direction = (self.view_direction + (offset * tan(self.view_angle * 0.5))).unitize()
             radiance = raytracer.get_radiance(self.view_position, sample_direction)
             image.add_to_pixel(x, y, radiance)
Exemple #4
0
    def pixel_accumulated_radiance(self, scene, random, width, height, x, y,
                                   aspect, num_samples):
        raytracer = RayTracer(scene)
        acc_radiance = [0.0, 0.0, 0.0]

        for i in range(num_samples):
            x_coefficient = ((x + random.real64()) * 2.0 / width) - 1.0
            y_coefficient = ((y + random.real64()) * 2.0 / height) - 1.0

            offset = self.right * x_coefficient + self.up * (y_coefficient *
                                                             aspect)

            sample_direction = (
                self.view_direction +
                (offset * tan(self.view_angle * 0.5))).unitize()

            radiance = raytracer.get_radiance(self.view_position,
                                              sample_direction, random)

            acc_radiance[0] += radiance[0]
            acc_radiance[1] += radiance[1]
            acc_radiance[2] += radiance[2]

        return Vector3f(acc_radiance[0], acc_radiance[1], acc_radiance[2])
Exemple #5
0
 def __init__(self):
     self.film = Film()
     self.sampler = TileSampler()
     self.ray_tracer = RayTracer()
     self.camera = Camera()