visionsim.simulate package

Subpackages

Submodules

visionsim.simulate.blender module

visionsim.simulate.blender.require_connected_client(func: Callable[..., Any]) → Callable[..., Any][source]

Decorator which ensures a client is connected.

Parameters:

func (Callable[..., Any]) – Function to decorate

Raises:

RuntimeError – raised if client is not connected.

Returns:

Decorated function.

Return type:

Callable[…, Any]

visionsim.simulate.blender.require_connected_clients(func: Callable[..., Any]) → Callable[..., Any][source]

Decorator which ensures all clients are connected.

Parameters:

func (Callable[..., Any]) – Function to decorate

Raises:

RuntimeError – if at least one client is not connected.

Returns:

Decorated function.

Return type:

Callable[…, Any]

visionsim.simulate.blender.require_initialized_service(func: Callable[..., Any]) → Callable[..., Any][source]

Decorator which ensures the render service was initialized.

Parameters:

func (Callable[..., Any]) – Function to decorate

Raises:

RuntimeError – raised if client.initialize has not been previously called.

Returns:

Decorated function.

Return type:

Callable[…, Any]

visionsim.simulate.blender.validate_camera_moved(func: Callable[..., Any]) → Callable[..., Any][source]

Decorator which emits a warning if the camera was not moved.

Parameters:

func (Callable[..., Any]) – Function to decorate

Returns:

Decorated function.

Return type:

Callable[…, Any]

class visionsim.simulate.blender.BlenderServer(hostname: bytes | str | None = None, port: bytes | str | int | None = 0, service: type[BlenderService] | None = None, extra_config: dict | None = None, **kwargs)[source]

Bases: Server

Expose a BlenderService to the outside world via RPCs.

Example

Once created, it can be started, which will block and await for an external connection from a BlenderClient:

server = BlenderServer()
server.start()

However, this needs to be called within blender’s runtime. Instead one can use BlenderServer.spawn() to spawn one or more blender instances, each with their own server.

__init__(hostname: bytes | str | None = None, port: bytes | str | int | None = 0, service: type[BlenderService] | None = None, extra_config: dict | None = None, **kwargs) → None[source]

Initialize a BlenderServer instance

Parameters:
  • hostname (bytes | str | None, optional) – the host to bind to. By default, the ‘wildcard address’ is used to listen on all interfaces. If not properly secured, the server can receive traffic from unintended or even malicious sources. Defaults to None (wildcard).

  • port (bytes | str | int | None, optional) – the TCP port to bind to. Defaults to 0 (bind to a random open port).

  • service (type[BlenderService], optional) – the service to expose, must be a BlenderService subclass. Defaults to BlenderService.

  • extra_config (dict, optional) – the configuration dictionary that is passed to the RPyC connection. Defaults to {"allow_all_attrs": True, "allow_setattr": True}.

  • **kwargs – Additional keyword arguments which are passed to the rpyc.utils.server.Server constructor.

Raises:
  • RuntimeError – a BlenderServer needs to be instantiated from within a blender instance.

  • ValueError – the exposed service must be BlenderService or subclass.

spawn(timeout: float = 0.0, log: str | os.PathLike | FILE | tuple[FILE, FILE] = -3, autoexec: bool = False, executable: str | os.PathLike | None = None, service: str | None = None, background: bool = True, factory_startup: bool = False, env: dict[str, str] | None = None) → Generator[tuple[list[subprocess.Popen], list[tuple[str, int]]]][source]

Spawn one or more blender instances and start a BlenderServer in each.

This is roughly equivalent to calling blender -b --python blender.py in many subprocesses, where blender.py initializes and starts a server instance. Proper logging and termination of these processes is also taken care of.

Note

The returned processes and connection settings are in the same order, so the i-th process corresponds to the i-th connection setting.

Warning

If log is a file handle or descriptor, such as redirecting Blender logs to subprocess.STDOUT, the writing process might get overwhelmed which can cause silent errors, dropped logs and locked processes. It is thus not recommended for long render jobs to set log to anything but DEVNULL or a directory.

Parameters:
  • jobs (int, optional) – number of jobs to spawn. Defaults to 1.

  • timeout (float, optional) – wait up to timeout seconds for each spawned server to accept connections on its reserved port before giving up. Zero (the default) skips the wait and yields immediately, even if a server is not yet ready to accept incoming connections; the client connecting to it is expected to retry.

  • log (str | os.PathLike | FILE | tuple[FILE, FILE], optional) – path to log directory, file handle, descriptor or tuple thereof. Stdout and stderr will be captured and saved if supplied. Defaults to subprocess.DEVNULL for both stdout/stderr.

  • autoexec (bool, optional) – if true, allow execution of any embedded python scripts within blender. For more, see blender’s CLI documentation. Defaults to False.

  • executable (str | os.PathLike | None, optional) – path to Blender’s executable. Defaults to looking for blender on $PATH, but is useful when targeting a specific blender install, or when it’s installed via a package manager such as flatpak. Setting it to “flatpak run –die-with-parent org.blender.Blender” might be required when using flatpaks. Defaults to None (system PATH).

  • service (str | None, optional) – path of the BlenderService subclass the spawned server should expose, either dotted (module:ClassName, imported inside blender) or a /path/to/service.py:ClassName file (executed as a script, so the file’s package is never imported). Defaults to None (the base BlenderService).

  • background (bool, optional) – if true, spawn blender in background mode (-b). This is faster and does not require a display, but has no OpenGL context, so viewport renders (playblasts) are unavailable. Set to false to keep a window/GL context open (requires a display). Defaults to True.

  • factory_startup (bool, optional) – if true, pass --factory-startup so the run ignores the machine’s blender preferences and startup file. Defaults to False.

  • env (dict[str, str] | None, optional) – extra environment variables for the spawned blender, such as PYTHONPATH. Merged over the parent’s os.environ, which is inherited by default. Defaults to None.

Raises:

TimeoutError – raise if unable to discover spawned servers in timeout seconds and kill any spawned processes.

Yields:

Generator[tuple[list[subprocess.Popen], list[tuple[str, int]]]] –

A tuple containing:
  • list[subprocess.Popen]: List of subprocess.Popen corresponding to all spawned servers.

  • list[tuple[str, int]]: List of connection setting for each server, where each element is a (hostname, port) tuple.

static spawn_registry() → tuple[Process | None, UDPRegistryClient][source]

Spawn a registry server and client to aid in server discovery, or return cached result. While this method can be called directly, it will be invoked automatically by discover() and spawn().

The registry is machine-wide, so a registry already running in another process is reused rather than treated as an error.

Returns:

A tuple containing:
  • Process | None: process running the registry server, or None if another process owns it,

  • rpyc.utils.registry.UDPRegistryClient: global registry client

Return type:

tuple[Process | None, rpyc.utils.registry.UDPRegistryClient]

Raises:

RuntimeError – the registry port is held by a process that does not answer rpyc queries.

static discover() → list[tuple[str, int]][source]

Discover any BlenderServers that are already running and return their connection parameters.

Note

A discoverable server might already be in use and can refuse connection attempts.

Returns:

List of connection setting for each server, where each element is a (hostname, port) tuple.

Return type:

list[tuple[str, int]]

class visionsim.simulate.blender.BlenderService[source]

Bases: Service

Server-side API to interact with blender and render novel views.

Most of the methods of a BlenderClient instance are remote procedure calls to a connected blender service. These methods are prefixed by exposed_.

ALIASES: tuple[str] = ('BLENDER',)
__init__() → None[source]

Initialize render service.

Raises:

RuntimeError – raised if not within blender’s runtime.

on_connect(conn: Connection) → None[source]

Called when the connection is established

Parameters:

conn (rpyc.Connection) – Connection object

on_disconnect(conn: Connection) → None[source]

Called when the connection has already terminated. Resets blender runtime. (must not perform any IO on the connection)

Parameters:

conn (rpyc.Connection) – Connection object

reset() → None[source]

Cleans up and resets blender runtime.

De-initialize service by restoring blender to it’s startup state, ensuring any cached attributes are cleaned (otherwise objects will be stale), and resetting any instance variables that were previously initialized.

register_output_type(subpath: str, node: bpy.types.CompositorNodeOutputFile, slot: bpy.types.NodeOutputFileSlotFile | bpy.types.NodeCompositorFileOutputItem, **camera_defaults) → None[source]

Register a new output datatype. If this is not called by an include_ method, the metadata for that datatype will not be saved to the database and the path to which the data is saved will not be updated at every render.

Warning

You must pass in the slot instance that was returned when a new file_output_item was created and not simply one of the node.file_output_items as these are readonly!

Parameters:
  • subpath (str) – Path suffix, from root data directory, of the new datatype (eg: “previews/depths”)

  • node (bpy.types.CompositorNodeOutputFile) – Output file node responsible for saving

  • slot (bpy.types.NodeOutputFileSlotFile | bpy.types.NodeCompositorFileOutputItem) – Slot of node which will save the output data.

  • **camera_defaults – Any addition camera information that will be added by default. Commonly, the number of output channels is passed in (eg: c=4 for RGBA).

Raises:

RuntimeError – raised if output type has already been registered.

property scene: bpy.types.Scene

Get current blender scene

property tree: bpy.types.CompositorNodeTree

Get current scene’s node tree

property render_layers: bpy.types.CompositorNodeRLayers[source]

Get and cache render layers node, create one if needed.

property view_layer: bpy.types.ViewLayer

Get current view layer

property camera: bpy.types.Camera

Get active camera, detect when it changes.

get_parents(obj: bpy.types.Object) → list[bpy.types.Object][source]

Recursively retrieves parent objects of a given object in Blender

Parameters:

obj – Object to find parent of.

Returns:

Parent objects of obj.

Return type:

list[bpy.types.Object]

exposed_with_logger(log: Logger) → None[source]

Use supplied logger, if logger is initialized in client, messages will log to the client.

Parameters:

log (logging.Logger) – Logger to use for messages

exposed_initialize(blend_file: str | PathLike, root_path: str | PathLike, **kwargs) → None[source]

Initialize BlenderService and load blendfile.

Parameters:
  • blend_file (str | os.PathLike) – path of scene file to load.

  • root_path (str | os.PathLike) – path at which to save rendered results.

  • **kwargs – Additional keyword arguments to be passed to bpy.ops.wm.open_mainfile.

exposed_iter_fcurves(actions: list[bpy.types.Action] | None = None) → Iterator[bpy.types.FCurve][source]

Yield fcurves of all actions.

Parameters:

actions (list[bpy.types.Action] | None, optional) – Only yield fcurves from these actions if specified, otherwise use all actions. Defaults to None.

Yields:

Iterator[bpy.types.FCurve] – an fcurve object from the scene or action

exposed_get_original_fps() → float[source]

Get effective framerate (fps/fps_base).

Returns:

Frame rate of scene.

Return type:

float

exposed_animation_range() → range[source]

Get animation range of current scene as range(start, end+1, step).

Returns:

Range of frames in animation.

Return type:

range

exposed_animation_range_tuple() → tuple[int, int, int][source]

Get animation range of current scene as a tuple of (start, end, step).

Returns:

Frame start, end, and step of animation.

Return type:

tuple[int, int, int]

exposed_include_composites(file_format: FILE_FORMATS | None = None, color_mode: COLOR_MODES | None = None, exr_codec: EXR_CODECS | None = None, bit_depth: Literal[8, 16, 32] | None = None) → None[source]

Sets up Blender to include the outputs of any existing compositor nodes groups.

Note: A default arguments of None means do not change setting inherited from the blendfile’s Output settings.

Parameters:
  • file_format (str | None, optional) – Format to save composited render as. Options vary depending on the version of Blender, with the following being broadly available: (‘BMP’, ‘IRIS’, ‘PNG’, ‘JPEG’, ‘JPEG2000’, ‘TARGA’, ‘TARGA_RAW’, ‘CINEON’, ‘DPX’, ‘OPEN_EXR’, ‘HDR’, ‘TIFF’, ‘WEBP’). Defaults to None.

  • color_mode (str | None, optional) – Typically one of (‘BW’, ‘RGB’, ‘RGBA’). Defaults to None.

  • exr_codec (str | None, optional) – Codec used to compress exr file. Only used when file_format="OPEN_EXR", options vary depending on the version of Blender, with the following being broadly available: (‘NONE’, ‘PXR24’, ‘ZIP’, ‘PIZ’, ‘RLE’, ‘ZIPS’, ‘DWAA’, ‘DWAB’). Defaults to None.

  • bit_depth (int | None, optional) – Bit depth per channel, also referred to as color-depth. Options depend on the chosen file format, with 8, 16 and 32bits being common. Defaults to None.

exposed_include_frames(file_format: FILE_FORMATS = 'PNG', color_mode: COLOR_MODES = 'RGB', exr_codec: EXR_CODECS = 'DWAA', bit_depth: Literal[8, 16, 32] = 8) → None[source]

Sets up Blender compositor to include ground truth rendered images, bypassing any existing compositor nodes.

Note

For linear intensity renders, use the “OPEN_EXR” format with and 32 or 16 bits.

Parameters:
  • file_format (str, optional) – Format to save ground truth render as. Options vary depending on the version of Blender, with the following being broadly available: (‘BMP’, ‘IRIS’, ‘PNG’, ‘JPEG’, ‘JPEG2000’, ‘TARGA’, ‘TARGA_RAW’, ‘CINEON’, ‘DPX’, ‘OPEN_EXR’, ‘HDR’, ‘TIFF’, ‘WEBP’). Defaults to “PNG”.

  • color_mode (str, optional) – Typically one of (‘BW’, ‘RGB’, ‘RGBA’). Defaults to “RGB”.

  • exr_codec (str, optional) – Codec used to compress exr file. Only used when file_format="OPEN_EXR", options vary depending on the version of Blender, with the following being broadly available: (‘NONE’, ‘PXR24’, ‘ZIP’, ‘PIZ’, ‘RLE’, ‘ZIPS’, ‘DWAA’, ‘DWAB’). Defaults to “DWAA”.

  • bit_depth (int, optional) – Bit depth per channel, also referred to as color-depth. Options depend on the chosen file format, with 8, 16 and 32 bits being common. Defaults to 8 bits.

Raises:

ValueError – raised when file-format not understood.

exposed_include_depths(preview: bool = True, file_format: FILE_FORMATS = 'OPEN_EXR', exr_codec: EXR_CODECS = 'DWAA', bit_depth: Literal[16, 32] = 32) → None[source]

Sets up Blender compositor to include depth map for rendered images.

Note

The preview colormap is re-normalized on a per-frame basis, to visually compare across frames, apply colorization after rendering using the CLI.

Parameters:
  • preview (bool, optional) – If true, colorized depth maps, helpful for quick visualizations, will be generated alongside ground-truth depth maps. Defaults to True.

  • file_format (str, optional) – Format of depth maps, one of “OPEN_EXR” or “HDR”. Defaults to “OPEN_EXR”.

  • exr_codec (str, optional) – Codec used to compress exr file. Only used when file_format="OPEN_EXR", options vary depending on the version of Blender, with the following being broadly available: (‘NONE’, ‘PXR24’, ‘ZIP’, ‘PIZ’, ‘RLE’, ‘ZIPS’, ‘DWAA’, ‘DWAB’). Defaults to “DWAA”.

  • bit_depth (int, optional) – Bit depth per channel, also referred to as color-depth. Options depend on the chosen file format, with 8, 16 and 32 bits being common. Defaults to 32 bits.

Raises:

ValueError – raised when file-format not understood.

exposed_include_normals(preview: bool = True, exr_codec: EXR_CODECS = 'DWAA', bit_depth: Literal[16, 32] = 32) → None[source]

Sets up Blender compositor to include normal map for rendered images.

Parameters:
  • preview (bool, optional) – If true, colorized normal maps will also be generated with each vector component being remapped from [-1, 1] to [0-255] where XYZ coordinates are mapped channel-wise to RGB. Defaults to True.

  • exr_codec (str, optional) – Codec used to compress exr file. Options vary depending on the version of Blender, with the following being broadly available: (‘NONE’, ‘PXR24’, ‘ZIP’, ‘PIZ’, ‘RLE’, ‘ZIPS’, ‘DWAA’, ‘DWAB’). Defaults to “DWAA”.

  • bit_depth (int, optional) – Bit depth per channel, also referred to as color-depth. Either 16 or 32 bits. Defaults to 32 bits.

exposed_include_flows(preview: bool = True, direction: Literal['forward', 'backward', 'both'] = 'forward', exr_codec: EXR_CODECS = 'DWAA', bit_depth: Literal[16, 32] = 32) → None[source]

Sets up Blender compositor to include optical flow for rendered images.

Parameters:
  • preview (bool, optional) – If true, also save preview visualizations of flow. Defaults to True.

  • direction (str, optional) – One of ‘forward’, ‘backward’ or ‘both’. Direction of flow to colorize for preview visualization. Only used when preview is true, otherwise both forward and backward flows are saved. Defaults to “forward”.

  • exr_codec (str, optional) – Codec used to compress exr file. Options vary depending on the version of Blender, with the following being broadly available: (‘NONE’, ‘PXR24’, ‘ZIP’, ‘PIZ’, ‘RLE’, ‘ZIPS’, ‘DWAA’, ‘DWAB’). Defaults to “DWAA”.

  • bit_depth (int, optional) – Bit depth per channel, also referred to as color-depth. Options depend on the chosen file format, with 8, 16 and 32 bits being common. Defaults to 32 bits.

Note

The preview colormap is re-normalized on a per-frame basis, to visually compare across frames, apply colorization after rendering using the CLI.

Raises:
  • ValueError – raised when direction is not understood.

  • RuntimeError – raised when motion blur is enabled as flow cannot be computed.

exposed_include_segmentations(preview: bool = True, shuffle: bool = True, seed: int = 1234, exr_codec: EXR_CODECS = 'DWAA', bit_depth: Literal[16, 32] = 32) → None[source]

Sets up Blender compositor to include segmentation maps for rendered images.

The preview visualization simply assigns a color to each object ID by mapping the objects ID value to a hue using a HSV node with saturation=1 and value=1 (except for the background which will have a value of 0 to ensure it is black). The assigned ID -> object name table is written to indices.json beside the raw pass.

Parameters:
  • preview (bool, optional) – If true, also save preview visualizations of segmentation. Defaults to True.

  • shuffle (bool, optional) – Shuffle preview colors, helps differentiate object instances. Defaults to True.

  • seed (int, optional) – Random seed used when shuffling colors. Defaults to 1234.

  • exr_codec (str, optional) – Codec used to compress exr file. Options vary depending on the version of Blender, with the following being broadly available: (‘NONE’, ‘PXR24’, ‘ZIP’, ‘PIZ’, ‘RLE’, ‘ZIPS’, ‘DWAA’, ‘DWAB’). Defaults to “DWAA”.

  • bit_depth (int, optional) – Bit depth per channel, also referred to as color-depth. Either 16 or 32 bits. Defaults to 32 bits.

Raises:

RuntimeError – raised when not using CYCLES, as other renderers do not support a segmentation pass.

exposed_include_materials(preview: bool = True, shuffle: bool = True, seed: int = 1234, exr_codec: EXR_CODECS = 'DWAA', bit_depth: Literal[16, 32] = 32) → None[source]

Sets up Blender compositor to include material ID maps for rendered images.

The preview visualization simply assigns a color to each material ID by mapping the materials ID value to a hue using a HSV node with saturation=1 and value=1 (except for the background which will have a value of 0 to ensure it is black). The assigned ID -> material name table is written to indices.json beside the raw pass.

Parameters:
  • preview (bool, optional) – If true, also save preview visualizations of material IDs. Defaults to True.

  • shuffle (bool, optional) – Shuffle preview colors, helps differentiate material instances. Defaults to True.

  • seed (int, optional) – Random seed used when shuffling colors. Defaults to 1234.

  • exr_codec (str, optional) – Codec used to compress exr file. Options vary depending on the version of Blender, with the following being broadly available: (‘NONE’, ‘PXR24’, ‘ZIP’, ‘PIZ’, ‘RLE’, ‘ZIPS’, ‘DWAA’, ‘DWAB’). Defaults to “DWAA”.

  • bit_depth (int, optional) – Bit depth per channel, also referred to as color-depth. Either 16 or 32 bits. Defaults to 32 bits.

Raises:

RuntimeError – raised when not using CYCLES, as other renderers do not support a material ID pass.

exposed_include_diffuse_pass(file_format: FILE_FORMATS = 'OPEN_EXR', color_mode: COLOR_MODES = 'RGB', exr_codec: EXR_CODECS = 'DWAA', bit_depth: Literal[8, 16, 32] = 32, denoise: bool = True) → None[source]

Sets up Blender compositor to include diffuse light passes for rendered images.

For CYCLES, this includes: Diffuse Direct, Diffuse Indirect and Diffuse Color. For EEVEE, this includes: Diffuse Light and Diffuse Color.

Note

When using CYCLES, these extra light passes might be very noisy, especially the indirect ones, as they rely on raytracing. To mitigate this, you can either increase the number of samples, or the threshold in the cycles_settings, or/and use the denoise option.

Parameters:
  • file_format (str, optional) – Format to save diffuse passes as. Defaults to “OPEN_EXR”.

  • color_mode (str, optional) – Typically one of (‘BW’, ‘RGB’, ‘RGBA’). Defaults to “RGB”.

  • exr_codec (str, optional) – Codec used to compress exr file. Only used when file_format="OPEN_EXR". Defaults to “DWAA”.

  • bit_depth (int, optional) – Bit depth per channel. Defaults to 32 bits.

  • denoise (bool, optional) – If true, apply Cycles denoising to the direct and indirect passes before saving. The colour pass is left undenoised as it is noise-free by nature. Has no effect when not using Cycles. Defaults to True.

exposed_include_specular_pass(file_format: FILE_FORMATS = 'OPEN_EXR', color_mode: COLOR_MODES = 'RGB', exr_codec: EXR_CODECS = 'DWAA', bit_depth: Literal[8, 16, 32] = 32, denoise: bool = True) → None[source]

Sets up Blender compositor to include specular light passes for rendered images.

For CYCLES, this includes: Glossy Direct, Glossy Indirect and Glossy Color. For EEVEE, this includes: Specular Light and Specular Color.

Note

When using CYCLES, these extra light passes might be very noisy, especially the indirect ones, as they rely on raytracing. To mitigate this, you can either increase the number of samples, or the threshold in the cycles_settings, or/and use the denoise option.

Parameters:
  • file_format (str, optional) – Format to save specular passes as. Defaults to “OPEN_EXR”.

  • color_mode (str, optional) – Typically one of (‘BW’, ‘RGB’, ‘RGBA’). Defaults to “RGB”.

  • exr_codec (str, optional) – Codec used to compress exr file. Only used when file_format="OPEN_EXR". Defaults to “DWAA”.

  • bit_depth (int, optional) – Bit depth per channel. Defaults to 32 bits.

  • denoise (bool, optional) – If true, apply Cycles denoising to the direct and indirect passes before saving. The colour pass is left undenoised as it is noise-free by nature. Has no effect when not using Cycles. Defaults to True.

exposed_include_points(preview: bool = True, exr_codec: EXR_CODECS = 'DWAA', bit_depth: Literal[16, 32] = 32) → None[source]

Sets up Blender compositor to include a world-space point map for each frame.

Note

The point map corresponds to world-space positions, like those used in VGGT [1], and not the camera-centric positions used in DUSt3R [2].

Parameters:
  • preview (bool, optional) – If true, colorized point maps will also be generated, where colors are assigned based on the absolute fractional world coordinates. Defaults to True.

  • exr_codec (str, optional) – Codec used to compress exr file. Defaults to “DWAA”.

  • bit_depth (int, optional) – Bit depth per channel. Either 16 or 32 bits. Defaults to 32 bits.

exposed_prepare_thermal(radiance: bool = True, preview: bool = True, initial_temperature_K: float = 295.0, thermal_diffusivity_mm2_s: float = 0.17, density_kg_m3: float = 1330.0, specific_heat_J_kgK: float = 880.0, emissivity: float = 0.9, irradiance_scale: float = 1.0, sim_time_s: float = 1.0, timestep_s: float = 0.05, bake_samples: int = 1024, irradiance_texture_size: int = 512, device: Literal['cuda', 'cpu'] = 'cuda', render_domain: Literal['AUTO', 'VERTEX', 'TEXEL'] = 'AUTO', atlas_texel_density: float = 1500.0, atlas_tile_min: int = 16, atlas_tile_max: int = 512, atlas_texel_soft_max: int = 500000, recompute: bool = False, radiance_scale: float = 1.0, exr_codec: EXR_CODECS = 'ZIP', bit_depth: Literal[16, 32] = 32, assignments: str | None = None) → None[source]

Solve a fixed thermal field, write attributes or atlas, and set up the AOV.

exposed_heatsim_solve(radiance: bool = True, preview: bool = True, initial_temperature_K: float = 295.0, thermal_diffusivity_mm2_s: float = 0.17, density_kg_m3: float = 1330.0, specific_heat_J_kgK: float = 880.0, emissivity: float = 0.9, irradiance_scale: float = 1.0, sim_time_s: float = 1.0, timestep_s: float = 0.05, bake_samples: int = 1024, irradiance_texture_size: int = 512, device: Literal['cuda', 'cpu'] = 'cuda', render_domain: Literal['AUTO', 'VERTEX', 'TEXEL'] = 'AUTO', atlas_texel_density: float = 1500.0, atlas_tile_min: int = 16, atlas_tile_max: int = 512, atlas_texel_soft_max: int = 500000, recompute: bool = False, radiance_scale: float = 1.0, exr_codec: EXR_CODECS = 'ZIP', bit_depth: Literal[16, 32] = 32, assignments: str | None = None) → None[source]

Solve and cache a fixed thermal field without render outputs, ignoring the render-output parameters it accepts for symmetry with ThermalConfig.

exposed_include_thermal(radiance: bool = True, preview: bool = True, initial_temperature_K: float = 295.0, thermal_diffusivity_mm2_s: float = 0.17, density_kg_m3: float = 1330.0, specific_heat_J_kgK: float = 880.0, emissivity: float = 0.9, irradiance_scale: float = 1.0, sim_time_s: float = 1.0, timestep_s: float = 0.05, bake_samples: int = 1024, irradiance_texture_size: int = 512, device: Literal['cuda', 'cpu'] = 'cuda', render_domain: Literal['AUTO', 'VERTEX', 'TEXEL'] = 'AUTO', atlas_texel_density: float = 1500.0, atlas_tile_min: int = 16, atlas_tile_max: int = 512, atlas_texel_soft_max: int = 500000, recompute: bool = False, radiance_scale: float = 1.0, exr_codec: EXR_CODECS = 'ZIP', bit_depth: Literal[16, 32] = 32, assignments: str | None = None) → None[source]

Add the temperature AOV and optional preview and radiance outputs.

exposed_configure_thermal(config: dict[str, Any]) → None[source]

Validate one serialized ThermalConfig and prepare both thermal outputs.

exposed_heatsim_solve_config(config: dict[str, Any]) → None[source]

Validate one serialized ThermalConfig and solve without render outputs.

exposed_load_addons(*addons: str) → None[source]

Load blender addons by name (case-insensitive).

Parameters:

*addons (str) – name of addons to load.

exposed_set_resolution(height: tuple[int] | list[int] | int | None = None, width: int | None = None, resolution_percentage: int = 100) → None[source]

Set frame resolution (height, width) in pixels. If a single tuple is passed, instead of using keyword arguments, it will be parsed as (height, width).

Parameters:
  • height (tuple[int] | list[int] | int | None, optional) – Height of render in pixels. Defaults to value from file.

  • width (int | None, optional) – Width of render in pixels. Defaults to value from file.

  • resolution_percentage (int, optional) – Percentage of the original resolution to render at. Defaults to 100%.

Raises:

ValueError – raised if the resolution is not understood, or if a dimension is not positive.

exposed_use_motion_blur(enable: bool) → None[source]

Enable/disable motion blur.

Parameters:

enable (bool) – If true, enable motion blur.

Raises:

RuntimeError – raised when motion blur is enabled as flow cannot be computed.

exposed_use_animations(enable: bool) → None[source]

Enable/disable all animations.

Parameters:

enable (bool) – If true, enable animations.

exposed_cycles_settings(device_type: str | None = None, use_cpu: bool | None = None, adaptive_threshold: float | None = None, max_samples: int | None = None, use_denoising: bool | None = None) → list[str][source]

Enables/activates cycles render devices and settings.

Note: A default arguments of None means do not change setting inherited from blendfile.

Parameters:
  • device_type (str, optional) – Name of device to use, one of “cpu”, “cuda”, “optix”, “metal”, etc. See blender docs for full list. Defaults to None.

  • use_cpu (bool, optional) – Boolean flag to enable CPUs alongside GPU devices. Defaults to None.

  • adaptive_threshold (float, optional) – Set noise threshold upon which to stop taking samples. Defaults to None.

  • max_samples (int, optional) – Maximum number of samples per pixel to take. Defaults to None.

  • use_denoising (bool, optional) – If enabled, a denoising pass will be used. Defaults to None.

Raises:
  • RuntimeError – raised when no devices are found.

  • ValueError – raised when setting use_cpu is required.

Returns:

Name of activated devices.

Return type:

list[str]

exposed_unbind_camera(clear_animations: bool = True) → None[source]

Remove constraints, animations and parents from main camera.

Note: In order to undo this, you’ll need to re-initialize.

Parameters:

clear_animations (bool, optional) – If true clear animation data for camera.

exposed_move_keyframes(scale=1.0, shift=0.0) → None[source]

Adjusts keyframes in Blender animations, keypoints are first scaled then shifted.

Parameters:
  • scale (float, optional) – Factor used to rescale keyframe positions along x-axis. Defaults to 1.0.

  • shift (float, optional) – Factor used to shift keyframe positions along x-axis. Defaults to 0.0.

Raises:

RuntimeError – raised if trying to move keyframes beyond blender’s limits.

exposed_set_current_frame(frame_number: int) → None[source]

Set current frame number. This might advance any animations.

Parameters:

frame_number (int) – index of frame to skip to.

exposed_camera_info() → dict[str, Any][source]

Return a dictionary with camera intrinsics.

Returns:

dictionary containing camera parameters.

Return type:

dict[str, Any]

exposed_camera_extrinsics() → npt.NDArray[np.floating][source]

Get the 4x4 transform matrix encoding the current camera pose.

Returns:

Current camera pose in matrix form.

Return type:

npt.NDArray[np.floating]

exposed_position_camera(location: TypeAliasForwardRef('npt.ArrayLike') | None = None, rotation: TypeAliasForwardRef('npt.ArrayLike') | None = None, look_at: TypeAliasForwardRef('npt.ArrayLike') | None = None, in_order: bool = True) → None[source]

Positions and orients camera according to specified parameters. All transformations are local, use unbind_camera to ensure position is set in world coordinates.

Note: Only one of look_at or rotation can be set at once.

Parameters:
  • location (npt.ArrayLike, optional) – Location to place camera in 3D space. Defaults to none.

  • rotation (npt.ArrayLike, optional) – Rotation matrix for camera. Defaults to none.

  • look_at (npt.ArrayLike, optional) – Location to point camera. Defaults to none.

  • in_order (bool, optional) – If set, assume current camera pose is from previous/next frame and ensure new rotation set by look_at is compatible with current position. Without this, a rotations will stay in the [-pi, pi] range and this wrapping will mess up interpolations. Only used when look_at is set. Defaults to True.

Raises:

ValueError – raised if camera orientation is over-defined.

exposed_rotate_camera(angle: float) → None[source]

Rotate camera around it’s optical axis, relative to current orientation. All transformations are local, use unbind_camera to ensure position is set in world coordinates.

Parameters:

angle – Relative amount to rotate by (clockwise, in radians).

exposed_offset_camera(offset: npt.ArrayLike) → None[source]

Move camera by a given vector in its local coordinate frame.

Parameters:

offset (npt.ArrayLike) – Amount to offset by (x, y, z) in local coordinates.

exposed_set_camera_keyframe(frame_num: int, matrix: TypeAliasForwardRef('npt.ArrayLike') | None = None) → None[source]

Set camera keyframe at given frame number. If camera matrix is not supplied, currently set camera position/rotation/scale will be used, this allows users to set camera position using position_camera and rotate_camera.

Parameters:
  • frame_num (int) – index of frame to set keyframe for.

  • matrix (npt.ArrayLike | None, optional) – 4x4 camera transform, if not supplied, use current camera matrix. Defaults to None.

exposed_set_animation_range(start: int | None = None, stop: int | None = None, step: int | None = None) → None[source]

Set animation range for scene.

Parameters:
  • start (int | None, optional) – frame start, inclusive. Defaults to None.

  • stop (int | None, optional) – frame stop, exclusive. Defaults to None.

  • step (int | None, optional) – frame interval. Defaults to None.

exposed_render_current_frame(allow_skips=True, dry_run=False) → None[source]

Generates a single frame in Blender at the current camera location, return the file paths for that frame, potentially including depth, normals, etc.

Note

This method renders the current frame as-is, it assumes the camera position, frame number and all other parameters have been set.

Parameters:
  • allow_skips (bool, optional) – if true, blender will not re-render and overwrite existing frames. Applies to every selected output; the render is skipped only when all of them exist. Defaults to True.

  • dry_run (bool, optional) – if true, nothing will be rendered at all. Defaults to False.

exposed_render_frame(frame_number: int, allow_skips=True, dry_run=False) → None[source]

Render one camera frame using the current scene state.

exposed_render_frames(frame_numbers: Iterable[int], allow_skips=True, dry_run=False, update_fn: UpdateFn | None = None) → None[source]

Render all requested frames and return associated transforms dictionary.

Parameters:
  • frame_numbers (Iterable[int]) – frames to render.

  • allow_skips (bool, optional) – if true, blender will not re-render and overwrite existing frames. Applies to every selected output; the render is skipped only when all of them exist. Defaults to True.

  • dry_run (bool, optional) – if true, nothing will be rendered at all. Defaults to False.

  • update_fn (UpdateFn, optional) – callback function to track render progress. Will first be called with total kwarg, indicating number of steps to be taken, then will be called with advance=1 at every step. Closely mirrors the rich.Progress API. Defaults to None.

Raises:

RuntimeError – raised if trying to render frames beyond blender’s limits.

exposed_render_animation(frame_start: int | None = None, frame_end: int | None = None, frame_step: int | None = None, allow_skips=True, dry_run=False, update_fn: UpdateFn | None = None) → None[source]

Determines frame range to render, sets camera positions and orientations, and renders all frames in animation range.

Note: All frame start/end/step arguments are absolute quantities, applied after any keyframe moves.

If the animation is from (1-100) and you’ve scaled it by calling move_keyframes(scale=2.0) then calling render_animation(frame_start=1, frame_end=100) will only render half of the animation. By default the whole animation will render when no start/end and step values are set.

Parameters:
  • frame_start (int, optional) – Starting index (inclusive) of frames to render as seen in blender. Defaults to None, meaning value from .blend file.

  • frame_end (int, optional) – Ending index (inclusive) of frames to render as seen in blender. Defaults to None, meaning value from .blend file.

  • frame_step (int, optional) – Skip every nth frame. Defaults to None, meaning value from .blend file.

  • allow_skips (bool, optional) – Same as render_current_frame.

  • dry_run (bool, optional) – Same as render_current_frame.

  • update_fn (UpdateFn, optional) – Same as render_frames.

Raises:

ValueError – raised if scene and camera are entirely static.

exposed_render_playblast(frame_start: int | None = None, frame_end: int | None = None, frame_step: int | None = None, video: bool = True, allow_skips=True, dry_run=False, update_fn: UpdateFn | None = None) → None[source]

Render a fast preview of the animation using Blender’s viewport/OpenGL renderer.

This uses bpy.ops.render.opengl in animation mode, which reuses whatever viewport engine, shading and anti-aliasing settings are configured in the blend-file (these are NOT affected by RenderConfig). Output is written to a dedicated playblast/ directory, separate from any ground truth outputs.

Note: All frame start/end/step arguments are absolute quantities, applied after any keyframe moves.

By default the whole animation will render when no start/end and step values are set.

Note: This does NOT restore the context it was called in. Like the other render methods, the scene

is mutated in place (frame range, render filepath, image/file format and registered outputs). Reopen the blend-file if you need to reset these attributes.

Parameters:
  • frame_start (int, optional) – Starting index (inclusive) of frames to render as seen in blender. Defaults to None, meaning value from .blend file.

  • frame_end (int, optional) – Ending index (inclusive) of frames to render as seen in blender. Defaults to None, meaning value from .blend file.

  • frame_step (int, optional) – Skip every nth frame. Defaults to None, meaning value from .blend file.

  • video (bool, optional) – If true, encode the preview as a single video file (playblast/playblast.mp4). If false, save a sequence of PNG images (playblast/0001.png, …) along with a playblast/transforms.db metadata database. Defaults to True.

  • allow_skips (bool, optional) – If true, skip rendering when the output already exists. Defaults to True.

  • dry_run (bool, optional) – If true, nothing will be rendered at all. Defaults to False.

  • update_fn (UpdateFn, optional) – Same as render_frames.

Raises:
  • RuntimeError – raised if the running Blender version is too old to support this feature, or if there is no window/3D-viewport context available (eg: Blender is running in background mode).

  • ValueError – raised if scene and camera are entirely static.

exposed_save_file(path: str | PathLike) → None[source]

Save the opened blender file. This is useful for introspecting the state of the compositor/scene/etc.

Parameters:

path (str | os.PathLike) – path where to save blendfile.

Raises:

ValueError – raised if file already exists.

class visionsim.simulate.blender.BlenderClient(addr: tuple[str, int], timeout: float = 10.0)[source]

Bases: object

Client-side API to interact with blender and render novel views.

The BlenderClient is responsible for communicating with (and potentially spawning) separate BlenderServer`s that will actually perform the rendering via a :class:`BlenderService.

The client acts as a context manager, it will connect to it’s server when the context is entered and cleanly disconnect and close the connection in case of errors or when exiting the with-block.

Many useful methods to interact with blender are provided, such as set_resolution or render_animation. These methods are dynamically generated when the client connects to the server. Available methods are directly inherited from BlenderService (or whichever service the server is exposing), specifically any service method starting with exposed_ will be accessible to the client at runtime. For example, BlenderClient.include_depths is a remote procedure call to BlenderService.exposed_include_depths().

__init__(addr: tuple[str, int], timeout: float = 10.0) → None[source]

Initialize a client with known address of server. Note: Using auto_connect() or spawn() is often more convenient.

Parameters:
  • addr (tuple[str, int]) – Connection tuple containing the hostname and port

  • timeout (float, optional) – Maximum time in seconds the client will attempt to connect to the server for before an error is thrown. Only used when entering context manager. Defaults to 10 seconds.

addr: tuple[str, int]
conn: Connection | None
awaitable: AsyncResult | None
process: Popen | None
timeout: float
classmethod auto_connect(timeout: float = 10.0) → Self[source]

Automatically connect to available server.

Use BlenderServer.discover() to find available server within timeout.

Note: This doesn’t actually connect to the server instance, the connection happens

when the context manager is entered. This simply creates a client instance with the connection settings (i.e: hostname, port) of an existing server. The connection might still fail when entering the with-block.

Parameters:

timeout (float, optional) – try to discover server instance for timeout (in seconds) before giving up. Defaults to 10.0 seconds.

Raises:

TimeoutError – raise if unable to discover server in timeout seconds.

Returns:

client instance initialized with connection settings of existing server.

Return type:

Self

classmethod spawn(timeout: float = 0.0, log: str | os.PathLike | FILE | tuple[FILE, FILE] = -3, autoexec: bool = False, executable: str | os.PathLike | None = None, service: str | None = None, background: bool = True, factory_startup: bool = False, env: dict[str, str] | None = None) → Generator[Self][source]

Spawn and connect to a blender server. The spawned process is accessible through the client’s process attribute.

Parameters:
  • timeout (float, optional) – wait up to timeout seconds for each spawned server to accept connections on its reserved port before giving up. Zero (the default) skips the wait and yields immediately, even if a server is not yet ready to accept incoming connections; the client connecting to it is expected to retry.

  • log (str | os.PathLike | FILE | tuple[FILE, FILE], optional) – path to log directory, file handle, descriptor or tuple thereof. Stdout and stderr will be captured and saved if supplied. Defaults to subprocess.DEVNULL for both stdout/stderr.

  • autoexec (bool, optional) – if true, allow execution of any embedded python scripts within blender. For more, see blender’s CLI documentation. Defaults to False.

  • executable (str | os.PathLike | None, optional) – path to Blender’s executable. Defaults to looking for blender on $PATH, but is useful when targeting a specific blender install, or when it’s installed via a package manager such as flatpak. Setting it to “flatpak run –die-with-parent org.blender.Blender” might be required when using flatpaks. Defaults to None (system PATH).

  • service (str | None, optional) – path of the BlenderService subclass the spawned server should expose, either dotted (module:ClassName) or a /path/to/service.py:ClassName file. Defaults to None (the base BlenderService).

  • background (bool, optional) – if true, spawn blender in background mode (-b). Background mode has no OpenGL context, so viewport renders (playblasts) require background=False, which also requires a display. Defaults to True.

  • factory_startup (bool, optional) – if true, pass --factory-startup so the run ignores the machine’s blender preferences and startup file. Defaults to False.

  • env (dict[str, str] | None, optional) – extra environment variables for the spawned blender, such as PYTHONPATH. Merged over the parent’s os.environ, which is inherited by default. Defaults to None.

Yields:

Generator[Self] – the connected client

render_animation_async(*args, **kwargs) → AsyncResult[source]

Asynchronously call render_animation and return an rpyc.AsyncResult.

Parameters:
Returns:

Result encapsulating the return value of render_animation.

After wait``ing for the render to finish, it can be accessed using the ``.value attribute.

Return type:

rpyc.AsyncResult

render_frames_async(*args, **kwargs) → AsyncResult[source]

Asynchronously call render_frames and return an rpyc.AsyncResult.

Parameters:
Returns:

Result encapsulating the return value of render_frames.

After wait``ing for the render to finish, it can be accessed using the ``.value attribute.

Return type:

rpyc.AsyncResult

render_playblast_async(*args, **kwargs) → AsyncResult[source]

Asynchronously call render_playblast and return an rpyc.AsyncResult.

Parameters:
Returns:

Result encapsulating the return value of render_playblast.

After wait``ing for the render to finish, it can be accessed using the ``.value attribute.

Return type:

rpyc.AsyncResult

wait() → None[source]

Block and await any async results.

common_animation_range() → range[source]

Get the animation range of this client as range(start, end+1, step).

Returns:

Range of frames in animation.

Return type:

range

class visionsim.simulate.blender.BlenderClients(*objs: Iterator[BlenderClient | tuple[str, int]])[source]

Bases: tuple

Collection of BlenderClient instances.

Most methods in this class simply call the equivalent method of each client, that is, calling clients.set_resolution is equivalent to calling set_resolution for each client in clients. Some special methods, namely the render_frames() and render_animation() methods will instead distribute the rendering load to all clients.

Finally, entering each client’s context-manager, and closing each client connection is ensured by using this class’ context-manager.

__init__(*objs) → None[source]

Initialize collection of BlenderClient from iterable of clients, or their connection settings.

Parameters:

*objs (Iterator[BlenderClient | tuple[str, int]]) – BlenderClient instances or their hostnames and ports.

stack: ExitStack
classmethod spawn(jobs: int = 1, timeout: float = 0.0, log: str | os.PathLike | FILE | tuple[FILE, FILE] = -3, autoexec: bool = False, executable: str | os.PathLike | None = None, service: str | None = None, background: bool = True, factory_startup: bool = False, env: dict[str, str] | None = None) → Generator[Self][source]

Spawn and connect to one or more blender servers. The spawned processes are accessible through the client’s process attribute.

Parameters:
  • jobs (int, optional) – number of jobs to spawn. Defaults to 1.

  • timeout (float, optional) – wait up to timeout seconds for each spawned server to accept connections on its reserved port before giving up. Zero (the default) skips the wait and yields immediately, even if a server is not yet ready to accept incoming connections; the client connecting to it is expected to retry.

  • log (str | os.PathLike | FILE | tuple[FILE, FILE], optional) – path to log directory, file handle, descriptor or tuple thereof. Stdout and stderr will be captured and saved if supplied. Defaults to subprocess.DEVNULL for both stdout/stderr.

  • autoexec (bool, optional) – if true, allow execution of any embedded python scripts within blender. For more, see blender’s CLI documentation. Defaults to False.

  • executable (str | os.PathLike | None, optional) – path to Blender’s executable. Defaults to looking for blender on $PATH, but is useful when targeting a specific blender install, or when it’s installed via a package manager such as flatpak. Setting it to “flatpak run –die-with-parent org.blender.Blender” might be required when using flatpaks. Defaults to None (system PATH).

  • service (str | None, optional) – path of the BlenderService subclass the spawned server should expose, either dotted (module:ClassName) or a /path/to/service.py:ClassName file. Defaults to None (the base BlenderService).

  • background (bool, optional) – if true, spawn blender instances in background mode (-b). Background mode has no OpenGL context, so viewport renders (playblasts) require background=False, which also requires a display. Defaults to True.

  • factory_startup (bool, optional) – if true, pass --factory-startup so the run ignores the machine’s blender preferences and startup file. Defaults to False.

  • env (dict[str, str] | None, optional) – extra environment variables for the spawned blender instances, such as PYTHONPATH. Merged over the parent’s os.environ, which is inherited by default. Defaults to None.

Yields:

Generator[Self] – the connected clients

pool(timeout: float = 0.0, log: str | os.PathLike | FILE | tuple[FILE, FILE] = -3, autoexec: bool = False, executable: str | os.PathLike | None = None, service: str | None = None, background: bool = True, factory_startup: bool = False, env: dict[str, str] | None = None, conns: list[tuple[str, int]] | None = None) → Generator[multiprocess.Pool][source]

Spawns a multiprocessing-like worker pool, each with their own BlenderClient instance. The function supplied to pool.map/imap/starmap and their async variants will be automagically passed a client instance as their first argument that they can use for rendering.

Example

def render(client, blend_file):
    root = Path("renders") / Path(blend_file).stem
    client.initialize(blend_file, root)
    client.render_animation()

if __name__ == "__main__":
    with BlenderClients.pool(2) as pool:
        pool.map(render, ["monkey.blend", "cube.blend", "metaballs.blend"])

Note

Here we use multiprocess instead of the builtin multiprocessing library to take advantage of the more advanced dill serialization (as opposed to the standard pickling).

Parameters:
  • jobs (int, optional) – number of jobs to spawn. Defaults to 1.

  • timeout (float, optional) – wait up to timeout seconds for each spawned server to accept connections on its reserved port before giving up. Zero (the default) skips the wait and yields immediately, even if a server is not yet ready to accept incoming connections; the client connecting to it is expected to retry.

  • log (str | os.PathLike | FILE | tuple[FILE, FILE], optional) – path to log directory, file handle, descriptor or tuple thereof. Stdout and stderr will be captured and saved if supplied. Defaults to subprocess.DEVNULL for both stdout/stderr.

  • autoexec (bool, optional) – if true, allow execution of any embedded python scripts within blender. For more, see blender’s CLI documentation. Defaults to False.

  • executable (str | os.PathLike | None, optional) – path to Blender’s executable. Defaults to looking for blender on $PATH, but is useful when targeting a specific blender install, or when it’s installed via a package manager such as flatpak. Setting it to “flatpak run –die-with-parent org.blender.Blender” might be required when using flatpaks. Defaults to None (system PATH).

  • service (str | None, optional) – path of the BlenderService subclass each spawned server should expose, either dotted (module:ClassName) or a /path/to/service.py:ClassName file. Defaults to None (the base BlenderService).

  • background (bool, optional) – if true, spawn blender instances in background mode (-b). Background mode has no OpenGL context, so viewport renders (playblasts) require background=False, which also requires a display. Defaults to True.

  • factory_startup (bool, optional) – if true, pass --factory-startup so the runs ignore the machine’s blender preferences and startup file. Defaults to False.

  • env (dict[str, str] | None, optional) – extra environment variables for the spawned blender instances, such as PYTHONPATH. Merged over the parent’s os.environ, which is inherited by default. Defaults to None.

  • conns – List of connection tuples containing the hostnames and ports of existing servers. If specified, the pool will use these servers (and jobs and other spawn arguments will be ignored) instead of spawning new ones.

Yields:

Generator[multiprocess.Pool] –

A multiprocess.Pool instance which has had it’s applicator methods

(map/imap/starmap/etc) monkey-patched to inject a client instance as first argument.

common_animation_range() → range[source]

Get animation range shared by all clients as range(start, end+1, step).

Raises:

RuntimeError – animation ranges for all clients are expected to be the same.

Returns:

Range of frames in animation.

Return type:

range

common_animation_range_tuple() → tuple[int, int, int][source]

Get animation range shared by all clients as a tuple of (start, end, step).

Raises:

RuntimeError – animation ranges for all clients are expected to be the same.

Returns:

Frame start, end, and step of animation.

Return type:

tuple[int, int, int]

render_frames(frame_numbers: Collection[int], allow_skips: bool = True, dry_run: bool = False, update_fn: UpdateFn | None = None) → None[source]

Render all requested frames by distributing workload across connected clients and return associated transforms dictionary.

Warning

Assumes all clients are initialized in the same manner, that is, to the same blendfile, with the same animation range, render settings, etc.

Parameters:
  • frame_numbers (Collection[int]) – frames to render.

  • allow_skips (bool, optional) – if true, blender will not re-render and overwrite existing frames. Applies to every selected output; the render is skipped only when all of them exist. Defaults to True.

  • dry_run (bool, optional) – if true, nothing will be rendered at all. Defaults to False.

  • update_fn (UpdateFn, optional) –

    callback function to track render progress. Will first be called with total kwarg, indicating number of steps to be taken, then will be called with advance=1 at every step. Closely mirrors the rich.Progress API. Defaults to None.

Raises:

RuntimeError – raised if trying to render frames beyond blender’s limits.

render_animation(frame_start: int | None = None, frame_end: int | None = None, frame_step: int | None = None, allow_skips=True, dry_run=False, update_fn: UpdateFn | None = None) → None[source]

Determines frame range to render, sets camera positions and orientations, and renders all frames in animation range by distributing workload onto all connected clients.

Note: All frame start/end/step arguments are absolute quantities, applied after any keyframe moves.

If the animation is from (1-100) and you’ve scaled it by calling move_keyframes(scale=2.0) then calling render_animation(frame_start=1, frame_end=100) will only render half of the animation. By default the whole animation will render when no start/end and step values are set.

Parameters:
  • frame_start (int, optional) – Starting index (inclusive) of frames to render as seen in blender. Defaults to None, meaning value from .blend file.

  • frame_end (int, optional) – Ending index (inclusive) of frames to render as seen in blender. Defaults to None, meaning value from .blend file.

  • frame_step (int, optional) – Skip every nth frame. Defaults to None, meaning value from .blend file.

  • allow_skips (bool, optional) – Same as render_current_frame.

  • dry_run (bool, optional) – Same as render_current_frame.

  • update_fn (UpdateFn, optional) – Same as render_frames.

Raises:

ValueError – raised if scene and camera are entirely static.

save_file(path: str | PathLike) → None[source]

Save opened blender file. This is useful for introspecting the state of the compositor/scene/etc.

Note: Only saves file once (from a single connected client), assumes all clients have

been initialized in the same manner.

Parameters:

path (str | os.PathLike) – path where to save blendfile.

Raises:

ValueError – raised if file already exists.

wait() → None[source]

Wait for all clients at once.

visionsim.simulate.config module

class visionsim.simulate.config.CompositesConfig(file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] | None = None, color_mode: Literal['BW', 'RGB', 'RGBA'] | None = None, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] | None = None, bit_depth: int | None = None)[source]

Bases: object

Same as FramesConfig(), except with all defaults set to None such that they are inherited from the blendfile. For more information see include_composites.

file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] | None = None

File format used to save composited frames

color_mode: Literal['BW', 'RGB', 'RGBA'] | None = None

grayscale, color or color+alpha

Type:

Mode to save composited frames in

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] | None = None

Encoding used to compress EXRs, only used when file_format='OPEN_EXR'

bit_depth: int | None = None

Bit depth for intensity frames. Usually 8 for pngs, 32 or 16 bits for OPEN_EXR

__init__(file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] | None = None, color_mode: Literal['BW', 'RGB', 'RGBA'] | None = None, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] | None = None, bit_depth: int | None = None) → None
class visionsim.simulate.config.FramesConfig(file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] = 'PNG', color_mode: Literal['BW', 'RGB', 'RGBA'] = 'RGB', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[8, 16, 32] = 8)[source]

Bases: object

Same as CompositesConfig(), except with sensible defaults. For more information see include_frames.

file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] = 'PNG'

File format used to save ground truth frames

color_mode: Literal['BW', 'RGB', 'RGBA'] = 'RGB'

grayscale, color or color+alpha

Type:

Mode to save ground truth frames in

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA'

Encoding used to compress EXRs, only used when file_format='OPEN_EXR'

bit_depth: Literal[8, 16, 32] = 8

Bit depth for intensity frames. Usually 8 for pngs, 32 or 16 bits for OPEN_EXR

__init__(file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] = 'PNG', color_mode: Literal['BW', 'RGB', 'RGBA'] = 'RGB', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[8, 16, 32] = 8) → None
class visionsim.simulate.config.DepthsConfig(preview: bool = True, file_format: Literal['OPEN_EXR', 'HDR'] = 'OPEN_EXR', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32)[source]

Bases: object

For more information see include_depths.

preview: bool = True

Also save colorized depth maps as PNGs

file_format: Literal['OPEN_EXR', 'HDR'] = 'OPEN_EXR'

File format used to save depth maps

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA'

Encoding used to compress EXRs, only used when file_format='OPEN_EXR'

bit_depth: Literal[16, 32] = 32

Bit depth used for saving depth maps. Usually 32 or 16 bits for OPEN_EXR and 32 for HDR

__init__(preview: bool = True, file_format: Literal['OPEN_EXR', 'HDR'] = 'OPEN_EXR', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32) → None
class visionsim.simulate.config.NormalsConfig(preview: bool = True, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32)[source]

Bases: object

For more information see include_normals.

preview: bool = True

Also save colorized normal maps as PNGs

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA'

Encoding used to compress EXRs

bit_depth: Literal[16, 32] = 32

Bit depth used for saving normal maps

__init__(preview: bool = True, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32) → None
class visionsim.simulate.config.FlowsConfig(preview: bool = True, direction: Literal['forward', 'backward', 'both'] = 'forward', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32)[source]

Bases: object

For more information see include_flows.

preview: bool = True

Also save colorized flow maps as PNGs

direction: Literal['forward', 'backward', 'both'] = 'forward'

Direction of flow to colorize for preview visualization. Only used when preview is true

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA'

Encoding used to compress EXRs

bit_depth: Literal[16, 32] = 32

Bit depth used for saving flow maps

__init__(preview: bool = True, direction: Literal['forward', 'backward', 'both'] = 'forward', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32) → None
class visionsim.simulate.config.SegmentationsConfig(preview: bool = True, shuffle: bool = True, seed: int = 1234, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32)[source]

Bases: object

For more information see include_segmentations.

preview: bool = True

Also save colorized segmentation maps as PNGs

shuffle: bool = True

Shuffle preview colors, helps differentiate object instances

seed: int = 1234

Random seed used when shuffling colors

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA'

Encoding used to compress EXRs

bit_depth: Literal[16, 32] = 32

Bit depth used for saving segmentation maps

__init__(preview: bool = True, shuffle: bool = True, seed: int = 1234, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32) → None
class visionsim.simulate.config.MaterialsConfig(preview: bool = True, shuffle: bool = True, seed: int = 1234, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32)[source]

Bases: object

For more information see include_materials.

preview: bool = True

Also save colorized material passes as PNGs

shuffle: bool = True

Shuffle preview colors, helps differentiate material instances

seed: int = 1234

Random seed used when shuffling colors

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA'

Encoding used to compress EXRs

bit_depth: Literal[16, 32] = 32

Bit depth used for saving material maps

__init__(preview: bool = True, shuffle: bool = True, seed: int = 1234, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32) → None
class visionsim.simulate.config.DiffusePassConfig(file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] = 'OPEN_EXR', color_mode: Literal['BW', 'RGB', 'RGBA'] = 'RGB', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[8, 16, 32] = 32, denoise: bool = True)[source]

Bases: object

For more information see include_diffuse_pass.

file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] = 'OPEN_EXR'

File format used to save diffuse passes

color_mode: Literal['BW', 'RGB', 'RGBA'] = 'RGB'

grayscale, color or color+alpha

Type:

Mode to save diffuse passes in

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA'

Encoding used to compress EXRs

bit_depth: Literal[8, 16, 32] = 32

Bit depth used for saving diffuse passes

denoise: bool = True

If true, apply denoising to the direct and indirect diffuse passes (Cycles only)

__init__(file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] = 'OPEN_EXR', color_mode: Literal['BW', 'RGB', 'RGBA'] = 'RGB', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[8, 16, 32] = 32, denoise: bool = True) → None
class visionsim.simulate.config.SpecularPassConfig(file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] = 'OPEN_EXR', color_mode: Literal['BW', 'RGB', 'RGBA'] = 'RGB', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[8, 16, 32] = 32, denoise: bool = True)[source]

Bases: object

For more information see include_specular_pass.

file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] = 'OPEN_EXR'

File format used to save specular passes

color_mode: Literal['BW', 'RGB', 'RGBA'] = 'RGB'

grayscale, color or color+alpha

Type:

Mode to save specular passes in

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA'

Encoding used to compress EXRs

bit_depth: Literal[8, 16, 32] = 32

Bit depth used for saving specular passes

denoise: bool = True

If true, apply denoising to the direct and indirect specular passes (Cycles only)

__init__(file_format: Literal['BMP', 'IRIS', 'PNG', 'JPEG', 'JPEG2000', 'TARGA', 'CINEON', 'DPX', 'OPEN_EXR', 'HDR', 'TIFF', 'WEBP'] = 'OPEN_EXR', color_mode: Literal['BW', 'RGB', 'RGBA'] = 'RGB', exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[8, 16, 32] = 32, denoise: bool = True) → None
class visionsim.simulate.config.PointsConfig(preview: bool = True, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32)[source]

Bases: object

For more information see include_points.

preview: bool = True

Also save colorized point maps as PNGs

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA'

Encoding used to compress EXRs

bit_depth: Literal[16, 32] = 32

Bit depth used for saving point maps

__init__(preview: bool = True, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'DWAA', bit_depth: Literal[16, 32] = 32) → None
class visionsim.simulate.config.ThermalConfig(radiance: 'bool' = True, preview: 'bool' = True, assignments: 'Path | None' = None, initial_temperature_K: 'float' = 295.0, thermal_diffusivity_mm2_s: 'float' = 0.17, density_kg_m3: 'float' = 1330.0, specific_heat_J_kgK: 'float' = 880.0, emissivity: 'float' = 0.9, irradiance_scale: 'float' = 1.0, sim_time_s: 'float' = 1.0, timestep_s: 'float' = 0.05, bake_samples: 'int' = 1024, irradiance_texture_size: 'int' = 512, device: "Literal['cuda', 'cpu']" = 'cuda', render_domain: "Literal['AUTO', 'VERTEX', 'TEXEL']" = 'AUTO', atlas_texel_density: 'float' = 1500.0, atlas_tile_min: 'int' = 16, atlas_tile_max: 'int' = 512, atlas_texel_soft_max: 'int' = 500000, recompute: 'bool' = False, radiance_scale: 'float' = 1.0, exr_codec: 'EXR_CODECS' = 'ZIP', bit_depth: 'Literal[16, 32]' = 32)[source]

Bases: object

radiance: bool = True

If true, also render the gray-body thermal-camera radiance image (second render pass)

preview: bool = True

Also save an inferno-colormap PNG preview of the temperature map

assignments: Path | None = None

Path to a thermal material assignment sidecar (<scene>.thermal.json). When set, thermal properties are resolved per material slot from the sidecar; otherwise authored object values or the global defaults below apply. Sidecars are described in the thermal rendering tutorial.

initial_temperature_K: float = 295.0

Default initial temperature for meshes without a per-object value

thermal_diffusivity_mm2_s: float = 0.17

Default thermal diffusivity (mm^2/s)

density_kg_m3: float = 1330.0

Default material density (kg/m^3)

specific_heat_J_kgK: float = 880.0

Default specific heat (J/kg*K)

emissivity: float = 0.9

Default surface emissivity in [0, 1]

irradiance_scale: float = 1.0

Scale factor applied to computed irradiance (heating input)

sim_time_s: float = 1.0

Total simulated time in seconds (static scene mode)

timestep_s: float = 0.05

Solver timestep in seconds

bake_samples: int = 1024

Cycles irradiance bake samples; adaptive sampling is disabled.

irradiance_texture_size: int = 512

Width and height of the square Cycles albedo and irradiance bakes.

device: Literal['cuda', 'cpu'] = 'cuda'

Torch device for the solve; falls back to cpu if cuda is unavailable

__init__(radiance: bool = True, preview: bool = True, assignments: Path | None = None, initial_temperature_K: float = 295.0, thermal_diffusivity_mm2_s: float = 0.17, density_kg_m3: float = 1330.0, specific_heat_J_kgK: float = 880.0, emissivity: float = 0.9, irradiance_scale: float = 1.0, sim_time_s: float = 1.0, timestep_s: float = 0.05, bake_samples: int = 1024, irradiance_texture_size: int = 512, device: Literal['cuda', 'cpu'] = 'cuda', render_domain: Literal['AUTO', 'VERTEX', 'TEXEL'] = 'AUTO', atlas_texel_density: float = 1500.0, atlas_tile_min: int = 16, atlas_tile_max: int = 512, atlas_texel_soft_max: int = 500000, recompute: bool = False, radiance_scale: float = 1.0, exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'ZIP', bit_depth: Literal[16, 32] = 32) → None
render_domain: Literal['AUTO', 'VERTEX', 'TEXEL'] = 'AUTO'

AUTO selects texels for coarse surfaces and vertices for suitable dense meshes.

TEXEL forces atlas sampling; VERTEX forces mesh-vertex sampling.

atlas_texel_density: float = 1500.0

Target solve texels per square metre on atlas-selected surfaces.

atlas_tile_min: int = 16

Minimum atlas tile side, in texels (per object).

atlas_tile_max: int = 512

Maximum atlas tile side, in texels (per object).

atlas_texel_soft_max: int = 500000

Soft ceiling on total atlas texels + retained vertices; exceeding it rescales the effective density down uniformly and warns, rather than allocating an unbounded solve.

recompute: bool = False

Bypass reusable thermal solve results and regenerate bakes.

radiance_scale: float = 1.0

Gray-body emission magnitude knob for the thermal_radiance render

exr_codec: Literal['NONE', 'PXR24', 'ZIP', 'PIZ', 'RLE', 'ZIPS', 'DWAA', 'DWAB'] = 'ZIP'

Encoding used to compress EXRs

bit_depth: Literal[16, 32] = 32

Bit depth for temperature/radiance EXRs

class visionsim.simulate.config.RenderConfig(load: 'Path | None' = None, dump: 'Path | None' = None, executable: 'Path | None' = None, height: 'int | None' = None, width: 'int | None' = None, resolution_percentage: 'int' = 100, include_composites: 'bool' = False, composites: 'CompositesConfig' = <factory>, include_frames: 'bool' = True, frames: 'FramesConfig' = <factory>, include_depths: 'bool' = False, depths: 'DepthsConfig' = <factory>, include_normals: 'bool' = False, normals: 'NormalsConfig' = <factory>, include_flows: 'bool' = False, flows: 'FlowsConfig' = <factory>, include_segmentations: 'bool' = False, segmentations: 'SegmentationsConfig' = <factory>, include_materials: 'bool' = False, materials: 'MaterialsConfig' = <factory>, include_diffuse_pass: 'bool' = False, diffuse_pass: 'DiffusePassConfig' = <factory>, include_specular_pass: 'bool' = False, specular_pass: 'SpecularPassConfig' = <factory>, include_points: 'bool' = False, points: 'PointsConfig' = <factory>, include_thermal: 'bool' = False, thermal: 'ThermalConfig' = <factory>, include_all: 'bool' = False, previews: 'bool' = True, keyframe_multiplier: 'float' = 1.0, timeout: 'int' = 0, autoexec: 'bool' = True, device_type: "Literal['cpu', 'cuda', 'optix', 'metal']"='optix', adaptive_threshold: 'float' = 0.05, max_samples: 'int' = 256, use_denoising: 'bool' = True, log_dir: 'Path' = PosixPath('logs'), allow_skips: 'bool' = True, unbind_camera: 'bool' = False, use_animations: 'bool' = True, use_motion_blur: 'bool | None' = None, addons: 'list[str] | None' = None, jobs: 'int' = 1, autoscale: 'bool' = False, max_job_vram: 'MemSize | None' = None, camera_offset: 'tuple[float, float, float] | None'=None)[source]

Bases: ConfigIO

__init__(load: Path | None = None, dump: Path | None = None, executable: Path | None = None, height: int | None = None, width: int | None = None, resolution_percentage: int = 100, include_composites: bool = False, composites: CompositesConfig = <factory>, include_frames: bool = True, frames: FramesConfig = <factory>, include_depths: bool = False, depths: DepthsConfig = <factory>, include_normals: bool = False, normals: NormalsConfig = <factory>, include_flows: bool = False, flows: FlowsConfig = <factory>, include_segmentations: bool = False, segmentations: SegmentationsConfig = <factory>, include_materials: bool = False, materials: MaterialsConfig = <factory>, include_diffuse_pass: bool = False, diffuse_pass: DiffusePassConfig = <factory>, include_specular_pass: bool = False, specular_pass: SpecularPassConfig = <factory>, include_points: bool = False, points: PointsConfig = <factory>, include_thermal: bool = False, thermal: ThermalConfig = <factory>, include_all: bool = False, previews: bool = True, keyframe_multiplier: float = 1.0, timeout: int = 0, autoexec: bool = True, device_type: Literal['cpu', 'cuda', 'optix', 'metal']='optix', adaptive_threshold: float = 0.05, max_samples: int = 256, use_denoising: bool = True, log_dir: Path = PosixPath('logs'), allow_skips: bool = True, unbind_camera: bool = False, use_animations: bool = True, use_motion_blur: bool | None = None, addons: list[str] | None = None, jobs: int = 1, autoscale: bool = False, max_job_vram: Annotated[int, ~tyro.constructors._primitive_spec.PrimitiveConstructorSpec(nargs=1, metavar=BYTES, instance_from_str=~visionsim.types._bytes_from_str, is_instance=~visionsim.types.<lambda>, str_from_instance=~visionsim.types._bytes_to_str, choices=None, _action=None)] | None = None, camera_offset: tuple[float, float, float] | None=None) → None
executable: Path | None = None

Path to blender executable

height: int | None = None

Height of rendered frames in pixels

width: int | None = None

Width of rendered frames in pixels

resolution_percentage: int = 100

Percentage of the original resolution to render at

include_composites: bool = False

If true, enable composited outputs

composites: CompositesConfig

Composited frames configuration options

include_frames: bool = True

If true, enable ground truth frame outputs

frames: FramesConfig

Ground truth frames configuration options

include_depths: bool = False

If true, enable depth map outputs

depths: DepthsConfig

Depth maps configuration options

include_normals: bool = False

If true, enable normal map outputs

normals: NormalsConfig

Normal maps configuration options

include_flows: bool = False

If true, enable optical flow outputs

flows: FlowsConfig

Optical flow configuration options

include_segmentations: bool = False

If true, enable segmentation map outputs

segmentations: SegmentationsConfig

Segmentation maps configuration options

include_materials: bool = False

If true, enable material map outputs

materials: MaterialsConfig

Material maps configuration options

include_diffuse_pass: bool = False

If true, enable diffuse light pass outputs

diffuse_pass: DiffusePassConfig

Diffuse light passes configuration options

include_specular_pass: bool = False

If true, enable specular light pass outputs

specular_pass: SpecularPassConfig

Specular light passes configuration options

include_points: bool = False

If true, enable world-space point map outputs

points: PointsConfig

Point maps configuration options

include_thermal: bool = False

If true, enable thermal outputs (temperature map + thermal-camera radiance)

thermal: ThermalConfig

Thermal modality configuration options

include_all: bool = False

If true, enable all ground truth outputs; applied by resolved()

previews: bool = True

If false, disable all preview visualizations of auxiliary outputs; applied by resolved()

keyframe_multiplier: float = 1.0

2.0 will slow down time

Type:

Stretch keyframes by this amount, eg

timeout: int = 0

Maximum allowed time in seconds to wait to connect to render instance; zero uses the assigned port directly

autoexec: bool = True

potentially dangerous)

Type:

If true, allow python execution of embedded scripts (warning

device_type: Literal['cpu', 'cuda', 'optix', 'metal'] = 'optix'

Name of device to use, one of “cpu”, “cuda”, “optix”, “metal”, etc

adaptive_threshold: float = 0.05

Noise threshold of rendered images, for higher quality frames make this threshold smaller. The default value is intentionally a little high to speed up renders

max_samples: int = 256

Maximum number of samples per pixel to take

use_denoising: bool = True

If enabled, a denoising pass will be used

log_dir: Path = PosixPath('logs')

Directory to use for logging

allow_skips: bool = True

If true, skip rendering a frame if it already exists

unbind_camera: bool = False

Free the camera from it’s parents, any constraints and animations it may have. Ensures it uses the world’s coordinate frame and the provided camera trajectory

use_animations: bool = True

Allow any animations to play out, if false, scene will be static

use_motion_blur: bool | None = None

Enable realistic motion blur. cannot be used if also rendering optical flow

addons: list[str] | None = None

List of extra addons to enable

jobs: int = 1

Number of concurrent render jobs

autoscale: bool = False

Set number of jobs automatically based on available VRAM and max_job_vram when enabled

max_job_vram: _bytes_to_str, choices=None, _action=None)] | None = None

Maximum allowable VRAM per job in bytes (limit is not enforced, simply used for autoscale); required when autoscale is enabled

camera_offset: tuple[float, float, float] | None = None

Camera offset to apply in local coordinates (x, y, z).

resolved() → RenderConfig[source]

Return a copy with include_all and previews applied to the individual pass options.

The configuration stays declarative: include_all and previews are only expanded when the render actually starts, so instances parsed by tyro keep the values the user expressed. Calling this method repeatedly is safe.

Returns:

Copy of this configuration with all aliases resolved.

Return type:

RenderConfig

visionsim.simulate.install module

visionsim.simulate.job module

visionsim.simulate.job.render_job(client: BlenderClient | BlenderClients, blend_file: str | PathLike, root: str | PathLike, config: RenderConfig, *, frame_start: int | None = None, frame_end: int | None = None, frame_step: int | None = None, output_blend_file: str | PathLike | None = None, dry_run: bool = False, update_fn: UpdateFn | None = None) → None[source]

Render a sequence from a given blender-file.

Parameters:
  • client (BlenderClient | BlenderClients) – The blender client(s) which will be used for rendering. These should already be connected to a BlenderServer, and will get automagically passed in when using this function with BlenderClients.pool or similar.

  • blend_file (str | os.PathLike) – Path to blender file to use.

  • root (str | os.PathLike) – Location at which to save all outputs.

  • config (RenderConfig) – Render configuration.

  • frame_start (int | None, optional) – Frame index to start capture at (inclusive). If None, use start of animation range.

  • frame_end (int | None, optional) – frame number to stop capture at (inclusive). If None, use end of animation range.

  • frame_step (int | None, optional) – Step with which to capture frames. If None, use step of animation range.

  • output_blend_file (str | os.PathLike | None, optional) – If set, write the modified blend file to this path. Helpful for troubleshooting. Defaults to not saving.

  • dry_run (bool, optional) – If enabled, do not render any frames or ground truth annotations.

  • update_fn (UpdateFn | None, optional) –

    callback function to track render progress. Will first be called with total kwarg, indicating number of steps to be taken, then will be called with advance=1 at every step. Closely mirrors the rich.Progress API.

visionsim.simulate.job.frame_job(client: BlenderClient, blend_file: str | PathLike, root: str | PathLike, config: RenderConfig, *, frame_number: int, output_blend_file: str | PathLike | None = None, dry_run: bool = False) → None[source]

Render a single frame from a given blender-file.

Parameters:
  • client (BlenderClient) – The blender client which will be used for rendering. It should already be connected to a BlenderServer.

  • blend_file (str | os.PathLike) – Path to blender file to use.

  • root (str | os.PathLike) – Location at which to save all outputs.

  • config (RenderConfig) – Render configuration.

  • frame_number (int) – Index of the frame to render.

  • output_blend_file (str | os.PathLike | None, optional) – If set, write the modified blend file to this path. Helpful for troubleshooting. Defaults to not saving.

  • dry_run (bool, optional) – If enabled, do not render the frame or ground truth annotations.

visionsim.simulate.job.playblast_job(client: BlenderClient, blend_file: str | PathLike, root: str | PathLike, config: RenderConfig, *, frame_start: int | None = None, frame_end: int | None = None, frame_step: int | None = None, video: bool = True, output_blend_file: str | PathLike | None = None, dry_run: bool = False, update_fn: UpdateFn | None = None) → None[source]

Render a fast preview (playblast) of a sequence from a given blender-file.

Unlike render_job(), this uses Blender’s viewport/OpenGL renderer and produces no ground truth annotations. Only the color preview is written, either as a video file or a PNG frame sequence (see render_playblast).

Parameters:
  • client (BlenderClient) – The blender client which will be used for rendering. It should already be connected to a BlenderServer, and must not be running in background mode.

  • blend_file (str | os.PathLike) – Path to blender file to use.

  • root (str | os.PathLike) – Location at which to save all outputs.

  • config (RenderConfig) – Render configuration.

  • frame_start (int | None, optional) – Frame index to start capture at (inclusive). If None, use start of animation range.

  • frame_end (int | None, optional) – frame number to stop capture at (inclusive). If None, use end of animation range.

  • frame_step (int | None, optional) – Step with which to capture frames. If None, use step of animation range.

  • video (bool, optional) – If true, encode the preview as a single video file, otherwise save a PNG frame sequence along with a metadata database. Defaults to True.

  • output_blend_file (str | os.PathLike | None, optional) – If set, write the modified blend file to this path. Helpful for troubleshooting. Defaults to not saving.

  • dry_run (bool, optional) – If enabled, do not render any frames.

  • update_fn (UpdateFn | None, optional) –

    callback function to track render progress. Will first be called with total kwarg, indicating number of steps to be taken, then will be called with advance=1 at every step. Closely mirrors the rich.Progress API.

visionsim.simulate.schema module

Module contents

visionsim.simulate.install_dependencies(executable: str | PathLike | None = None, editable: bool = False, version: str | None = None, path: str | None = None, torch_index_url: str | None = None) → CompletedProcess[source]

Install additional packages into blender`s runtime.

Parameters:
  • executable (str | os.PathLike | None, optional) – Path to the blender executable to use. Defaults to one on PATH.

  • editable – (bool, optional): If set, install current visionsim as editable in blender. Only works if visionsim is already installed as editable locally.

  • version (str | None, optional) – The version of visionsim to install. Setting this is akin to specifying the version when pip installing. If set, a fresh copy from PyPI will be installed inside blender’s runtime environment, which might not match the currently installed version. Defaults to None (use currently installed version).

  • path (str | None, optional) – The path to the visionsim source code to install, only used when –version is not set.

  • torch_index_url (str | None, optional) – PyTorch wheel index to install torch from, e.g. https://download.pytorch.org/whl/cpu. Defaults to None (whatever PyPI resolves to).