threedb.rendering.render_blender¶
Implements the Blender rendering class that subclasses threedb.rendering.base_renderer.BaseRenderer
:.
This includes all the Blender-specific rendering settings, functions, and configs.
-
threedb.rendering.render_blender.
ENV_EXTENSIONS
= ['blend', 'exr', 'hdr']¶ Utility functions
-
class
threedb.rendering.render_blender.
Blender
(root_dir: str, render_settings: Dict[str, Any], _=None)¶ Bases:
threedb.rendering.base_renderer.BaseRenderer
-
NAME
: str = 'Blender'¶
-
KEYS
: List[str] = ['rgb', 'segmentation', 'uv', 'depth']¶
-
__init__
(root_dir: str, render_settings: Dict[str, Any], _=None) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
static
enumerate_models
(search_dir: str) → List[str]¶ Given a root folder, returns all .blend files in root/blender_models/
-
static
enumerate_environments
(search_dir: str) → List[str]¶ Given a root folder, returns all files in root/blender_environments/ which have extensions in ENV_EXTENSIONS above.
-
declare_outputs
() → Dict[str, Tuple[List[int], str]]¶ This function declares what the output of render() will be, based on the renderer settings. Returns a dictionary mapping keys to (dtype, size) tuples—the output of render() is string-to-tensor dictionary whose tensors will be checked against the return value of this function for both size and type.
A basic implementation which suffices for most applications is provided in the abstract class
threedb.rendering.base_renderer.BaseRenderer
.
-
load_model
(model: str) → threedb.rendering.base_renderer.RenderObject¶ Given a root directory and a model id, loads the model into the renderer and returns the corresponding object.
-
get_model_uid
(loaded_model)¶ Given an 3D model, return its UID as assigned by the renderer.
-
load_env
(env: str) → Optional[threedb.rendering.base_renderer.RenderEnv]¶ Given a root folder and environment ID, load the environment into the renderer. If needed, returns an environment object, to be passed back to the render() function.
-
setup_render
(model: Optional[threedb.rendering.base_renderer.RenderObject], env: Optional[threedb.rendering.base_renderer.RenderEnv]) → None¶ Perform setup operations for rendering. Called only when the model or environment being rendered changes—otherwise, only render() will be called. No return value.
-
get_context_dict
(model_uid: str, object_class: int) → Dict[str, Any]¶ Returns, for a given model id, a “context” dictionary; this context will be passed to the controls (see :class:
threedb.controls.base_control.PreProcessControl
for more info).- Parameters
model_uid (str) – The ID of the model being rendered.
object_class (int) – The class label for the model.
- Returns
A context dictionary
- Return type
Dict[str, Any]
-
render
(model_uid: str, loaded_model: threedb.rendering.base_renderer.RenderObject, loaded_env: threedb.rendering.base_renderer.RenderEnv) → Dict[str, torch.Tensor]¶ [summary]
- Parameters
model_uid (str) – Render a model and environment. You can assume that setup_render() has been called with the relevant model and object in context. This function should also handle applying the pre and post-processing controls.
loaded_model (RenderObject) – The model that was most recently loaded and passed to setup_render.
loaded_env (RenderEnv) – the environment that was most recently loaded and passed to setup_render.
- Returns
A dictionary mapping result keys (e.g., ‘rgb’, ‘segmentation’, etc.) to PyTorch tensor outputs.
- Return type
Dict[str, ch.Tensor]
-
-
threedb.rendering.render_blender.
Renderer
¶