class_docstr: An implementation of a rendering backend in Blender/Cycles.
class_docstr_tok: ["An","implementation","of","a","rendering","backend","in","Blender\/Cycles","."]
docstr: Renders all frames (or a subset) of the animation and returns images as a dict of arrays.
  
  Args:
    frames: list of frames to render (defaults to range(scene.frame_start, scene.frame_end+1)).
    ignore_missing_textures: if False then raise a RuntimeError when missing textures are
      detected. Otherwise, proceed to render (with purple color instead of missing texture).
    return_layers: list of layers to return. For possible values refer to
      the Blender.post_processors dict. Defaults to ("backward_flow",
      "forward_flow", "depth", "normal", "object_coordinates", "segmentation").
  
  Returns:
    A dictionary with one entry for each return layer. By default:
      - "rgba": shape = (nr_frames, height, width, 4)
      - "segmentation": shape = (nr_frames, height, width, 1) (int)
      - "backward_flow": shape = (nr_frames, height, width, 2)
      - "forward_flow": shape = (nr_frames, height, width, 2)
      - "depth": shape = (nr_frames, height, width, 1)
      - "object_coordinates": shape = (nr_frames, height, width, 3) (uint16)
      - "normal": shape = (nr_frames, height, width, 3) (uint16)
docstr_tok: ["Renders","all","frames","(","or","a","subset",")","of","the","animation","and","returns","images","as","a","dict","of","arrays",".","Args",":","frames",":","list","of","frames","to","render","(","defaults","to","range","(","scene.frame_start",",","scene.frame_end+1",")",")",".","ignore_missing_textures",":","if","False","then","raise","a","RuntimeError","when","missing","textures","are","detected",".","Otherwise",",","proceed","to","render","(","with","purple","color","instead","of","missing","texture",")",".","return_layers",":","list","of","layers","to","return",".","For","possible","values","refer","to","the","Blender.post_processors","dict",".","Defaults","to","(","``","backward_flow","''",",","``","forward_flow","''",",","``","depth","''",",","``","normal","''",",","``","object_coordinates","''",",","``","segmentation","''",")",".","Returns",":","A","dictionary","with","one","entry","for","each","return","layer",".","By","default",":","-","``","rgba","''",":","shape","=","(","nr_frames",",","height",",","width",",","4",")","-","``","segmentation","''",":","shape","=","(","nr_frames",",","height",",","width",",","1",")","(","int",")","-","``","backward_flow","''",":","shape","=","(","nr_frames",",","height",",","width",",","2",")","-","``","forward_flow","''",":","shape","=","(","nr_frames",",","height",",","width",",","2",")","-","``","depth","''",":","shape","=","(","nr_frames",",","height",",","width",",","1",")","-","``","object_coordinates","''",":","shape","=","(","nr_frames",",","height",",","width",",","3",")","(","uint16",")","-","``","normal","''",":","shape","=","(","nr_frames",",","height",",","width",",","3",")","(","uint16",")"]
code: def render(
      self,
      frames: Optional[Sequence[int]] = None,
      ignore_missing_textures: bool = False,
      return_layers: Sequence[str] = (
          "rgba",
          "backward_flow",
          "forward_flow",
          "depth",
          "normal",
          "object_coordinates",
          "segmentation",
      ),
  ) -> Dict[str, np.ndarray]:
      """Renders all frames (or a subset) of the animation and returns images as a dict of arrays.
  
      Args:
        frames: list of frames to render (defaults to range(scene.frame_start, scene.frame_end+1)).
        ignore_missing_textures: if False then raise a RuntimeError when missing textures are
          detected. Otherwise, proceed to render (with purple color instead of missing texture).
        return_layers: list of layers to return. For possible values refer to
          the Blender.post_processors dict. Defaults to ("backward_flow",
          "forward_flow", "depth", "normal", "object_coordinates", "segmentation").
  
      Returns:
        A dictionary with one entry for each return layer. By default:
          - "rgba": shape = (nr_frames, height, width, 4)
          - "segmentation": shape = (nr_frames, height, width, 1) (int)
          - "backward_flow": shape = (nr_frames, height, width, 2)
          - "forward_flow": shape = (nr_frames, height, width, 2)
          - "depth": shape = (nr_frames, height, width, 1)
          - "object_coordinates": shape = (nr_frames, height, width, 3) (uint16)
          - "normal": shape = (nr_frames, height, width, 3) (uint16)
      """
      logger.info(
          "Using scratch rendering folder: '%s'", self.scratch_dir
      )
      if not ignore_missing_textures:
          self._check_missing_textures()
      self.set_exr_output_path(self.scratch_dir / "exr" / "frame_")
      # --- starts rendering
      if frames is None:
          frames = range(
              self.scene.frame_start, self.scene.frame_end + 1
          )
      with RedirectStream(stream=sys.stdout, disabled=self.verbose):
          for frame_nr in frames:
              bpy.context.scene.frame_set(frame_nr)
              # When writing still images Blender doesn't append the frame number to the png path.
              # (but for exr it does, so we only adjust the png path)
              bpy.context.scene.render.filepath = str(
                  self.scratch_dir
                  / "images"
                  / f"frame_{frame_nr:04d}.png"
              )
              bpy.ops.render.render(animation=False, write_still=True)
              logger.info(
                  "Rendered frame '%s'",
                  bpy.context.scene.render.filepath,
              )
  
      # --- post process the rendered frames
      return self.postprocess(
          self.scratch_dir, return_layers=return_layers
      )
  
imports: import collections
  import io
  import logging
  import os
  import sys
  from contextlib import redirect_stdout
  from typing import Any, Dict, Optional, Sequence, Union
  import tempfile
  from kubric.safeimport.bpy import bpy
  import numpy
  import tensorflow
  from singledispatchmethod import singledispatchmethod
  import kubric
  from kubric import core
  from kubric.core.assets import UndefinedAsset
  from kubric.redirect_io import RedirectStream
  from kubric.renderer import blender_utils
  from kubric import file_io
  from kubric.file_io import PathLike
label_desc: Use image node_id 16 for calling the Blender obj's underlying member method code with example usage: obj.render(frames, ignore_missing_textures, return_layers) and returns: self