コード例 #1
0
    def check_scene(self, max_iter=200):

        self.vessel.material = Lambert(blue)
        self.camera_outer.material = Lambert(yellow)
        self.camera_top.material = Lambert(yellow)
        self.source.material = Lambert(green)
        self.top_pinhole.material = Lambert(green)
        self.out_pinhole.material = Lambert(green)

        # cube walls
        bottom = Box(lower=Point3D(-0.99, -1.02, -0.99),
                     upper=Point3D(0.99, -1.01, 0.99),
                     parent=self.world,
                     material=Lambert(red))
        # top = Box(lower=Point3D(-0.99, 1.01, -0.99), upper=Point3D(0.99, 1.02, 0.99), parent=self.world,
        #           material=Lambert(red))
        left = Box(lower=Point3D(1.01, -0.99, -0.99),
                   upper=Point3D(1.02, 0.99, 0.99),
                   parent=self.world,
                   material=Lambert(yellow))
        # right = Box(lower=Point3D(-1.02, -0.99, -0.99), upper=Point3D(-1.01, 0.99, 0.99), parent=self.world,
        #             material=Lambert(purple))
        back = Box(lower=Point3D(-0.99, -0.99, 1.01),
                   upper=Point3D(0.99, 0.99, 1.02),
                   parent=self.world,
                   material=Lambert(orange))

        # various wall light sources
        light_front = Box(lower=Point3D(-1.5, -1.5, -10.1),
                          upper=Point3D(1.5, 1.5, -10),
                          parent=self.world,
                          material=UniformSurfaceEmitter(d65_white, 1.0))
        light_top = Box(lower=Point3D(-0.99, 1.01, -0.99),
                        upper=Point3D(0.99, 1.02, 0.99),
                        parent=self.world,
                        material=UniformSurfaceEmitter(d65_white, 1.0),
                        transform=translate(0, 1.0, 0))

        light_bottom = Box(lower=Point3D(-0.99, -3.02, -0.99),
                           upper=Point3D(0.99, -3.01, 0.99),
                           parent=self.world,
                           material=UniformSurfaceEmitter(d65_white, 1.0),
                           transform=translate(0, 1.0, 0))

        light_right = Box(lower=Point3D(-1.92, -0.99, -0.99),
                          upper=Point3D(-1.91, 0.99, 0.99),
                          parent=self.world,
                          material=UniformSurfaceEmitter(d65_white, 1.0))

        light_left = Box(lower=Point3D(1.91, -0.99, -0.99),
                         upper=Point3D(1.92, 0.99, 0.99),
                         parent=self.world,
                         material=UniformSurfaceEmitter(d65_white, 1.0))

        # Process the ray-traced spectra with the RGB pipeline.
        rgb = RGBPipeline2D()

        # camera
        pix = 1000
        camera = PinholeCamera(
            (pix, pix),
            pipelines=[rgb],
            transform=translate(-0.01, 0.0, -0.25) * rotate(0, 0, 0))
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(0.0, 0.0, 0.4) * rotate(180, 0, 0))
        # top view
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(0.0, self.vessel_out_rad+0.15, self.vessel_width/2)*rotate(0, -90, 0))
        # prof
        camera = PinholeCamera(
            (pix, pix),
            pipelines=[rgb],
            transform=translate(-0.13, 0.13, -0.2) * rotate(-25, -25.0, 0))

        # camera top side
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.x_shift_top, self.top_px_first_y+0.0004, self.top_px_z-self.cam_in_radius+0.005)*rotate(0, 0, 0))
        # camera top down-up
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.x_shift_top, self.top_px_first_y-0.01, self.vessel_width/2)*rotate(0, 90, 0))
        # camera top up-down
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.x_shift_top-0.004, self.top_px_first_y+self.lid_top+self.tube_height-0.01, self.vessel_width/2)*rotate(0, -90, 0))

        # camera out side
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(-self.vessel_out_rad-0.015, 0.000, self.vessel_width/2-self.cam_in_radius/2+0.0001))
        # camera out down-up
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(self.out_px_first_x+0.005+0.005, 0.0, self.vessel_width/2)*rotate(90, 0, 0))
        # camera out up-down
        # camera = PinholeCamera((pix, pix), pipelines=[rgb], transform=translate(-self.vessel_out_rad-self.tube_height-0.01, 0.0, self.vessel_width/2-0.005)*rotate(-90, 0, 0))

        # camera - pixel sampling settings
        camera.fov = 60  # 45
        camera.pixel_samples = 10

        # camera - ray sampling settings
        camera.spectral_rays = 1
        camera.spectral_bins = 25
        camera.parent = self.world

        plt.ion()
        p = 1
        while not camera.render_complete:
            print("Rendering pass {}...".format(p))
            camera.observe()
            print()
            p += 1
            if p > max_iter:
                break

        plt.ioff()
        rgb.display()
コード例 #2
0
ファイル: add.py プロジェクト: raysect/source
world = World()

angle_increments = np.array([-4, -3, -2, -1, 0, 1, 2, 3, 4])
temperature_scan = np.linspace(0, 2000, 9) + 273.15

# metal spheres
angle = 6
distance = 3.6
radius = 0.15

for i in range(9):
    temperature = temperature_scan[i]
    increment = angle_increments[i]

    material = Add(RoughIron(0.05),
                   UniformSurfaceEmitter(BlackBody(temperature)),
                   surface_only=True)

    Sphere(radius,
           world,
           transform=rotate(increment * angle, 0, 0) *
           translate(0, radius + 0.00001, distance),
           material=material)

# glass spheres
angle = 6
distance = 3
radius = 0.15

for i in range(9):
    temperature = temperature_scan[i]
コード例 #3
0
           transform=rotate(increment * angle, 0, 0) *
           translate(0, radius + 0.00001, distance),
           material=Lambert(colours[i]))

# diffuse ground plane
Box(Point3D(-100, -0.1, -100),
    Point3D(100, 0, 100),
    world,
    material=Lambert(ConstantSF(1 / 1000)))

# four strip lights
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 8) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 6) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 4) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))
Cylinder(0.5,
         1.0,
         world,
         transform=translate(0.5, 5, 2) * rotate(90, 0, 0),
         material=UniformSurfaceEmitter(d65_white, 1.0))
コード例 #4
0
e_left = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
             parent=enclosure,
             transform=translate(1, 0, 0) * rotate(-90, 0, 0),
             material=Lambert(red_reflectivity))

e_right = Box(Point3D(-1, -1, 0), Point3D(1, 1, 0),
              parent=enclosure,
              transform=translate(-1, 0, 0) * rotate(90, 0, 0),
              material=Lambert(green_reflectivity))

# ceiling light
light = Box(Point3D(-0.4, -0.4, -0.01), Point3D(0.4, 0.4, 0.0),
            parent=enclosure,
            transform=translate(0, 1, 0) * rotate(0, 90, 0),
            material=UniformSurfaceEmitter(light_spectrum, 2))

# light = Box(Point3D(-0.4, -0.4, -0.01), Point3D(0.4, 0.4, 0.0),
#             parent=enclosure,
#             transform=translate(0, 1, 0) * rotate(0, 90, 0),
#             material=UniformSurfaceEmitter(d65_white, 2))

# back_light = Sphere(0.1,
#     parent=enclosure,
#     transform=translate(0.80, -0.85, 0.80)*rotate(0, 0, 0),
#     material=UniformSurfaceEmitter(light_spectrum, 10.0))

# objects in enclosure
box = Box(Point3D(-0.4, 0, -0.4), Point3D(0.3, 1.4, 0.3),
          parent=world,
          transform=translate(0.4, -1 + 1e-6, 0.4)*rotate(30, 0, 0),
コード例 #5
0
Box(Point3D(-100, -0.1, -100),
    Point3D(100, 0, 100),
    world,
    material=RoughTitanium(0.1))

# front light
Sphere(5,
       world,
       transform=translate(1, 8, -10),
       material=UniformVolumeEmitter(d65_white, 1.0))

# fill light
Sphere(10,
       world,
       transform=translate(7, 20, 20),
       material=UniformSurfaceEmitter(d65_white, 0.15))

# camera
rgb = RGBPipeline2D(display_update_time=15, display_unsaturated_fraction=0.995)
sampler = RGBAdaptiveSampler2D(rgb,
                               min_samples=1000,
                               fraction=0.1,
                               cutoff=0.01)
camera = PinholeCamera((1024, 1024),
                       parent=world,
                       transform=translate(0, 4, -3.5) * rotate(0, -46, 0),
                       pipelines=[rgb],
                       frame_sampler=sampler)
camera.spectral_bins = 21
camera.spectral_rays = 21
camera.pixel_samples = 250
コード例 #6
0
ファイル: colours_emissive.py プロジェクト: raysect/source
colours = [
    yellow, orange, red_orange, red, purple, blue, light_blue, cyan, green
]

# coloured metal spheres
angle = 6
radius = 0.12
distance = 3.2

for i in range(9):
    increment = angle_increments[i]
    Sphere(radius,
           world,
           transform=rotate(increment * angle, 0, 0) *
           translate(0, radius + 0.00001, distance),
           material=UniformSurfaceEmitter(colours[i]))

# diffuse ground plane
Box(Point3D(-100, -0.1, -100),
    Point3D(100, 0, 100),
    world,
    material=Lambert(ConstantSF(0.5)))

rgb = RGBPipeline2D(name="sRGB")
sampler = RGBAdaptiveSampler2D(rgb,
                               ratio=10,
                               fraction=0.2,
                               min_samples=500,
                               cutoff=0.05)

# observer
コード例 #7
0
    def emission_function(self, spectrum, cosine, back_face):

        spectrum.samples[:] = 1.0
        spectrum.samples[spectrum.wavelengths > 500] = 2 * cosine
        return spectrum


# 1. Create Primitives
# --------------------

# Box defining the floor
ground = Box(lower=Point3D(-100, -14.2, -100), upper=Point3D(100, -14.1, 100), material=RoughAluminium(0.05))

# Box defining the isotropic emitter
emitterIsotropic = Box(lower=Point3D(-25, -10, -10), upper=Point3D(-5, 10, 10),
              material=UniformSurfaceEmitter(d65_white), transform=rotate(0, 0, 0))
# Box defining the anisotropic emitter
emitterAnisotropic = Box(lower=Point3D(5, -10, -10), upper=Point3D(25, 10, 10),
              material=BlueYellowEmitter(), transform=rotate(0, 0, 0))


# 2. Add Observer
# ---------------

# camera
camera = PinholeCamera((384, 384), transform=translate(0, 0, -80))
camera.fov = 45
camera.pixel_samples = 250
camera.pipelines[0].accumulate = False