ddg.blender.render module

class ddg.blender.render.ImageFormatExtension(value)[source]

Bases: Enum

An enumeration.

BMP = '.bmp'
PNG = '.png'
IRIS = '.sgi'
JPEG = '.jpg'
JPEG2000 = '.jp2'
TARGA = '.tga'
TARGA_RAW = '.tga'
DPX = '.dpx'
CINEON = '.cin'
OPEN_EXR = '.exr'
OPEN_EXR_MULTILAYER = '.exr'
HDR = '.hdr'
TIFF = '.tiff'
WEBP = '.webp'
ddg.blender.render.set_world_background(color=(1, 1, 1, 1), strength=0.2, world=None)[source]

Set the world background color and emission.

Parameters:
colorSequence of 4 floats between 0 and 1 (default=(1, 1, 1, 1))

Color the background will have.

strengthfloat (default=0.2)

Emission strength of the background.

worldbpy.types.World (default=None)

World to modify. If None, use world of the current scene.

ddg.blender.render.set_film_transparency(scene=None, transparent=True)[source]

Set the transparency of the render’s film.

Parameters:
scenebpy.types.Scene (default=None)

Scene to apply the render setup to. If None, use the current scene.

transparentbool (default=True)

If True make the film transparent, else use opaque world background.

ddg.blender.render.setup_eevee_renderer(scene=None, taa_render_samples=64, shadow_cube_size='512', shadow_cascade_size='1024')[source]

Set render settings for the Eevee engine.

The default arguments for every parameter other than scene match Blender’s default settings.

Parameters:
scenebpy.types.Scene (default=None)

Scene to which to apply the render settings. If None use bpy.context.scene.

taa_render_samplesint (default=64)

Number of samples per pixel for rendering. Sets scene.eevee.taa_render_samples to this value.

shadow_cube_size{“64”, “128”, “256”, “512”, “1024”, “2048”, “4096”} (default = “512”)

Size of point and area light shadow maps. Sets scene.eevee.shadow_cube_size to this value.

shadow_cascade_size{“64”, “128”, “256”, “512”, “1024”, “2048”, “4096”} (default = “1024”)

Size of sun light shadow maps. Sets scene.eevee.shadow_cascade_size to this value.

ddg.blender.render.setup_cycles_renderer(scene=None, use_persistent_data=False, device='CPU', use_adaptive_sampling=True, adaptive_threshold=0.01, samples=4096, adaptive_min_samples=0, time_limit=0, use_denoising=True)[source]

Set render settings for the Cycles engine with adaptive sampling.

The default arguments for every parameter other than scene match Blender’s default settings.

Parameters:
scenebpy.types.Scene (default=None)

Scene to which to apply the render settings. If None, use bpy.context.scene.

use_persistent_databool (default=False)

Keep render data around for faster re-renders and animation renders, at the cost of increased memory usage. Sets scene.render.use_persistent_data to this value.

device{“CPU”, “GPU”} (default=”CPU”)

Device to use for rendering. Sets scene.cycles to this value.

use_adaptive_samplingbool (default=True)

Automatically reduce the number of samples per pixel based on estimated noise level. Sets scene.cycles.use_adaptive_sampling to this value.

adaptive_thresholdfloat (default=0.01)

Noise level step to stop sampling at, lower values reduce noise at the cost of render time. Zero for automatic setting based on number of AA samples. Sets scene.cycles.adaptive_threshold to this value.

samplesint (default=4096)

Number of samples to render for each pixel. Sets scene.cycles.samples to this value.

adaptive_min_samplesint (default=0)

Minimum AA samples for adaptive sampling, to discover noisy features before stopping sampling. Zero for automatic setting based on noise threshold. Sets scene.cycles.adaptive_min_samples to this value.

time_limitfloat (default=0)

Limit the render time (excluding synchronization time). Zero disables the limit. Measured in seconds. Sets scene.cycles.time_limit to this value.

use_denoisingbool (default=True)

Denoise the rendered image. Sets scene.cycles.use_denoising to this value.

ddg.blender.render.set_render_stamp_note(note, scene=None, font_size=26, font_color=(0, 0, 0, 1), bg_color=(0, 0, 0, 0))[source]

Set a custom string to display in the render stamp.

Parameters:
notestr

The string to display in render stamp.

scenebpy.types.Scenes (default=None)

The scene to setup render stamp. If None use the current scene.

font_sizeint (default=26)

The font size of displayed string.

font_colorIterable of four floats (default=(0.,0.,0.,1.))

RGBA values of displayed string.

bg_colorIterable of four floats (default=(0.,0.,0.,0.))

RGBA values of background of displayed string.

Notes

In order to display a stamp note scene.render.use_stamp must be set to True. Blender then automatically adds other render stamps, such as render time, date and file name. You can disable those manually, for example by setting scene.render.use_stamp_filename = False. For more settings, see bpy.types.RenderSettings.

ddg.blender.render.set_render_output_images(output_path, time=True, scene=None, file_format='PNG', alpha=True, quality=100)[source]

Set the rendering output for an image sequence.

Unless time=False, each time this function is called a new timestamp is set, and the output images will be saved under {output_path}/{timestamp}/ in order to isolate renders between sessions.

Parameters:
output_pathstr

The directory path to which to save to ouput.

timebool (default=True)

Whether or not to create a timestamp subdirectory and save the rendered images under it.

scenebpy.types.Scenes (default=None)

The scene to which to apply the settings. If None use the current scene.

file_formatstr (default=”PNG”)

The file format of the images. In upper letters. For example ‘PNG’ or ‘JPEG2000’

alphabool (default=True)

Whether to use alpha in the output image.

qualityint (default=100)

Quality of the output image in percent.

ddg.blender.render.render_frame(frame, full_path=None, camera=None)[source]

Render a frame to full_path.

Parameters:
frameint

Frame to use for the render.

full_pathstr (default=None)

Full output path with file name and extension. If None use the current scene scene.render.filepath and scene.render.image_settings.file_format.

camerabpy.types.Camera (default=None)

Camera to use for the render. If None use the current scene camera.

ddg.blender.render.render_animation(output_directory=None, start=None, end=None, camera=None)[source]

Render all frames between start and end to path.

Parameters:
output_directorystr (default=None)

Directory of the render output. If None use current scene scene.render.filepath and scene.render.image_settings.file_format.

startint (default=None)

Start frame. If None use current scene start frame.

endint (default=None)

End frame. If None use current scene end frame.

camerabpy.types.Camera (default=None)

Camera to use for the render. If None, use the current scene camera.