blenderproc.renderer package¶
Module contents¶
-
blenderproc.renderer.
enable_depth_output
(activate_antialiasing, output_dir=None, file_prefix='depth_', output_key='depth', antialiasing_distance_max=None, convert_to_distance=False)¶ 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
- activate_antialiasing (
-
blenderproc.renderer.
enable_diffuse_color_output
(output_dir=None, file_prefix='diffuse_', output_key='diffuse')¶ Enables writing diffuse color (albedo) images.
Diffuse color images will be written in the form of .png files during the next rendering.
Parameters:
-
blenderproc.renderer.
enable_distance_output
(activate_antialiasing, output_dir=None, file_prefix='distance_', output_key='distance', antialiasing_distance_max=None, convert_to_depth=False)¶ Enables writing distance images.
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 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
- activate_antialiasing (
-
blenderproc.renderer.
enable_motion_blur
(motion_blur_length=0.5, rolling_shutter_type='NONE', rolling_shutter_length=0.1)¶ Enables motion blur and sets rolling shutter.
Parameters:
-
blenderproc.renderer.
enable_normals_output
(output_dir=None, file_prefix='normals_', output_key='normals')¶ Enables writing normal images.
Normal images will be written in the form of .exr files during the next rendering.
Parameters:
-
blenderproc.renderer.
map_file_format_to_file_ending
(file_format)¶ 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.renderer.
render
(output_dir=None, file_prefix='rgb_', output_key='colors', load_keys=None, return_data=True, keys_with_alpha_channel=None)¶ 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. Backwards compatibility to config-based pipeline. - keys_with_alpha_channel (
Optional
[Set
[str
]]) – A set containing all keys whose alpha channels should be loaded.
Return type: Returns: dict of lists of raw renderer output. Keys can be ‘distance’, ‘colors’, ‘normals’
- output_dir (
-
blenderproc.renderer.
render_nocs
(output_dir=None, file_prefix='nocs_', output_key='nocs', return_data=True)¶ Renders the Normalized Object Coordinate Space (NOCS).
Colors each object based on its local coordinates. The coordinates [-1, 1] are mapped into the [0, 1] colorspace. It is therefore, recommended that all local vertex coordinates are in range [-1, 1]. The world background is rendered transparent.
Parameters: Return type: Returns: A dict containing one entry “nocs” which points to the list of rendered frames.
-
blenderproc.renderer.
render_optical_flow
(output_dir=None, temp_dir=None, get_forward_flow=True, get_backward_flow=True, blender_image_coordinate_style=False, forward_flow_output_file_prefix='forward_flow_', forward_flow_output_key='forward_flow', backward_flow_output_file_prefix='backward_flow_', backward_flow_output_key='backward_flow', return_data=True)¶ Renders the optical flow (forward and backward) for all frames.
Parameters: - output_dir (
Optional
[str
]) – The directory to write images to. - temp_dir (
Optional
[str
]) – The directory to write intermediate data to. - get_forward_flow (
bool
) – Whether to render forward optical flow. - get_backward_flow (
bool
) – Whether to render backward optical flow. - blender_image_coordinate_style (
bool
) – Whether to specify the image coordinate system at the bottom left (blender default; True) or top left (standard convention; False). - forward_flow_output_file_prefix (
str
) – The file prefix that should be used when writing forward flow to a file. - forward_flow_output_key (
str
) – The key which should be used for storing forward optical flow values. - backward_flow_output_file_prefix (
str
) – The file prefix that should be used when writing backward flow to a file. - backward_flow_output_key (
str
) – The key which should be used for storing backward optical flow values. - return_data (
bool
) – Whether to load and return generated data. Backwards compatibility to config-based pipeline.
Return type: Returns: dict of lists of raw renderer outputs. Keys can be ‘forward_flow’, ‘backward_flow’
- output_dir (
-
blenderproc.renderer.
render_segmap
(output_dir=None, temp_dir=None, map_by='class', default_values=None, file_prefix='segmap_', output_key='segmap', segcolormap_output_file_prefix='instance_attribute_map_', segcolormap_output_key='segcolormap', use_alpha_channel=False, render_colorspace_size_per_dimension=2048)¶ Renders segmentation maps for all frames
Parameters: - output_dir (
Optional
[str
]) – The directory to write images to. - temp_dir (
Optional
[str
]) – The directory to write intermediate data to. - map_by (
Union
[str
,List
[str
]]) – The attributes to be used for color mapping. - default_values (
Optional
[Dict
[str
,int
]]) – The default values used for the keys used in attributes, if None is {“class”: 0}. - file_prefix (
str
) – The prefix to use for writing the images. - output_key (
str
) – The key to use for registering the output. - segcolormap_output_file_prefix (
str
) – The prefix to use for writing the segmentation-color map csv. - segcolormap_output_key (
str
) – The key to use for registering the segmentation-color map output. - use_alpha_channel (
bool
) – If true, the alpha channel stored in .png textures is used. - render_colorspace_size_per_dimension (
int
) – As we use float16 for storing the rendering, the interval of integers which can be precisely stored is [-2048, 2048]. As blender does not allow negative values for colors, we use [0, 2048] ** 3 as our color space which allows ~8 billion different colors/objects. This should be enough.
Return type: Returns: dict of lists of segmaps and (for instance segmentation) segcolormaps
- output_dir (
-
blenderproc.renderer.
set_cpu_threads
(num_threads)¶ 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.renderer.
set_denoiser
(denoiser)¶ 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.renderer.
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)¶ 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.
- diffuse_bounces (
-
blenderproc.renderer.
set_max_amount_of_samples
(samples)¶ 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.renderer.
set_noise_threshold
(noise_threshold)¶ 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.renderer.
set_output_format
(file_format=None, color_depth=None, enable_transparency=None, jpg_quality=None)¶ 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”.
- file_format (
-
blenderproc.renderer.
set_simplify_subdivision_render
(simplify_subdivision_render)¶ 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.renderer.
set_world_background
(color, strength=1)¶ Sets the color of blenders world background
Parameters: