blendersynth.blender.compositor.compositor
- blendersynth.blender.compositor.compositor.AVAILABLE_FORMATS = ['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'TARGA_RAW', 'CINEON', 'DPX', 'OPEN_EXR_MULTILAYER', 'OPEN_EXR', 'HDR', 'TIFF']
List of available output file formats
- class blendersynth.blender.compositor.compositor.Compositor(view_layer='ViewLayer', background_color=None, rgb_color_space=None)[source]
Compositor output - for handling file outputs, and managing Compositor node tree
- __init__(view_layer='ViewLayer', background_color=None, rgb_color_space=None)[source]
- Parameters:
view_layer – Name of View Layer to render
background_color (
tuple
) – If given, RGB[A] tuple in range [0-1], will overwrite World background with solid color (while retaining lighting effects).rgb_color_space (
str
) – Color transform for RGB only. Defaults to AgX Base sRGB for Blender 4+, and Filmic sRGB for older versions.
- define_output(input_data, name=None, is_data=False, file_format='PNG', color_mode='RGBA', jpeg_quality=90, png_compression=15, color_depth='8', EXR_color_depth='32')[source]
Add a connection between a valid render output, and a file output node.
This should only be called once per output (NOT inside a loop). Inside the loop, only call
update_filename
,update_all_filenames
update_directory
All outputs will be defined in raw color space (no color correction), except for the RGB output, and any overlays on this output (e.g. Bounding Box Visualization)
- Parameters:
input_data (
Union
[str
,CompositorNodeGroup
,AOV
]) – Ifstr
, will get the input_data from that key in the render_layers_node. IfCompositorNodeGroup
, use that node as input. IfAOV
, use that AOV as input (storing AOV).name (
str
) – Target name of output. If not given, will infer from input_data.is_data (
bool
) – If True, save with no color correction. If False, save with color correction.file_format (
str
) – File format to save output as. Must be inAVAILABLE_FORMATS
color_mode (
str
) – Color mode to save output as.jpeg_quality (
int
) – Quality of JPEG output.png_compression (
int
) – Compression of PNG output.color_depth (
str
) – Color depth of output.EXR_color_depth (
str
) – Color depth of EXR output.
- Return type:
str
- Returns:
Name of output.
- get_axes_visual(size=1, thickness=2)[source]
Return an axes visual overlay.
- Parameters:
size (
int
) – Size of axes. Default 100thickness (
int
) – Thickness of axes. Default 2
- Return type:
- get_bounding_box_visual(col=(0.0, 0.0, 255.0, 255.0), thickness=5)[source]
Return a bounding box visual overlay.
- Parameters:
col – (3,) or (N, 3) Color(s) of bounding box(es) [in BGR]
thickness (
int
) – (,) or (N,) Thickness(es) of bounding box(es)
- Return type:
- get_depth_visual(max_depth=1, col=(255, 255, 255))[source]
Get depth visual, which normalizes depth values so max_depth = col, and any values below that are depth/max_depth * col.
- Parameters:
max_depth – Maximum depth value to normalize to
col (
tuple
) – Color of maximum depth value. 0-255 RGB or RGBA.
- Return type:
- get_keypoints_visual(marker='x', color=(0, 0, 255), size=5, thickness=2)[source]
Return a keypoints visual overlay.
- Parameters:
marker (
str
) – Marker type, either [c/circle], [s/square], [t/triangle] or [x]. Default ‘x’size (
int
) – Size of marker. Default 5color (
tuple
) – Color of marker, RGB or RGBA, default (0, 0, 255) (red)thickness (
int
) – Thickness of marker. Default 2
- Return type:
- get_mask(index, input_rgb, anti_aliasing=False)[source]
Get mask node from pass index. If not found, create new mask node
- Return type:
- property keys: List[str]
List of output keys.
- render(camera=None, scene=None, annotations=None, animation=False, frame_start=0, frame_end=250)[source]
Render the scene.
- Parameters:
camera (
Union
[Camera
,List
[Camera
]]) – Camera(s) to render from. If None, will use scene.camera. If multiple, will render each camera separately, appending the camera’s names as the output file names.scene (
Scene
) – Scene to render. If None, will use bpy.context.scene.annotations (
AnnotationHandler
) – Object containing annotation information for each camera view to be used for overlaysanimation (
bool
) – If True, will render an animation, using frame_start and frame_end as the start and end frames.frame_start (
int
) – Start frame for animation.frame_end (
int
) – End frame for animation.
- Return type:
- Returns:
RenderResult
object containing paths to rendered files.