# camera - ray sampling settings camera.spectral_rays = 1 camera.spectral_bins = 20 camera.ray_max_depth = 100 camera.ray_extinction_prob = 0.1 camera.min_wavelength = 375.0 camera.max_wavelength = 740.0 # 3. Build Scenegraph # ------------------- world = World() sphere.parent = world ground.parent = world emitter.parent = world camera.parent = world # 4. Observe() # ------------ plt.ion() camera.observe() plt.ioff() rgb.save("render.png") rgb.display() plt.show()
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()