def set_default_parameters(): """ Loads and sets default parameters defined in DefaultConfig.py """ # Set default intrinsics CameraUtility.set_intrinsics_from_blender_params( DefaultConfig.fov, DefaultConfig.resolution_x, DefaultConfig.resolution_y, DefaultConfig.clip_start, DefaultConfig.clip_end, DefaultConfig.pixel_aspect_x, DefaultConfig.pixel_aspect_y, DefaultConfig.shift_x, DefaultConfig.shift_y, "FOV") CameraUtility.set_stereo_parameters( DefaultConfig.stereo_convergence_mode, DefaultConfig.stereo_convergence_distance, DefaultConfig.stereo_interocular_distance) # Init renderer RendererUtility.init() RendererUtility.set_samples(DefaultConfig.samples) addon_utils.enable("render_auto_tile_size") RendererUtility.toggle_auto_tile_size(True) # Set number of cpu cores used for rendering (1 thread is always used for coordination => 1 # cpu thread means GPU-only rendering) RendererUtility.set_cpu_threads(1) RendererUtility.set_denoiser(DefaultConfig.denoiser) RendererUtility.set_simplify_subdivision_render( DefaultConfig.simplify_subdivision_render) RendererUtility.set_light_bounces( DefaultConfig.diffuse_bounces, DefaultConfig.glossy_bounces, DefaultConfig.ao_bounces_render, DefaultConfig.max_bounces, DefaultConfig.transmission_bounces, DefaultConfig.transparency_bounces, DefaultConfig.volume_bounces)
def _configure_renderer(self, default_samples=256, use_denoiser=False, default_denoiser="Intel"): """ Sets many different render parameters which can be adjusted via the config. :param default_samples: Default number of samples to render for each pixel :param use_denoiser: If true, a denoiser is used, only use this on color information :param default_denoiser: Either "Intel" or "Blender", "Intel" performs much better in most cases """ RendererUtility.init() RendererUtility.set_samples( self.config.get_int("samples", default_samples)) if self.config.has_param("use_adaptive_sampling"): RendererUtility.set_adaptive_sampling( self.config.get_float("use_adaptive_sampling")) if self.config.get_bool("auto_tile_size", True): RendererUtility.toggle_auto_tile_size(True) else: RendererUtility.toggle_auto_tile_size(False) RendererUtility.set_tile_size(self.config.get_int("tile_x"), self.config.get_int("tile_y")) # Set number of cpu cores used for rendering (1 thread is always used for coordination => 1 # cpu thread means GPU-only rendering) RendererUtility.set_cpu_threads(self.config.get_int("cpu_threads", 1)) print('Resolution: {}, {}'.format( bpy.context.scene.render.resolution_x, bpy.context.scene.render.resolution_y)) RendererUtility.set_denoiser(None if not use_denoiser else self.config. get_string("denoiser", default_denoiser)) RendererUtility.set_simplify_subdivision_render( self.config.get_int("simplify_subdivision_render", 3)) RendererUtility.set_light_bounces( self.config.get_int("diffuse_bounces", 3), self.config.get_int("glossy_bounces", 0), self.config.get_int("ao_bounces_render", 3), self.config.get_int("max_bounces", 3), self.config.get_int("transmission_bounces", 0), self.config.get_int("transparency_bounces", 8), self.config.get_int("volume_bounces", 0)) RendererUtility.toggle_stereo(self.config.get_bool("stereo", False)) self._use_alpha_channel = self.config.get_bool('use_alpha', False)