blenderproc.python.renderer.RendererUtility module

Provides functionality to render a color, normal, depth and distance image.

blenderproc.python.renderer.RendererUtility._progress_bar_thread(pipe_out, stdout, total_frames, num_samples)[source]

The thread rendering the progress bar

Parameters:
  • pipe_out (int) – The pipe output delivering blenders debug messages.

  • stdout (IO) – The stdout to which the progress bar should be written.

  • total_frames (int) – The number of frames that should be rendered.

  • num_samples (int) – The number of samples used to render each frame.

blenderproc.python.renderer.RendererUtility._render_progress_bar(pipe_out, pipe_in, stdout, total_frames, enabled=True)[source]

Shows a progress bar visualizing the render progress.

Parameters:
  • pipe_out (int) – The pipe output delivering blenders debug messages.

  • pipe_in (int) – The input of the pipe, necessary to send the end character.

  • stdout (IO) – The stdout to which the progress bar should be written.

  • total_frames (int) – The number of frames that should be rendered.

  • enabled (bool) – If False, no progress bar is shown.

blenderproc.python.renderer.RendererUtility.disable_all_denoiser()[source]

Disables all denoiser.

At the moment this includes the cycles and the intel denoiser.

blenderproc.python.renderer.RendererUtility.enable_depth_output(activate_antialiasing, output_dir=None, file_prefix='depth_', output_key='depth', antialiasing_distance_max=None, convert_to_distance=False)[source]

Enables writing depth images.

Depth images will be written in the form of .exr files during the next rendering.

Parameters:
  • activate_antialiasing (bool) – If this is True the final image will be antialiased

  • output_dir (Optional[str]) – The directory to write files to, if this is None the temporary directory is used.

  • file_prefix (str) – The prefix to use for writing the files.

  • output_key (str) – The key to use for registering the depth output.

  • antialiasing_distance_max (Optional[float]) – Max distance in which the distance is measured. Only if activate_antialiasing is True.

  • convert_to_distance (bool) – If this is true, while loading a postprocessing step is executed to convert this depth image to a distance image

blenderproc.python.renderer.RendererUtility.enable_diffuse_color_output(output_dir=None, file_prefix='diffuse_', output_key='diffuse')[source]

Enables writing diffuse color (albedo) images.

Diffuse color images will be written in the form of .png files during the next rendering.

Parameters:
  • output_dir (Optional[str]) – The directory to write files to, if this is None the temporary directory is used.

  • file_prefix (str) – The prefix to use for writing the files.

  • output_key (str) – The key to use for registering the diffuse color output.

blenderproc.python.renderer.RendererUtility.enable_distance_output(activate_antialiasing, output_dir=None, file_prefix='distance_', output_key='distance', antialiasing_distance_max=None, convert_to_depth=False)[source]

Enables writing distance images.

Parameters:
  • activate_antialiasing (bool) – If this is True the final image will be anti-aliased

  • output_dir (Optional[str]) – The directory to write files to, if this is None the temporary directory is used.

  • file_prefix (str) – The prefix to use for writing the files.

  • output_key (str) – The key to use for registering the distance output.

  • antialiasing_distance_max (Optional[float]) – Max distance in which the distance is measured. Resolution decreases antiproportionally. Only if activate_antialiasing is True.

  • convert_to_depth (bool) – If this is true, while loading a postprocessing step is executed to convert this distance image to a depth image

blenderproc.python.renderer.RendererUtility.enable_experimental_features()[source]

Enables experimental cycles features.

blenderproc.python.renderer.RendererUtility.enable_motion_blur(motion_blur_length=0.5, rolling_shutter_type='NONE', rolling_shutter_length=0.1)[source]

Enables motion blur and sets rolling shutter.

Parameters:
  • motion_blur_length (float) – Time taken in frames between shutter open and close.

  • rolling_shutter_type (str) – Type of rolling shutter effect. If “NONE”, rolling shutter is disabled.

  • rolling_shutter_length (float) – Scanline “exposure” time for the rolling shutter effect.

blenderproc.python.renderer.RendererUtility.enable_normals_output(output_dir=None, file_prefix='normals_', output_key='normals')[source]

Enables writing normal images.

Normal images will be written in the form of .exr files during the next rendering.

Parameters:
  • output_dir (Optional[str]) – The directory to write files to, if this is None the temporary directory is used.

  • file_prefix (str) – The prefix to use for writing the files.

  • output_key (str) – The key to use for registering the normal output.

blenderproc.python.renderer.RendererUtility.enable_segmentation_output(map_by='category_id', default_values=None, pass_alpha_threshold=0.05, output_dir=None, file_prefix='segmap_', output_key='segmap')[source]

Enables segmentation output by certain keys.

The key instances is used, if a mapping of every object in the scene to an integer is requested. These integers are assigned randomly and do not follow any system. They are consisted for one rendering call.

By default, the custom property category_id is used. It has to be set for every visible object in the scene, including the background (world). One can provide a default_value for it to avoid errors: {“category_id”: 0}.

Map by keys can be all custom properties or the attributes of an object such as location or name. If the value can not be stored in the image itself an instance image has to be generated. The output then will contain a dictionary mapping the instance ids to the attributes of the objects.

Parameters:
  • map_by (Union[str, List[str]]) – Map by keys, either a single str or a list of str.

  • default_values (Optional[Dict[str, Any]]) – A dictionary offering a default value for objects which do not provide a value for a certain key

  • pass_alpha_threshold (float) – This alpha threshold is used to decide which object to use a low value means that an object has to be nearly completely transparent to be considered transparent, while materials such as frosted class with an alpha value of 0.5 would be considered opaque

  • output_dir (Optional[str]) – The temporary output dir in which the resulting .exr images are saved

  • file_prefix (str) – The prefix to use for writing the files.

  • output_key (str) – The key to use for registering the segmentation output.

blenderproc.python.renderer.RendererUtility.map_file_format_to_file_ending(file_format)[source]

Returns the files endings for a given blender output format.

Parameters:

file_format (str) – The blender file format.

Return type:

str

Returns:

The file ending.

blenderproc.python.renderer.RendererUtility.render(output_dir=None, file_prefix='rgb_', output_key='colors', load_keys=None, return_data=True, keys_with_alpha_channel=None, verbose=False)[source]

Render all frames.

This will go through all frames from scene.frame_start to scene.frame_end and render each of them.

Parameters:
  • output_dir (Optional[str]) – The directory to write files to, if this is None the temporary directory is used. The temporary directory is usually in the shared memory (only true for linux).

  • file_prefix (str) – The prefix to use for writing the images.

  • output_key (Optional[str]) – The key to use for registering the output.

  • load_keys (Optional[Set[str]]) – Set of output keys to load when available

  • return_data (bool) – Whether to load and return generated data.

  • keys_with_alpha_channel (Optional[Set[str]]) – A set containing all keys whose alpha channels should be loaded.

  • verbose (bool) – If True, more details about the rendering process are printed.

Return type:

Dict[str, Union[ndarray, List[ndarray]]]

Returns:

dict of lists of raw renderer output. Keys can be ‘distance’, ‘colors’, ‘normals’

blenderproc.python.renderer.RendererUtility.render_init()[source]

Initializes the renderer.

This enables the cycles renderer and sets some options to speedup rendering.

blenderproc.python.renderer.RendererUtility.set_cpu_threads(num_threads)[source]

Sets the number of CPU cores to use simultaneously while rendering.

Parameters:

num_threads (int) – The number of threads to use. If 0 is given the number is automatically detected based on the cpu cores.

blenderproc.python.renderer.RendererUtility.set_denoiser(denoiser)[source]

Enables the specified denoiser.

Automatically disables all previously activated denoiser.

Parameters:

denoiser (Optional[str]) – The name of the denoiser which should be enabled. Options are “INTEL”, “OPTIX” and None. If None is given, then no denoiser will be active.

blenderproc.python.renderer.RendererUtility.set_light_bounces(diffuse_bounces=None, glossy_bounces=None, ao_bounces_render=None, max_bounces=None, transmission_bounces=None, transparent_max_bounces=None, volume_bounces=None)[source]

Sets the number of light bounces that should be used by the raytracing renderer. Default values are defined in DefaultConfig.py

Parameters:
  • diffuse_bounces (Optional[int]) – Maximum number of diffuse reflection bounces, bounded by total maximum.

  • glossy_bounces (Optional[int]) – Maximum number of glossy reflection bounces, bounded by total maximum.

  • ao_bounces_render (Optional[int]) – Approximate indirect light with background tinted ambient occlusion at the specified bounce, 0 disables this feature.

  • max_bounces (Optional[int]) – Total maximum number of bounces.

  • transmission_bounces (Optional[int]) – Maximum number of transmission bounces, bounded by total maximum.

  • transparent_max_bounces (Optional[int]) – Maximum number of transparent bounces.

  • volume_bounces (Optional[int]) – Maximum number of volumetric scattering events.

blenderproc.python.renderer.RendererUtility.set_max_amount_of_samples(samples)[source]

Sets the maximum number of samples to render for each pixel. This maximum amount is usually not reached if the noise threshold is low enough. If the noise threshold was set to 0, then only the maximum number of samples is used (We do not recommend this).

Parameters:

samples (int) – The maximum number of samples per pixel

blenderproc.python.renderer.RendererUtility.set_noise_threshold(noise_threshold)[source]

Configures the adaptive sampling, the noise threshold is typically between 0.1 and 0.001. Adaptive sampling automatically decreases the number of samples per pixel based on estimated level of noise.

We do not recommend setting the noise threshold value to zero and therefore turning off the adaptive sampling.

For more information see the official documentation: https://docs.blender.org/manual/en/latest/render/cycles/render_settings/sampling.html#adaptive-sampling

Parameters:

noise_threshold (float) – Noise level to stop sampling at. If 0 is given, adaptive sampling is disabled and only the max amount of samples is used.

blenderproc.python.renderer.RendererUtility.set_output_format(file_format=None, color_depth=None, enable_transparency=None, jpg_quality=None)[source]

Sets the output format to use for rendering. Default values defined in DefaultConfig.py.

Parameters:
  • file_format (Optional[str]) – The file format to use, e.q. “PNG”, “JPEG” or “OPEN_EXR”.

  • color_depth (Optional[int]) – The color depth.

  • enable_transparency (Optional[bool]) – If true, the output will contain a alpha channel and the background will be set transparent.

  • jpg_quality (Optional[int]) – The quality to use, if file format is set to “JPEG”.

blenderproc.python.renderer.RendererUtility.set_render_devices(use_only_cpu=False, desired_gpu_device_type=None, desired_gpu_ids=None)[source]

Configures the devices to use for rendering.

Parameters:
  • use_only_cpu (bool) – If True, only the cpu is used for rendering.

  • desired_gpu_device_type (Union[str, List[str], None]) – One or multiple GPU device types to consider. If multiple are given, the first available is used. Possible choices are [“OPTIX”, “CUDA”, “METAL”, “HIP”]. Default is [“OPTIX”, “CUDA”, “HIP”] on linux/windows and [“METAL”] on supported Mac devices.

  • desired_gpu_ids (Union[int, List[int], None]) – One or multiple GPU ids to specifically use. If none is given, all suitable GPUs are used.

blenderproc.python.renderer.RendererUtility.set_simplify_subdivision_render(simplify_subdivision_render)[source]

Sets global maximum subdivision level during rendering to speedup rendering.

Parameters:

simplify_subdivision_render (int) – The maximum subdivision level. If 0 is given, simplification of scene is disabled.

blenderproc.python.renderer.RendererUtility.set_world_background(color, strength=1)[source]

Sets the color of blenders world background

Parameters:
  • color (List[float]) – A three-dimensional list specifying the new color in floats.

  • strength (float) – The strength of the emitted background light.

blenderproc.python.renderer.RendererUtility.toggle_light_tree(enable)[source]

Enables/Disables blender’s light tree for rendering.

Enabling the light tree reduces the noise in scenes with many point lights, however it increases the render time per sample. See https://wiki.blender.org/wiki/Reference/Release_Notes/3.5/Cycles

Parameters:

enable (bool) – True, if light tree should be enabled.

blenderproc.python.renderer.RendererUtility.toggle_stereo(enable)[source]

Enables/Disables stereoscopy.

Parameters:

enable (bool) – True, if stereoscopy should be enabled.